美文网首页
playbook循环

playbook循环

作者: EmptyBottl_520d | 来源:发表于2017-10-21 11:46 被阅读0次
    • with_items
    • with_nested
    • with_dict
    • with_fileglob
    • with_together
    • with_sequence
    ---
    - hosts: all
    
      tasks:
    
        # create groups
        - group: name=evens state=present
        - group: name=odds state=present
    
        # create some test users
        - user: name={{ item }} state=present groups=evens
          with_sequence: start=0 end=32 format=testuser%02x
    
        # create a series of directories with even numbers for some reason
        - file: dest=/var/stuff/{{ item }} state=directory
          with_sequence: start=4 end=16 stride=2
    
        # a simpler way to use the sequence plugin
        # create 4 groups
        - group: name=group{{ item }} state=present
          with_sequence: count=4
    
    • with_random_choice
    - debug: msg={{ item }}
      with_random_choice:
         - "go through the door"
         - "drink from the goblet"
         - "press the red button"
         - "do nothing"
    
    • until
    - action: shell /usr/bin/foo
      register: result
      until: result.stdout.find("all systems go") != -1
      retries: 5
      delay: 10
    
    • with_indexed_items
    - name: indexed loop demo
      debug: msg="at array position {{ item.0 }} there is a value {{ item.1 }}"
      with_indexed_items: "{{some_list}}"
    

    相关文章

      网友评论

          本文标题:playbook循环

          本文链接:https://www.haomeiwen.com/subject/llliuxtx.html