Running a playbook using Ansible on Jenkins

0 votes

I am trying to run an Ansible playbook via Jenkins

    - hosts: all
  tasks:
    - name: Print message
      debug: msg="Hello number 2 from Ansible!!"
    - name: ping all hosts
      ping:
    - debug: var=ansible_all_ipv4_addresses
    - name: Update the repository cache and update package "nginx" to latest version using default release squeeze-backport
      apt:
        name: nginx
        state: latest
        update_cache: yes
    - name: Copy config files for nginx
      copy:
        src: ./Config-Files-Prod/NGINX Redirect/
        dest: /etc/nginx
        force: yes
        directory_mode: yes

But I end up with the following error:

Could not find or access './Config-Files-Prod/NGINX Redirect/'\nSearched in:\n\t<http://server.com/job/Ansible-AS/ws/Play-Books-Prod/files/./Config-Files-Prod/NGINX
Apr 4 in Ansible by Asha
134 views

1 answer to this question.

0 votes
Hey, @Asha seems like you've added a wrong path to the source. Check if you've added the correct path. Let me know.
answered Apr 4 by Akhil

Yeah! I was using the wrong path. I changed the path to 

../Config-Files-Prod/NGINX Redirect/

And it worked!! Thank you:)

Related Questions In Ansible

0 votes
1 answer
0 votes
3 answers
0 votes
1 answer

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 13, 2018 in Ansible by DareDev
• 6,810 points
122 views
0 votes
1 answer

Permission denied when running ansible playbook through jenkins

Jenkins uses it's own user to execute ...READ MORE

answered Jun 25, 2018 in Ansible by DareDev
• 6,810 points
541 views
0 votes
0 answers

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

Not able to connect remote host via ...READ MORE

Apr 2 in Jenkins by Nishant
• 160 points

recategorized Apr 2 by Nishant 529 views
+13 votes
2 answers
0 votes
1 answer

Error when executing ansible playbook on Azure

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

answered Jan 28 in Ansible by Kavya
28 views