Ansible-Pull Copy Error

I was following a tutorial from a year ago so perhaps something in Ansible has changed. My issue is I get this error:

TASK [copy sudoers_ansible] ****************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “checksum”: “9c9e5aae4aa1c02a4934d7172d2c4cd6c057d15d”, “msg”: “Unsupported parameters for (ansible.legacy.copy) module: root Supported parameters include:
_original_basename, attributes, backup, checksum, content, dest, directory_mode, follow, force, group, local_follow, mode, owner, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate”}

  • name: copy sudoers_ansible
    copy:
    src: files/sudoers_ansible
    dest: /etc/sudoers.d/ansible
    owner: root
    group: root

mode: 0440

I’ve added ansible as a system sudoer. All of the parameters I’m using; src, dest, owner, group and mode seem to be listed as supported in the error message.

Are you sure this is the task that is being run?
Try adding an extra bogus parameter, that should then be listed in the error message

I added a bogus parameter to my users.yml file as follows;

  • name: copy sudoers_ansible
    copy:
    bogus: parameter
    src: files/sudoers_ansible
    dest: /etc/sudoers.d/ansible
    owner: root
    root: root
    mode: 0440

Now the error message reads:

TASK [copy sudoers_ansible] ****************************************************
fatal: [localhost]: FAILED! => {“changed”: false, “checksum”: “9c9e5aae4aa1c02a4934d7172d2c4cd6c057d15d”, “msg”: “Unsupported parameters for (ansible.legacy.copy) module: bogus, root Supported parameters include: _original_basename, attributes, backup, checksum, content, dest, directory_mode, follow, force, group, local_follow, mode, owner, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate”}

PLAY RECAP *********************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

I also verified that the destination file “/etc/sudoers.d/ansible” does not exist. The source file “~/git projects/ansible_pull/tasks/files/sudoers_ansible” does exist.

Paul

I added a bogus parameter to my users.yml file as follows;

  • name: copy sudoers_ansible
    copy:
    bogus: parameter
    src: files/sudoers_ansible
    dest: /etc/sudoers.d/ansible
    owner: root
    root: root

There is your issue.
You didn’t post this in the first place?

OK, I’m lost. What is my issue? The formatting of your reply is a bit funky. But if you are talking about “mode: 0440”, that was in the initial post. Is there something wrong with that, and if so, what?

Hi Paul,

he was talking about the line **above** what he wrote, which is 'root:
root'. That line was **not** included in your first post, and that's
the line that's wrong. It must be 'user: root' (as it was in your first
post).

> root: root

Cheers,
Felix

I must have been reviewing the wrong file, not the one that was being executed, because it said group: root. But the actual users.yml did have root: root and now it works as expected.

Sorry, for MY confusion.