Ansible error “ Could not find or access on Ansible Controller”

I am trying to write an ansible playbook to send certificates to my client machines from my local machine. The error message I get is:

msg": "Could not find or access '/etc/icinga2/pki/clienthostname.crt' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"

In the error output I also see this line:

AnsibleFileNotFound(file_name=source, paths=[to_text(p) for p in search]) ansible.errors.AnsibleFileNotFound: Could not find or access '/etc/icinga2/pki/clienthostname.crt' on the Ansible Controller..\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"

I have added both the following to escalate my privileges but nothing has changed. I have also tried adding remote_src to my playbook like the error message suggested and although my playbook does compete without any errors the files are not actually copied over

become: yes | become_user: root

Here is my playbook

name: Send client certificates
hosts: all
become: yes
become_user: root
vars: masternode: localhost clientnode: "{{ inventory_hostname }}"
tasks: -name: Copy files to remote host connection: local become: yes become_user: root copy: src: /etc/icinga2/pki/{{ clientnode }}.crt dest: /etc/icinga2/pki

I have confirmed that I am spelling the directory correctly and the file does exist. As a normal user I cannot access this directory as I get the Permission Denied error, so that is why I have added the become: yes and become_true to my playbook to elevate privileges but I am still getting an error.

0

1 Answer

Can you give only below and try

src: {{ clientnode }}.crt

What I mean, the files which you want to be copied, if present at same location, don't give the full path.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like