Unsupported parameters for the copy module in Ansible

Anshul Choudhary asked:

I am trying to copy couple of files from my local to remote server and getting this error:

    "ansible_loop_var": "item",
    "changed": false,
    "checksum": "7fc8ff2de203d603caf90e2b50a557cf176e5b3d",
    "diff": [],
    "invocation": {
        "module_args": {
            "_original_basename": "snmp_exporter/snmp.yml",
            "checksum": "7fc8ff2de203d603caf90e2b50a557cf176e5b3d",
            "dest": "/home/mesadmin/check1/snmp_exporter/",
            "follow": false,
            "force": true,
            "mode": "0644",
            "src": "/home/mesadmin/.ansible/tmp/ansible-tmp-1566620501.8182452-257658154385730/source",
            "state": "present"
        }
    },
    "item": "snmp_exporter",
    "msg": "Unsupported parameters for (copy) module: state Supported parameters 
include: _original_basename, attributes, backup, checksum, content, delimiter, dest,
directory_mode, follow, force, group, local_follow, mode, owner, regexp, 
remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate"
}

This is part of that playbook and I am getting error for all the items,
I just pasted one instance above:

 - name: Status Check for Configuration Files, Exporters and RPMs
     copy:
      src: /Users/file_path/{{item}}
      dest: /home/dest_path/check1/{{item}}
      state: present
      force: yes
      mode: "0644"
     with_items:
      - prometheus
      - grafana
      - alertmanager
      - start.sh
      - snmp_exporter

I have tried changing the mode from 0644 to 0777, 2775 etc.
I also tried changing the state to touch
I also tried changing the module from copy to file but it didn’t work as well

All these files are present at my local machine and there is a check1 directory at the remote server where i am trying to copy these files

Couple of tickets I found but didn’t work for me:

https://github.com/ansible/ansible/issues/23521

https://github.com/ansible/ansible/issues/48645

My answer:


The message says that you used an unsupported parameter, and listed the valid ones.

When we look at your playbook, we can see you actually did use an invalid parameter:

      state: present

You need to remove this.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.