summaryrefslogtreecommitdiffstats
path: root/playbooks
diff options
context:
space:
mode:
authorLénaïc Huard <lhuard@amadeus.com>2015-05-20 13:26:04 +0200
committerLénaïc Huard <lhuard@amadeus.com>2015-05-22 08:42:01 +0200
commit4e8f6d1923782e7aef863441f7c1434ca1029164 (patch)
tree9edd8d1637b5e95dea5c7d39e38b092fe7a6cc08 /playbooks
parent09717b94a0b76d03db38baee793b141e1a651cdd (diff)
downloadopenshift-4e8f6d1923782e7aef863441f7c1434ca1029164.tar.gz
openshift-4e8f6d1923782e7aef863441f7c1434ca1029164.tar.bz2
openshift-4e8f6d1923782e7aef863441f7c1434ca1029164.tar.xz
openshift-4e8f6d1923782e7aef863441f7c1434ca1029164.zip
[libvirt cluster] Use net-dhcp-leases to find VMs’ IPs
Query libvirt’s DHCP leases rather than inspecting the host’s ARP cache to find the VMs’ IPs.
Diffstat (limited to 'playbooks')
-rw-r--r--playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml12
1 files changed, 3 insertions, 9 deletions
diff --git a/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml b/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
index 359d0b2f3..8bf1e84ee 100644
--- a/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
+++ b/playbooks/libvirt/openshift-cluster/tasks/launch_instances.yml
@@ -58,23 +58,17 @@
uri: '{{ libvirt_uri }}'
with_items: instances
-- name: Collect MAC addresses of the VMs
- shell: 'virsh -c {{ libvirt_uri }} dumpxml {{ item }} | xmllint --xpath "string(//domain/devices/interface/mac/@address)" -'
- register: scratch_mac
- with_items: instances
-
- name: Wait for the VMs to get an IP
- command: "egrep -c '{{ scratch_mac.results | oo_collect('stdout') | join('|') }}' /proc/net/arp"
- ignore_errors: yes
+ shell: 'virsh net-dhcp-leases openshift-ansible | egrep -c ''{{ instances | join("|") }}'''
register: nb_allocated_ips
until: nb_allocated_ips.stdout == '{{ instances | length }}'
retries: 30
delay: 1
- name: Collect IP addresses of the VMs
- shell: "awk '/{{ item.stdout }}/ {print $1}' /proc/net/arp"
+ shell: 'virsh net-dhcp-leases openshift-ansible | awk ''$6 == "{{ item }}" {gsub(/\/.*/, "", $5); print $5}'''
register: scratch_ip
- with_items: scratch_mac.results
+ with_items: instances
- set_fact:
ips: "{{ scratch_ip.results | oo_collect('stdout') }}"