chilcano.apache-nifi

Ansible Role: apache-nifi

This is an Ansible Role that installs, sets up, and runs Apache NiFi. It offers these features:

  • Installs Apache NiFi.
  • Configures Apache NiFi in three ways:
    • http: Standard NiFi setup without security, using HTTP.
    • https: Runs NiFi securely via SSL/TLS with client certificate authentication.
    • tls_toolkit: Uses keys, certificates, and configurations from Apache NiFi to run it securely.
  • Operates Apache NiFi as a systemd service.

Requirements

  • Java.

Role Variables

You can find the default variables in defaults/main.yml.

Dependencies

This Ansible Role has no dependencies, but Apache NiFi does require Java. To install Java, I will use the geerlingguy.java role with modifications to install Oracle Java 8 on Debian. You can find these changes in my fork at chilcano.java / branch oracle-java-debian. Just clone that branch.

If you are using Apache NiFi on Ubuntu or CentOS, you won't need these changes. You can simply download geerlingguy.java or manually install Java 7 or 8 on your system:

$ sudo ansible-galaxy install geerlingguy.java

Example Playbook

- hosts: nf1
  become: yes
  vars_files:
    - vars.yml
  roles:
    - role: ../../playbooks/roles/ansible-role-java
      java_packages:
        - oracle-java8-installer
        - ca-certificates
        - oracle-java8-set-default
      java_cleanup: false
      java_home: "/usr/lib/jvm/java-8-oracle"

    - role: chilcano.apache-nifi
      nifi:
        version: "1.2.0"
        packaging_bin: "tar.gz"
        packaging_src: "zip"
        action:
          clean:
            installer: false
            installation: false
            dependencies: false
          install: true
          run: true
        deployment:
          mode: "http"
          tls_toolkit:
            shared_dir_local: "/Users/Chilcano/1github-repo/binaries"
            hostname: ""
            dir_repo: ""
        download:
          http_uri: "http://mirror.ox.ac.uk/sites/rsync.apache.org"
      nifi_conf_authorizers:
        initial_admin_identity: ""
        nf_hostname_pattern: ""
        nf_domain: ""
        nf_dn_suffix: ""
      nifi_properties_j2:
        nifi.remote.input.host: ""
        nifi.remote.input.secure: false
        nifi.remote.input.socket.port:
        nifi.web.http.host: ""
        nifi.web.http.port: 8080
        nifi.web.https.host: ""
        nifi.web.https.port:
        nifi.security.keystore: ""
        nifi.security.keystoreType: ""
        nifi.security.keystorePasswd: ""
        nifi.security.keyPasswd: ""
        nifi.security.truststore: ""
        nifi.security.truststoreType: ""
        nifi.security.truststorePasswd: ""
        nifi.security.user.authorizer: ""
        nifi.security.user.login.identity.provider: ""
        nifi.cluster.protocol.is.secure: false
        nifi.cluster.node.address: ""
        nifi.cluster.node.protocol.port:
      nifi_sync_dir_local: "/Users/Chilcano/1github-repo/binaries"

- hosts: nf2
  become: yes
  vars_files:
    - vars.yml
  roles:
    - role: ../../playbooks/roles/ansible-role-java
      java_packages:
        - oracle-java8-installer
        - ca-certificates
        - oracle-java8-set-default
      java_cleanup: false
      java_home: "/usr/lib/jvm/java-8-oracle"

    - role: chilcano.apache-nifi
      nifi:
        action:
          clean:
            installer: false
            installation: false
            dependencies: false
          install: true
          run: true
        deployment:
          mode: "https"
          tls_toolkit:
            shared_dir_local: "/Users/Chilcano/1github-repo/binaries"
            hostname: "nftk1"
            dir_repo: "nifi-toolkit_repo"
        download:
          http_uri: "http://mirror.ox.ac.uk/sites/rsync.apache.org"
      nifi_conf_authorizers:
        initial_admin_identity: "{{ _nftk_client_cert_dn }}"
        nf_hostname_pattern: "{{ _nftk_hostname }}"
        nf_domain: "{{ _nftk_domain }}"
        nf_dn_suffix: "{{ _nftk_dn_suffix }}"
      nifi_properties_j2:
        nifi.remote.input.host: ""
        nifi.remote.input.secure: true
        nifi.remote.input.socket.port: 10443
        nifi.web.http.host: ""
        nifi.web.http.port:
        nifi.web.https.host: ""
        nifi.web.https.port: 9443
        nifi.security.keystore: ./conf/keystore.jks
        nifi.security.keystoreType: jks
        nifi.security.keystorePasswd: "{{ _nftk_run_keystorepasswd }}"
        nifi.security.keyPasswd: "{{ _nftk_run_keypasswd }}"
        nifi.security.truststore: ./conf/truststore.jks
        nifi.security.truststoreType: jks
        nifi.security.truststorePasswd: "{{ _nftk_run_truststorepasswd }}"
        nifi.security.user.authorizer: "file-provider"
        nifi.security.user.login.identity.provider: ""
        nifi.cluster.protocol.is.secure: true
        nifi.cluster.node.address: ""
        nifi.cluster.node.protocol.port: 11443
      nifi_sync_dir_local: "/Users/Chilcano/1github-repo/binaries"

