Bo's Oracle Station

查看: 841|回复: 0

ANSIBLE8

[复制链接]

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2020-8-10 20:58:23 | 显示全部楼层 |阅读模式
循环项的分量:
  1. ---
  2. - name: Users Exist and Are in the Correct Groups
  3.   hosts: srvgroup
  4.   tasks:
  5.   - name: User and Group
  6.     user:
  7.       name: "{{ item.name }}"
  8.       state: present
  9.       groups: "{{ item.group }}"
  10.     loop:
  11.       - name: alex
  12.         group: wheel
  13.       - name: natasha
  14.         group: root


复制代码

其他方式的循环:


  1. ---
  2. - name: Copy File
  3.   hosts: server1.example.com
  4.   tasks:
  5.   - name: Test Copy
  6.     copy:
  7.       src: "{{ item }}"
  8.       dest: /tmp/
  9.     with_lines:
  10.       - ls ./v5.d/*

  11.   - name: Watch It
  12.     shell:
  13.       cat "{{ item }}"
  14.     loop:
  15.       - /tmp/again.html
  16.       - /tmp/again2.html
  17.     register: v_result

  18.   - name: Result
  19.     debug:
  20.       var: v_result
复制代码
v5.d.zip (501 Bytes, 下载次数: 21)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-9 18:23 , Processed in 0.039701 second(s), 27 queries .

快速回复 返回顶部 返回列表