summaryrefslogtreecommitdiffstats
path: root/playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml
blob: 1cd83f7bea0c53e9fd29529a2ee207ebf699a44d (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 'error: Network not found:' not in net_info_result.stderr"

- name: Create a temp directory for the template xml file
  command: "/usr/bin/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