Adam Chally
Adam Chally

Reputation: 69

Ansible Copy Module Fails

I am trying to copy over the "resolve.conf" file from one machine to another and overwrite the old one. This operation works on all but 4 of the 40+ servers... I get an error it could not replace the file because it is not permitted. I have pasted the contents of the Playbook related to the failure of the operation below.

- hosts: all
  remote_user: root

...

  - name: Copy over the updated DNS configuration file
    copy: src=/etc/resolv.conf dest=/etc/resolv.conf

It gives me the following error message for all 4 servers.

fatal: [server-name]: FAILED! => {"changed": false, "checksum": "9925f1a81f849f373f860c3156d19edcd1c002f2", "failed": true, "msg": "Could not replace file: /root/.ansible/tmp/ansible-tmp-1469481567.72-275811900408782/source to /etc/resolv.conf: [Errno 1] Operation not permitted"}

I just don't understand what the problem could be since I am accessing the machines as the root user and the Playbook succeeds on the majority of the servers - many with the exact same configuration and settings. For example, it succeeds on the server "server-analytical1" but fails on the server "server-analytical2". So, does anyone have any insight into why the Playbook would fail for only a few servers even though they're similar to or the same as other servers that succeeded?

Upvotes: 2

Views: 2403

Answers (1)

nitzmahone
nitzmahone

Reputation: 13940

Is the immutable bit set on the target file? Try lsattr /etc/resolv.conf and chattr -i /etc/resolv.conf to unset if it is.

Upvotes: 4

Related Questions