summaryrefslogtreecommitdiffstats
path: root/playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml
diff options
context:
space:
mode:
authorLénaïc Huard <lhuard@amadeus.com>2016-08-22 17:53:20 +0200
committerLénaïc Huard <lhuard@amadeus.com>2016-08-22 22:20:35 +0200
commitd3faaccc614c694b539e6fb8c02327da4f9b296b (patch)
tree72a2ed8bbbf7308ce2894b8a3d65cf63bb3330ad /playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml
parent4a48123bf6889279cbbd6f6aeb8317fd0cf1b827 (diff)
downloadopenshift-d3faaccc614c694b539e6fb8c02327da4f9b296b.tar.gz
openshift-d3faaccc614c694b539e6fb8c02327da4f9b296b.tar.bz2
openshift-d3faaccc614c694b539e6fb8c02327da4f9b296b.tar.xz
openshift-d3faaccc614c694b539e6fb8c02327da4f9b296b.zip
Replace some virsh commands by native virt_XXX ansible module
Diffstat (limited to 'playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml')
-rw-r--r--playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml36
1 files changed, 10 insertions, 26 deletions
diff --git a/playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml b/playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml
index 3117d9edc..b42ca83af 100644
--- a/playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml
+++ b/playbooks/libvirt/openshift-cluster/tasks/configure_libvirt_network.yml
@@ -1,27 +1,11 @@
---
-- 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
+- name: Create the libvirt network for OpenShift
+ virt_net:
+ name: '{{ libvirt_network }}'
+ state: '{{ item }}'
+ autostart: 'yes'
+ xml: "{{ lookup('template', 'network.xml') }}"
+ uri: '{{ libvirt_uri }}'
+ with_items:
+ - present
+ - active