8.修改和拷贝文件到被管理主机
# 使用 fetch模块 将远端主机的文件拷贝到本机
vim secure_log_backups.yml
---
- name: Use the fetch module to retrieve secure log files
hosts: all
remote_user: root
tasks:
- name: Fetch /etc/var/log/secure log file from managed hosts
ansible.builtin.fetch:
src: /var/log/secure
dest: secure-backups
flat: no
# 运行剧本,可以看到远端文件被拉取下来了
ansible-navigator run -m stdout secure_log_backups.yml
# 使用 copy模块 将本机目录下的文件拷贝到远端主机并设置对应的权限和selinux安全上下文
vim copy_file.yml
---
- name: Using the copy module
hosts: all
remote_user: root
tasks:
- name: Copy a file to managed hosts and