vino/vino-builder/assets/playbooks/roles/libvirt/tasks/create-network.yaml

36 lines
1.2 KiB
YAML

# Facts will be available as 'ansible_libvirt_networks'
- name: initially gather facts on existing virsh networks
virt_net:
command: facts
name: "" # this attribute is not needed but required
uri: "{{ libvirt_uri }}"
ignore_errors: true
- name: Print value of ansible networks
debug:
msg: "Value of ansible_libvirt_networks is {{ ansible_libvirt_networks }}"
# TODO(alanmeadows): deal with updates as once its defined we will
# never re-define it
- name: add networks defined if they do not already exist
virt_net:
state: present
# looks like setting name here is a redundant, the name is anyways taken from the template xml file, but should set it to make virt_pool module happy.
name: "{{ network.name }}"
xml: "{{ libvirtNetworks[network.libvirtTemplate].libvirtTemplate }}"
uri: "{{ libvirt_uri }}"
when: "network.name not in ansible_libvirt_networks"
- name: activate the network
virt_net:
state: active
name: "{{ network.name }}"
uri: "{{ libvirt_uri }}"
# these are idempotent so require no conditional checks
- name: autostart the network
virt_net:
autostart: yes
name: "{{ network.name }}"
uri: "{{ libvirt_uri }}"