Jenkins invokes Packer plugin and packer uses ansible

68 views
Skip to first unread message

Gaurav Rastogi

unread,
Sep 29, 2017, 8:58:45 AM9/29/17
to Jenkins Users
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
 
Reply all
Reply to author
Forward
0 new messages