您可以使用Ansible的copy模块来传送文件,使用command模块来执行chmod和rm命令。以下是使用Ansible完成以上需求的示例任务:

- name: 传送文件
  copy:
    src: /path/to/source/file
    dest: /path/to/destination/file
  become: true

- name: 执行chmod命令
  command: chmod +x /path/to/file
  become: true

- name: 执行rm命令
  command: rm /path/to/file
  become: true

在上述示例中,将/path/to/source/file传送到所有主机的/path/to/destination/file。然后,使用chmod +x /path/to/file给文件添加执行权限,并使用rm /path/to/file删除文件。

您可以将这些任务保存在一个YAML文件中,然后使用ansible-playbook命令来执行该文件。

传文件 putansible all -m ping -vvvgrep put加执行权限ansible all -m ping -vvvgrep chmod删除临时文件ansible all -m ping -vvvgrep rm使用ansible完成以上需求

原文地址: https://www.cveoy.top/t/topic/i5Si 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录