--- - name: Prepare swarm manager docker_swarm: state: present advertise_addr: "{{ interface }}" when: inventory_hostname in groups['manager'] - name: Get the Manager join-token shell: docker swarm join-token --quiet worker register: worker_token when: inventory_hostname in groups['manager'] - name: Prepare swarm workers docker_swarm: state: join advertise_addr: "{{ interface }}" join_token: "{{ hostvars[groups['manager'][0]]['worker_token']['stdout'] }}" #remote_addrs: "{{ hostvars[groups['manager'][0]]['ansible_lxcbr0_ipv4.address'] }}" remote_addrs: "10.0.3.1" when: inventory_hostname in groups['workers'] - name: Prepare docker volumes file: path: /var/container_data/mysql state: directory mode: '0755' when: inventory_hostname in groups['workers'] - name: Add docker labels for galera master and secondary nodes shell: | docker node update --label-add node1=true worker1 docker node update --label-add node2=true worker2 when: inventory_hostname in groups['workers'] #- name: Add docker labels for galera secondary nodes # docker_node: # labels: # hostname: 'worker2' # node2: true # when: inventory_hostname in groups['workers']