Jenkins invokes Packer plugin and packer uses ansible

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Jenkins invokes Packer plugin and packer uses ansible

Gaurav Rastogi
Hello folks,

I have a peculiar issue and based on my testing it seems to be a jenkins issue.

Setup: An AWS EC2 instance running Jenkins behind nginx proxy
Installed with packer and ansible

Jobs:

1. git job that pulls the anible.yml playbook from aws codecommit (It installs PH and httpd24)
2. git job that pulls the packer.json file from aws codecommit (it will pull ami image and then call ansible playbook). 
3. packer job with packer plugin that is told about the packer file and runs it 

Expected result: To create a ami delivery pipeline

Failing: packer job keeps failing with below console output:

Started by user jenkins
Building in workspace /var/lib/jenkins/workspace/packer
[packer] $ /usr/local/packer/packer build -debug /var/lib/jenkins/workspace/getrepopacker/packer.json
Debug mode enabled. Builds will not be parallelized.
 [1;32mamazon-ebs output will be in this color. [0m

1 error(s) occurred:

* Error running "ansible-playbook --version": exec: "ansible-playbook": executable file not found in $PATH
Finished: FAILURE
Build step 'Packer' marked build as failure
Finished: FAILURE

Something tells me that my ansible install attempts may have been at fault but I am currently able to run packer job directly by using the jenkins user (I had changed /etc/passwd for jenkins to /login/bash) and created a password for jenkins user. I have added the PATH to my ansible on this user.

But every time I run the packer job it fails. I suspect it is because when the job runs jenkins creates a temp script which doesn't load the environment variables and hence doesn't find the path for ansible. I have also created a .bashrc file with the path for ansible but since the jobs do not load environment variables i see failed results.

Any help is appreciated. 

Thanks
G
 

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/210676d1-dfb9-441f-a792-66c69980a9f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.