--- # play 1 - local # check config info from inventory # play 2 # gather status # play 3 # bootstrap # play 4 # join - name: Tests hosts: swarm connection: local gather_facts: no vars: swarm_list: {} tasks: - debug: var=hostvars - name: Gather Swarm info set_fact: swarm_list: "{{swarm_list + hostvars[hostname]['swarm_name']}}" - debug: var=swarm_list # # show all the hosts in the inventory # - debug: # msg: "{{ item }}" # loop: "{{ groups['all'] }}" # - name: printsomthieng # debug: # msg: "{{ item }}" # with_items: "{{ play_hosts }}" # #run_once: true # debug: # msg: # # - "{{ item }}" # - "{{hostvars[item]['swarm_master']}}" # #loop: "{{ hosts.items() | list }}" # - name: Create swarm___ groups # add_host: # hostname: "{{ item }}" # groups: "swarm_{{item}}manager_operational" # with_items: "{{ play_hosts }}" # run_once: true # - name: Display # command: echo "swarm_{{item}}manager_operational"