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

This works up until the copy section where it reports it can't find the files "/Config-Files-Prod/NGINX Redirect/"

The Playbook, Inventory and config file are all held in a git repository and the Jenkins job deals with this via the Git plugin.

But how can I get ansible to use git as its source for the config files when it is running. "/Config-Files-Prod/" is under the root folder in the git repository that holds a directory structure with files for nginx. Do I have to pull the files to the Jenkins box before I can pas them to ansible or can i simple point ansible to directly reference Git?

error is

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
1
My workspace in Jenkins shows the files in /Config-files-Prod/NGINX REdirect - DevilWAH

1 Answers

0
votes

Sorry I fixed it, I moved the back up directory and changed the line

./Config-Files-Prod/NGINX Redirect/

to

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

Thank you.