I've written a ansible role to copy properties file of my application to a remote machine. I first check if the properties file exists locally and then copy the file to my remote machine. The command I used to run the playbook is as follows :-
ansible-playbook -i ./playbooks/hosts ./playbooks/deploy.yml --tags copy --limit remote_machine_name --ask-become-pass
I can see that the playbooks ran fine and I'm able to verify that the file has been copied to the remote machine. Now when I try to achieve the same using Gitlab CI/CD, the pipeline fails saying that the file specified doesn't exist. The ansible-playbook command I use in the CI/CD pipeline is :-
ansible-playbook -i ./playbooks/hosts ./playbooks/deploy.yml --tags copy --limit remote_machine_name --extra-vars "ansible_user=${ANSIBLE_USER} ansible_become_pass=${ANSIBLE_USER_PASSWORD} ansible_sudo_pass=${ANSIBLE_USER_PASSWORD}"
Stack trace that I get when the pipeline fails :-
"item": {
"ansible_loop_var": "item",
"changed": false,
"failed": false,
"invocation": {
"module_args": {
"checksum_algorithm": "sha1",
"follow": false,
"get_attributes": true,
"get_checksum": true,
"get_md5": false,
"get_mime": true,
"path": "../properties/application.properties"
}
},
"item": "../properties/application.properties",
"stat": {
"exists": false
}
},
"msg": "file ../properties/application.properties does not exist"
}
What could be the reason behind this? I can verify that other stages of the gitlab pipeline works fine.