--- # USAGE: # sudo ansible-playbook qemu_cloud_start.yml # you can use --limit regexp to start just two clouds, for example: # sudo ansible-playbook qemu_cloud_start.yml -l *cloud[AB]* - name: create bridges for qemu nodes hosts: all connection: local gather_facts: no serial: 1 tasks: - name: create bridges linux_bridge: state: present bridge: "{{ item }}" loop: - "{{ eth0 }}" - "{{ eth2 | default() }}" when: item != "" - name: start qemu nodes hosts: all connection: local gather_facts: no vars: node_id: "{{ '%02d' | format(groups['all'].index(inventory_hostname)) }}" lm_ifname: lm_{{ cloud }}_{{ inventory_hostname_short }} rootfs_url: http://repo.libremesh.org/tmp/openwrt-18.06-x86-64-generic-rootfs.tar.gz ramfs_url: http://repo.libremesh.org/tmp/openwrt-18.06-x86-64-ramfs.bzImage rootfs: files/generic-rootfs.tar.gz ramfs: files/ramfs.bzImage tasks: - name: download rootfs if not found locally tags: download run_once: yes get_url: url: "{{ rootfs_url }}" dest: "{{ rootfs }}" - name: download ramfs if not found locally tags: download run_once: yes get_url: url: "{{ ramfs_url }}" dest: "{{ ramfs }}" - name: create taps linux_tuntap: state: present name: "{{ item }}" mode: tap loop: - "{{ lm_ifname }}_0" - "{{ lm_ifname }}_2" - name: add eth0 taps to bridges linux_bridge_port: state: present bridge: "{{ eth0 }}" port: "{{ lm_ifname }}_0" - name: add eth2 taps to bridges linux_bridge_port: state: present bridge: "{{ eth2 | default() }}" port: "{{ lm_ifname }}_2" when: eth2 | default() != "" - name: deploy template template: dest: "/tmp/lime_node_{{ node_id }}" src: lime-node - name: run qemu shell: (../qemu_dev_start --node-id {{ node_id }} --eth0 {{ lm_ifname }}_0 --eth2 {{ lm_ifname }}_2 {{ rootfs }} {{ ramfs }} &) - name: set_fact set_fact: linklocal: "fe80::5000:ff:feab:c0{{ node_id }}%lm_cloud{{cloud}}" - name: useful info for doing clusterssh hosts: all connection: local gather_facts: no tasks: - set_fact: linklocals: "{{ linklocals | default([]) | union([ hostvars[item].linklocal | default() ]) }}" loop: "{{ groups['all'] }}" run_once: yes - name: info run_once: yes pause: seconds: 5 prompt: | =================================== now to manage the cloud you can do: clusterssh {{ linklocals | join(' ') }} ===================================