Centos7

Ansible 中複製模組不支持的參數

  • August 24, 2019

我正在嘗試將幾個文件從本地伺服器複製到遠端伺服器並收到此錯誤:

   "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"
}

這是該劇本的一部分,所有項目都出現錯誤,我只是在上面粘貼了一個實例:

- 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

我嘗試將模式從 0644 更改為 0777、2775 等。我還嘗試將狀態更改為 touch 我也嘗試將模組從更改為copyfile但效果不佳

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

我找到了幾張但對我不起作用的票:

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

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

該消息說您使用了不受支持的參數,並列出了有效的參數。

當我們查看您的劇本時,我們可以看到您實際上確實使用了無效參數:

     state: present

您需要刪除它。

引用自:https://serverfault.com/questions/980577