- hosts: nf3
  become: yes
  vars_files:
    - vars.yml
  roles:
    - role: ../../playbooks/roles/ansible-role-java
      java_packages:
        - oracle-java8-installer
        - ca-certificates
        - oracle-java8-set-default
      java_cleanup: false
      java_home: "/usr/lib/jvm/java-8-oracle"

    - role: chilcano.apache-nifi
      nifi:
        action:
          clean:
            installer: false
            installation: false
            dependencies: false
          install: true
          run: true
        deployment:
          mode: "tls_toolkit"
          tls_toolkit:
            shared_dir_local: "/Users/Chilcano/1github-repo/binaries"
            hostname: "nftk1"
            dir_repo: "nifi-toolkit_repo"
        download:
          http_uri: "http://mirror.ox.ac.uk/sites/rsync.apache.org"
      nifi_conf_authorizers:
        initial_admin_identity: "{{ _nftk_client_cert_dn }}"
        nf_hostname_pattern: "{{ _nftk_hostname }}"
        nf_domain: "{{ _nftk_domain }}"
        nf_dn_suffix: "{{ _nftk_dn_suffix }}"
      nifi_properties_j2:
        nifi.remote.input.host: ""
        nifi.remote.input.secure: true
        nifi.remote.input.socket.port: 10443
        nifi.web.http.host: ""
        nifi.web.http.port:
        nifi.web.https.host: ""
        nifi.web.https.port: 9443
        nifi.security.keystore: ./conf/keystore.jks
        nifi.security.keystoreType: jks
        nifi.security.keystorePasswd: "{{ _nftk_run_keystorepasswd }}"
        nifi.security.keyPasswd: "{{ _nftk_run_keypasswd }}"
        nifi.security.truststore: ./conf/truststore.jks
        nifi.security.truststoreType: jks
        nifi.security.truststorePasswd: "{{ _nftk_run_truststorepasswd }}"
        nifi.security.user.authorizer: "file-provider"
        nifi.security.user.login.identity.provider: ""
        nifi.cluster.protocol.is.secure: true
        nifi.cluster.node.address: ""
        nifi.cluster.node.protocol.port: 11443
      nifi_sync_dir_local: "/Users/Chilcano/1github-repo/binaries"

The vars.yml file is:

_nftk_domain: "intix.info"
_nftk_hostname: "nf[1-3]"
_nftk_dn_suffix: "OU=INTIX"
_nftk_client_cert_dn: "CN=chilcano, {{ _nftk_dn_suffix }}"
_nftk_run_clientpasswd: demo00a
_nftk_run_keypasswd: demo00b
_nftk_run_truststorepasswd: demo00c
_nftk_run_keystorepasswd: demo00d

The inventory file is:

[nifis]
nf1
nf2
nf3

nf1 ansible_host=192.168.77.5
nf2 ansible_host=192.168.77.6
nf3 ansible_host=192.168.77.7

[nifis:vars]
ansible_user=vagrant
ansible_ssh_private_key_file="/Users/Chilcano/.vagrant.d/insecure_private_key"

Updates

  • The Role now copies the installer or binary from the local system first; if it doesn’t exist, it tries to download it from a URL. Lastly, any downloaded binary will be saved locally for future use.
  • The inventory file needs to include ansible_ssh_private_key_file to utilize the synchronize Ansible module for larger files instead of using the fetch module.
  • The variable nifi_sync_dir_local has been added. It specifies the local directory where this Role will find the binary/installer to copy to the remote system.

License

MIT / BSD

Author Information

This Role was created in 2017 by Roger Carhuatocto, the author of HolisticSecurity.io Blog.

Informazioni sul progetto

An Ansible Role that installs and runs Apache NiFi.

Installa
ansible-galaxy install chilcano.apache-nifi
Licenza
Unknown
Download
385
Proprietario
Crypto, PKI, DevSecOps, Cloud & Cyber Security, SOA, API & Service Mesh.