I'm trying to move an Ansible Playbook that we used to run locally over to Ansible Tower but am running into an issue.
We have configuration files that we copy over to remote servers using the following task:
- name: Copy Config File
copy:
src: "files/propertyOverride.config"
dest: /opt/project/propertyOverride.config
owner: myuser
group: myuser
mode: '755'
This works fine when running locally as Ansible is able to find the file in the current directory.
However, when I move this over to Ansible Tower and try to run it, it doesn't look like the job is pulling that file from the git repository where the playbook is housed. I'm using git as the SCM for the project.
Is there a way to reference a file from within the git repository that is housing this Ansible Project?
Answering my own question here.
Looks like Ansible will automatically pull files from git but for some reason it wasn't working with an absolute path. When I changed it to this:
- name: Copy Config File
copy:
src: "../files/propertyOverride.config"
dest: /opt/project/propertyOverride.config
owner: myuser
group: myuser
mode: '755'
It worked as expected.