zoukankan      html  css  js  c++  java
  • ansible非role格式

    示例playbook
    [root@host131 ~]# cat msg.playbook
    ---
    -
    hosts: host131,localhost
    tasks:
    - name: Playbook Sample Task
    debug:
    msg: Welcome to Ansible
    ...
    [root@host131 ~]#

    执行结果
    [root@host131 ~]# ansible-playbook msg.playbook

    PLAY [host131,localhost] ***************************************************************************************************************

    TASK [Gathering Facts] *****************************************************************************************************************
    ok: [localhost]
    ok: [host131]

    TASK [Playbook Sample Task] ************************************************************************************************************
    ok: [host131] => {
    "msg": "Welcome to Ansible"
    }
    ok: [localhost] => {
    "msg": "Welcome to Ansible"
    }

    PLAY RECAP *****************************************************************************************************************************
    host131 : ok=2 changed=0 unreachable=0 failed=0
    localhost : ok=2 changed=0 unreachable=0 failed=0

    [root@host131 ~]#

    方式5: 通过环境变量传给playbook的hosts
    示例playbook

    [root@host131 ~]# cat msg.playbook
    ---
    -
    hosts: '{{ env_host_list }}'
    tasks:
    - name: Playbook Sample Task
    debug:
    msg: Welcome to Ansible
    ...
    [root@host131 ~]#

    执行结果
    [root@host131 ~]# ansible-playbook msg.playbook -e 'env_host_list=host131,localhost'

    PLAY [host131,localhost] ***************************************************************************************************************

    TASK [Gathering Facts] *****************************************************************************************************************
    ok: [localhost]
    ok: [host131]

    TASK [Playbook Sample Task] ************************************************************************************************************
    ok: [host131] => {
    "msg": "Welcome to Ansible"
    }
    ok: [localhost] => {
    "msg": "Welcome to Ansible"
    }

    PLAY RECAP *****************************************************************************************************************************
    host131 : ok=2 changed=0 unreachable=0 failed=0
    localhost : ok=2 changed=0 unreachable=0 failed=0

    [root@host131 ~]#
    ————————————————
    版权声明:本文为CSDN博主「淼叔」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/liumiaocn/article/details/95456872

  • 相关阅读:
    Office 转 PDF & PDF 转 SWF Windows版
    Office 转 PDF & PDF 转 SWF Linux版
    MP4Box 编译 和相应命令
    CentOS VNC 安装与配置,方便进行运程桌面连接
    系统时钟&&硬件时钟
    IPtables中SNAT、DNAT和MASQUERADE的含义
    配置SNAT实现共享上网
    DNAT & SNAT
    linux应急操作
    linux-清理linux空间
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/14627515.html
Copyright © 2011-2022 走看看