4

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Mr.DevEng
  • 2,651
  • 14
  • 57
  • 115
  • 1
    As the error message states: `OSError: [Errno 12] Cannot allocate memory`. Maybe you run into this [issue](https://stackoverflow.com/questions/20111242/how-to-avoid-errno-12-cannot-allocate-memory-errors-caused-by-using-subprocess) – JGK Nov 01 '18 at 16:20
  • Thank you for your response @JGK. I was trying for the same issue. I updated the error what I am getting now. Now I am getting the password required error. Can you please look on my updated issue please ? – Mr.DevEng Nov 02 '18 at 07:06
  • Have you tried it without `sudo` checkbox checked? Looks like that you do not have sudo rights on the system for the user, jenkins is running. – JGK Nov 02 '18 at 07:42
  • Yes. Previous I tried that only. But I was getting "Permission denied" error. After that I checked the sudo checkbox. I updated that also in my edited question. You can now see the edited one when I am not checking the sudo check box. – Mr.DevEng Nov 02 '18 at 08:30
  • Seems to me, that you can't ssh to the server with the user jenkins is running. – JGK Nov 02 '18 at 08:43
  • OK.I am using only one EC2 machine for ansible , jenkins and docker deployment. If I have SSH issue , how I can resolve that ? I am only started in CI/CD section. Can you give idea where I can add the configuration for SSH ? In my EC2 inbound rules ? Or in jenkins configuration? – Mr.DevEng Nov 02 '18 at 08:51
  • You said, that running the playbook on the command line is working, right? Running it under jenkins produces the above error, right? Which user are you using on the command line? Under which user is jenkins running? You ave to adapt the jenkins env to the user env which you are using on the command line. – JGK Nov 02 '18 at 09:37
  • For shell command , I am used to login into machine using root . And when I am login into the Jenkins Dashboard , using admin user. And I did n;t understood adpat the jenkins env to the root user env . What actually means? what I can do here ? – Mr.DevEng Nov 02 '18 at 09:43
  • Under which user account is the jenkins server running (`ps -ef | grep jenkins`)? – JGK Nov 02 '18 at 11:02
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/183002/discussion-between-jacob-and-jgk). – Mr.DevEng Nov 02 '18 at 11:33

1 Answers1

1

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.

bahrep
  • 29,961
  • 12
  • 103
  • 150