From 6309041cb3173821a9261874dd23e6e8151f2bfa Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Fri, 16 Oct 2015 12:13:53 -0400 Subject: [PATCH] Correct conditionals and dnsmasq reload for deploy The conditionals in the deployment role were incorrect if the inventory data source was set to ironic where the interpretted reply from the API could include an empty instance_info dictonary. Changed the conditionals to handle the condition where the dictonary may be empty. Additionally changed the dnsmasq handling to directly HUP the dnsmasq process as the service init file, if present, may not support reloaded state as Ansible passes it directly through. Change-Id: Id84b8869ef5fc9deb1eee8cc304ee00713a3016a --- .../bifrost-deploy-nodes-dynamic/tasks/main.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml index dbbc83ab1..8881597e1 100644 --- a/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml +++ b/playbooks/roles/bifrost-deploy-nodes-dynamic/tasks/main.yml @@ -18,12 +18,14 @@ # things that are not directly accessible or reasonable # to be inspected. - name: "Setup DHCP for nodes." - template: src=templates/dhcp-host.j2 dest=/etc/dnsmasq.d/bifrost.dhcp-hosts.d/{{ hostname }} + template: src=dhcp-host.j2 dest=/etc/dnsmasq.d/bifrost.dhcp-hosts.d/{{ hostname }} delegate_to: localhost - when: instance_info is defined and inventory_dhcp | bool + when: inventory_dhcp | bool and instance_info is defined and instance_info | to_json != '{}' - name: "Sending dnsmasq HUP" - service: name=dnsmasq state=reloaded - when: instance_info is not defined and inventory_dhcp | bool + # Note(TheJulia): We need to actually to send a hup signal directly as + # Ansible's reloaded state does not pass through to the init script. + command: killall -HUP dnsmasq + when: inventory_dhcp | bool and instance_info is not defined or ( instance_info is defined and instance_info | to_json == '{}' ) - name: "Deploy to hardware - Using custom instance_info." os_ironic_node: auth_type: None @@ -34,11 +36,11 @@ 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 + when: instance_info is defined and instance_info | to_json != '{}' - name: "Collect the checksum of the deployment image." local_action: stat path={{deploy_image}} register: test_deploy_image - when: instance_info is not defined + when: instance_info is not defined or ( instance_info is defined and instance_info | to_json == '{}' ) - name: "Error if deploy_image is not present, and instance_info is not defined" fail: msg="The user-defined deploy_image, which is the image to be written to the remote node(s) upon deployment, was not found. Cannot proceed." when: instance_info is not defined and test_deploy_image.stat.exists | bool == false @@ -56,4 +58,4 @@ image_disk_format: "raw" root_gb: 10 delegate_to: localhost - when: instance_info is not defined + when: instance_info is not defined or ( instance_info is defined and instance_info | to_json == '{}' )