Permission denied Message in Jenkins Free style Job for calling ansible-playbook

Viewed 1109

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

  1. Created new jenkins free style project
  2. Edited the description for project
  3. Choosed "Subversion" in Source Code management and added the SVN repo URL and credentials
  4. Checked "Poll SCM" in Build Triggers" section
  5. 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

enter image description here

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,

enter image description here

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?

1 Answers

Maybe the problem is with permissions to the SVN repository? Does it require authentication?

The errors are Connection aborted.', error(13, 'Permission denied and sudo: a password is required. According to the screenshot, you do not specify any user credentials. When your build machine access the SVN server and repository, it seems that it has to provide a username and password. If you now specify credentials and still see errors, make sure that they are correct and that the user account has Read permissions to the repository.

Related