My Application
I am trying to create a Jenkins job for implementing my CI/CD pipeline. I am using SVN repository for my version control. When I am commiting to this repository , the job configuring in the Jenkins need to trigger and need to call one Ansible Playbook YML file. I am configuring every stages of my pipeline using Ansible playbook.
My Current Approach
I created one svn repository and configured post-commit hook in hooks directory. And I created a Ansible playbook. I am building all my pipeline stage using this Ansible playbook.
When I am running Ansible playbook manually , it is successfully working. But when I creating one jenkins job and calling this playbook using job, the Ansible section showing "Red Crossmark".
Steps I did on Jenkins
- Created new jenkins free style project
- Edited the description for project
- Choosed "Subversion" in Source Code management and added the SVN repo URL and credentials
- Checked "Poll SCM" in Build Triggers" section
- Choosed "Invoke Ansible Playbook " on Build section and added the playbook Url.
The following image shows the invoke ansible section ,
Update
NB: With sudo checkbox checked state
Error
When I am trying to apply , it not showing anyhting. If I save and again taking from dashboard , it showing "Failed".Like the following screenshot,
Updated Console Output Error
TASK [Gathering Facts] *********************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
to retry, use: --limit @/home/spacestudy/pipelinesite.retry
PLAY RECAP *********************************************************************
localhost : ok=0 changed=0 unreachable=0 failed=1
Updated Attempt By Unchecking sudo checkbox
TASK [pipelinerole : login into dockerhub] *************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Error connecting: Error while fetching server API version: ('Connection aborted.', error(13, 'Permission denied'))"}
to retry, use: --limit @/home/spacestudy/pipelinesite.retry
Direct test Approach by Shell Command on EC2
NB:
When I am running directly the "$ansible-playbook " shell command command on my EC2 the same error getting. But When I am running shell command "$sudo ansible-playbook" , then error not getting. Because of that , Here also I checked the "sudo" checkbox. But I am getting quite different.
How can I trouble-shoot the failing of the job and why I am not able to apply?