q36988 发表于 2018-7-29 09:47:31

自动化运维工具Ansible实战(七)playbook循环

- shell: echo "{{ item }}"  
with_items:
  
    - one
  
    - two
  
register: echo
  
变量echo内容如下:
  
{
  
    "changed": true,
  
    "msg": "All items completed",
  
    "results": [
  
      {
  
            "changed": true,
  
            "cmd": "echo \"one\" ",
  
            "delta": "0:00:00.003110",
  
            "end": "2013-12-19 12:00:05.187153",
  
            "invocation": {
  
                "module_args": "echo \"one\"",
  
                "module_name": "shell"
  
            },
  
            "item": "one",
  
            "rc": 0,
  
            "start": "2013-12-19 12:00:05.184043",
  
            "stderr": "",
  
            "stdout": "one"
  
      },
  
      {
  
            "changed": true,
  
            "cmd": "echo \"two\" ",
  
            "delta": "0:00:00.002920",
  
            "end": "2013-12-19 12:00:05.245502",
  
            "invocation": {
  
                "module_args": "echo \"two\"",
  
                "module_name": "shell"
  
            },
  
            "item": "two",
  
            "rc": 0,
  
            "start": "2013-12-19 12:00:05.242582",
  
            "stderr": "",
  
            "stdout": "two"
  
      }
  
    ]
  
}
页: [1]
查看完整版本: 自动化运维工具Ansible实战(七)playbook循环