于志腾的技术专栏 PHP and Python and Vue Coder

playbook之yml配置

2019-08-05
YztSon

阅读:


执行命令

  1. 列出可以执行主机的列表 –list-hosts
ansible-playbook -i ./hosts --list-hosts ./f1.yml
  1. 执行
ansible-playbook -i ./hosts  ./f1.yml

执行展示

macbookpro@bogon  /etc/ansible  ansible-playbook -i ./hosts --list-hosts ./f1.yml
 [WARNING]: Ansible is being run in a world writable directory (/private/etc/ansible), ignoring it as an ansible.cfg source. For more information see
https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir


playbook: ./f1.yml

  play #1 (192.168.0.107): 192.168.0.107	TAGS: []
    pattern: ['192.168.0.107']
    hosts (1):
      192.168.0.107
      
      
      
 macbookpro@bogon  /etc/ansible  ansible-playbook -i ./hosts  ./f1.yml
 [WARNING]: Ansible is being run in a world writable directory (/private/etc/ansible), ignoring it as an ansible.cfg source. For more information see
https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir


PLAY [192.168.0.107] ****************************************************************************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************************************************************************
ok: [192.168.0.107]

TASK [touch file] *******************************************************************************************************************************************************************
 [WARNING]: Consider using the file module with state=touch rather than running 'touch'.  If you need to use command because file is insufficient you can add 'warn: false' to this
command task or set 'command_warnings=False' in ansible.cfg to get rid of this message.

changed: [192.168.0.107]

PLAY RECAP **************************************************************************************************************************************************************************
192.168.0.107              : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


playbook执行结果返回值

  1. 红色: 表示有task执行失败或者提醒信息
  2. 黄色: 表示执行了且改变了远程主机的状态
  3. 绿色: 表示执行成功

Similar Posts

上一篇 playbook的组成

Comments