I am a newbie to ansible and I am trying to set and install JAVA_HOME and NiFi via ansible on a node running RHEL7. I run the following playbook:
---
- hosts: web
sudo: yes
environment:
JAVA_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre
tasks:
- name: Creates directory
file: path=/home/ec2-user/nifi state=directory
- name: Download NiFi
get_url:
url: http://archive.apache.org/dist/nifi/1.5.0/nifi-1.5.0-bin.zip
dest: /home/ec2-user/nifi/nifi.zip
- name: install unzip
yum:
name: unzip
state: present
- name: Extract NiFi in the same folder
unarchive:
src: /home/ec2-user/nifi/nifi.zip
dest: /home/ec2-user/nifi/
copy: no
- name: configure the webserver in nifi.properties file
replace:
dest: /home/ec2-user/nifi/nifi-1.5.0/conf/nifi.properties
regexp: 'nifi.web.http.host='
replace: 'nifi.web.http.host=ec2-13-211-204-235.ap-southeast-2.compute.amazonaws.com'
- name: install java
yum:
name: java-1.8.0-openjdk
state: present
- name: start NiFi
shell: /home/ec2-user/nifi/nifi-1.5.0/bin/nifi.sh start
register: shell_out
- debug:
var: shell_out
Basically the code above includes these tasks: setting JAVA_HOME, create a directory for nifi, download nifi, extract nifi, install java and run nifi. The output of the shell below shows that nifi is installed and JAVA_HOME is set and everything seems ok:
TASK [debug] *******************************************************************************************************
ok: [13.211.204.235] => {
"shell_out": {
"changed": true,
"cmd": "/home/ec2-user/nifi/nifi-1.5.0/bin/nifi.sh start",
"delta": "0:00:04.023438",
"end": "2018-04-11 05:46:13.735321",
"failed": false,
"rc": 0,
"start": "2018-04-11 05:46:09.711883",
"stderr": "",
"stderr_lines": [],
"stdout": "\nJava home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre\nNiFi home: /home/ec2-user/nifi/nifi-1.5.0\n\nBootstrap Config File: /home/ec2-user/nifi/nifi-1.5.0/conf/bootstrap.conf",
"stdout_lines": [
"",
"Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre",
"NiFi home: /home/ec2-user/nifi/nifi-1.5.0",
"",
"Bootstrap Config File: /home/ec2-user/nifi/nifi-1.5.0/conf/bootstrap.conf"
]
}
}
When I check EC2 instance, all the changes have been applied e.g., extraction of downloaded file in the folder and nifi.properties configuration. However, when I check the nifi status there is no nifi running on the instance. In addition, the value of JAVA_HOME is null when I run echo $JAVA_HOME
in bash.
To add more info: I have checked the log file on the instance and it seems nifi starts and quickly stops after:
[ec2-user@ip-172-31-8-240 logs]$ cat nifi-app.log
2018-04-11 07:06:09,698 INFO [main] org.apache.nifi.NiFi Launching NiFi...
2018-04-11 07:06:10,175 INFO [main] o.a.nifi.properties.NiFiPropertiesLoader Determined default nifi.properties path to be '/home/ec2-user/nifi/nifi-1.5.0/./conf/nifi.properties'
2018-04-11 07:06:10,178 INFO [main] o.a.nifi.properties.NiFiPropertiesLoader Loaded 144 properties from /home/ec2-user/nifi/nifi-1.5.0/./conf/nifi.properties
2018-04-11 07:06:10,200 INFO [main] org.apache.nifi.NiFi Loaded 144 properties
2018-04-11 07:06:10,209 INFO [main] org.apache.nifi.BootstrapListener Started Bootstrap Listener, Listening for incoming requests on port 33327
2018-04-11 07:06:10,233 INFO [main] org.apache.nifi.BootstrapListener Successfully initiated communication with Bootstrap
2018-04-11 07:06:10,257 INFO [main] org.apache.nifi.nar.NarUnpacker Expanding 89 NAR files with all processors...
2018-04-11 07:06:12,710 INFO [Thread-1] org.apache.nifi.NiFi Initiating shutdown of Jetty web server...
2018-04-11 07:06:12,710 INFO [Thread-1] org.apache.nifi.NiFi Jetty web server shutdown completed (nicely or otherwise).