运行以下 Ansible Yaml 文件后,输出显示文件已创建且内容已更改
YAML 文件
---
- hosts: all
gather_facts: yes
connection: local
tasks:
- name: Check the date on the server.
action: command touch /opt/b
- name: cat the Content
action: command cat /opt/b
运行剧本
root@my-ubuntu:/var/lib/awx/projects/test# ansible-playbook main.yml
PLAY [all] *********************************************************************
TASK [setup] *******************************************************************
ok: [ansible-ubuntu-1604-db]
TASK [Check the date on the server.] *******************************************
changed: [ansible-ubuntu-1604-db]
[WARNING]: Consider using file module with state=touch rather than running touch
TASK [cat the Content] *********************************************************
changed: [ansible-ubuntu-1604-db]
PLAY RECAP *********************************************************************
ansible-ubuntu-1604-db : ok=3 changed=2 unreachable=0 failed=0
消息显示更改=2,任务未创建任何文件
ubuntu@ansible-ubuntu-1604-db:~$ ls -l /opt/
total 0
环境
- MAC 本地桌面上的 Ansible 控制器
- 目标节点在云端