summaryrefslogtreecommitdiffstats
path: root/playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml
blob: 3117d9edcbdf695237a5a4f3fa8d80b2df7c0954 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
- name: Test if libvirt network for openshift already exists
  command: "virsh -c {{ libvirt_uri }} net-info {{ libvirt_network }}"
  register: net_info_result
  changed_when: False
  failed_when: "net_info_result.rc != 0 and 'no network with matching name' not in net_info_result.stderr"

- name: Create a temp directory for the template xml file
  command: "mktemp -d /tmp/openshift-ansible-XXXXXXX"
  register: mktemp
  when: net_info_result.rc == 1

- name: Create network xml file
  template:
    src: templates/network.xml
    dest: "{{ mktemp.stdout }}/network.xml"
  when: net_info_result.rc == 1

- name: Create libvirt network for openshift
  command: "virsh -c {{ libvirt_uri }} net-create {{ mktemp.stdout }}/network.xml"
  when: net_info_result.rc == 1

- name: Remove the temp directory
  file:
    path: "{{ mktemp.stdout }}"
    state: absent
  when: net_info_result.rc == 1