Hi,
I know the solution to this topic has been posted many times and I have tried searching through google and other forums including the ansible docs but unfortunately, nothing seems to be working for me. Please provide your feedback and help me with the solution. Also please let me know if you need any further information.
I am trying to create a playbook to download and install jenkins from a war file and so installing java from the source file as a pre-requisite.
I check for the presence of Java and if not found, go on to download and install java from source and then registering the env variable JAVA_HOME and adding the java binary onto my PATH. However, the environment variable part is frustratingly not working for me.
I initially started out with using the shell module to source /etc/profile using /bin/bash, but that didnt work. Read more and found out about environment keyword. As part of my playbook, I create a user jenkins_user and then download the jenkins war file and try to run with the above defined env variables. unfortunately, it is not working. However, I am not sure I am doing this the correct way as I keep getting failures and the latest is that ‘java’ cannot be found by newly created jenkins_user.
Pasted below is all my code.
playbook.yaml
`