Fix fail if network_interface contains '-'

If the specified network_interface contains a hyphen ansible munches the
hostvar key to replace the '-' with a '_'. We fail to do this munging so
we are unable to find the correct key.

Change-Id: Ied2d859e6cb32fa760597e1b09ee0d757eafa6f7
This commit is contained in:
Gregory Haynes 2015-10-03 22:38:20 -07:00
parent 5d9ce17212
commit 0c1fcb9abe
6 changed files with 22 additions and 13 deletions

View File

@ -3,6 +3,7 @@
ironic_url: "http://localhost:6385/"
nginx_port: 8080
network_interface: "virbr0"
ans_network_interface: "{{ network_interface | replace('-', '_') }}"
http_boot_folder: "/httpboot"
deploy_image_filename: "deployment_image.qcow2"
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"

View File

@ -24,7 +24,7 @@
ironic_url: "{{ ironic_url }}"
uuid: "{{ uuid }}"
state: present
config_drive: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{ nginx_port }}/configdrive-{{ uuid }}.iso.gz"
config_drive: "http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{ nginx_port }}/configdrive-{{ uuid }}.iso.gz"
instance_info: "{{ instance_info }}"
delegate_to: localhost
when: instance_info is defined
@ -42,9 +42,9 @@
ironic_url: "{{ ironic_url }}"
uuid: "{{ uuid }}"
state: present
config_drive: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{ nginx_port }}/configdrive-{{ uuid }}.iso.gz"
config_drive: "http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{ nginx_port }}/configdrive-{{ uuid }}.iso.gz"
instance_info:
image_source: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{ nginx_port }}/{{deploy_image_filename}}"
image_source: "http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{ nginx_port }}/{{deploy_image_filename}}"
image_checksum: "{{ test_deploy_image.stat.md5 }}"
image_disk_format: "raw"
root_gb: 10

View File

@ -14,11 +14,17 @@ transform_boot_image: false
# virtual machines for the hardware instead of real hardware.
testing: false
ci_testing: false
# Default network interface that bifrost will be attached to.
# This is used in ipa_* so it must be before
network_interface: "virbr0"
ans_network_interface: "{{ network_interface | replace('-', '_') }}"
ipa_kernel: "{{http_boot_folder}}/ipa.vmlinuz"
ipa_ramdisk: "{{http_boot_folder}}/ipa.initramfs"
ipa_kernel_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.vmlinuz"
ipa_kernel_url: "http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.vmlinuz"
ipa_kernel_upstream_url: http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe.vmlinuz
ipa_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.initramfs"
ipa_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.initramfs"
ipa_ramdisk_upstream_url: http://tarballs.openstack.org/ironic-python-agent/coreos/files/coreos_production_pxe_image-oem.cpio.gz
deploy_image_filename: "deployment_image.qcow2"
deploy_image: "{{http_boot_folder}}/{{deploy_image_filename}}"
@ -48,8 +54,6 @@ enabled_drivers: "agent_ipmitool,pxe_amt,agent_ilo,agent_ucs"
# DHCP pool for requests.
dhcp_pool_start: 192.168.1.200
dhcp_pool_end: 192.168.1.250
# Default network interface that bifrost will be attached to.
network_interface: "virbr0"
# Dnsmasq default route for clients. If not defined, dnsmasq will push to clients
# as default route the same IP of the dnsmasq server.
# Default: undefined

View File

@ -83,7 +83,7 @@
dest=/etc/ironic/ironic.conf
insertafter="[conductor]"
regexp='^(.*)api_url=(.*)$'
line="api_url=http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:6385/"
line="api_url=http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:6385/"
- name: "Configure conductor cleaning"
lineinfile:
dest=/etc/ironic/ironic.conf
@ -112,7 +112,7 @@
dest=/etc/ironic/ironic.conf
insertafter="[pxe]"
regexp='^(.*)tftp_server=(.*)$'
line="tftp_server={{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}"
line="tftp_server={{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}"
- name: "Set PXE tftp_root"
lineinfile:
dest=/etc/ironic/ironic.conf
@ -130,7 +130,7 @@
dest=/etc/ironic/ironic.conf
insertafter="[pxe]"
regexp='^(.*)http_url=(.*)$'
line="http_url=http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{nginx_port}}/"
line="http_url=http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{nginx_port}}/"
- name: "Set iPXE http_root"
lineinfile:
dest=/etc/ironic/ironic.conf

View File

@ -443,7 +443,7 @@ dhcp-boot=tag:!ipxe,/undionly.kpxe
{% if testing %}
dhcp-boot=http://192.168.122.1:{{nginx_port}}/boot.ipxe
{% else %}
dhcp-boot=http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{nginx_port}}/boot.ipxe
dhcp-boot=http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{nginx_port}}/boot.ipxe
{% endif %}
# Encapsulated options for Etherboot gPXE. All the options are

View File

@ -1,6 +1,10 @@
---
ironic_url: "http://localhost:6385/"
nginx_port: 8080
# Default network interface that bifrost will be attached to.
network_interface: "virbr0"
ipa_kernel_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.vmlinuz"
ipa_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.initramfs"
ans_network_interface: "{{ network_interface | replace('-', '_') }}"
ipa_kernel_url: "http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.vmlinuz"
ipa_ramdisk_url: "http://{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}:{{nginx_port}}/ipa.initramfs"