ERROR Ansible playbook execution failed - Ansible Jenkins

0 votes

I have a playbook and I'm trying to execute it using the Jenkins pipeline. 

pipeline script:

withEnv(["PYTHONPATH=/home/ec2-user/ansible/lib"]) {
                    colorized: true,
                    credentialsId: 'my-creds',
                    installation: 'ansible-2-2-0',
                    inventory: 'staging',
                    playbook: 'deploy.yml',
                    extras: "--extra-vars 'app_build_id=${git_commit}'"

[Pipeline] ansiblePlaybook
[planet-healthcare-pipeline] $ /home/ec2-user/ansible/bin/ansible-playbook deploy.yml -i staging -f 5 --private-key /home/ec2-user/jenkins/workspace/REDACTED.key -u ec2-user --extra-vars app_build_id=24a6431
Traceback (most recent call last):
  File "/home/ec2-user/ansible/bin/ansible-playbook", line 43, in <module>
    import ansible.constants as C
ImportError: No module named ansible.constants
FATAL: command execution failed
hudson.AbortException: Ansible playbook execution failed
    at org.jenkinsci.plugins.ansible.AnsiblePlaybookBuilder.perform(
    at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$
    at org.jenkinsci.plugins.ansible.workflow.AnsiblePlaybookStep$
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$
    at java.util.concurrent.Executors$
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] mail
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Ansible playbook execution failed
Finished: FAILURE
Apr 4, 2019 in Ansible by Asha

1 answer to this question.

0 votes

Hey @Asha, Try to run it as user jenkins

sudo su -s /bin/bash jenkins
answered Apr 4, 2019 by Aman

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer
+1 vote
3 answers
0 votes
1 answer

Not able to connect remote host via jenkins to run ansible playbook

set "host_key_checking = False" in /etc/ansible/ansible.cfg READ MORE

answered Dec 2, 2019 in Jenkins by pavan

reshown Dec 2, 2019 by Vardhan 5,703 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
0 votes
1 answer

Error when executing ansible playbook on Azure

Hey @Ganga, As the error message says, ...READ MORE

answered Jan 29, 2019 in Ansible by Kavya