diff --git a/playbooks/deploy-dynamic.yaml b/playbooks/deploy-dynamic.yaml index aa027b408..d16b46bc1 100644 --- a/playbooks/deploy-dynamic.yaml +++ b/playbooks/deploy-dynamic.yaml @@ -1,4 +1,9 @@ --- +- hosts: localhost + name: "Gather facts on localhost" + become: no + gather_facts: yes + - hosts: baremetal name: "Create configuration drive files and deploy machines from inventory" become: no diff --git a/playbooks/enroll-dynamic.yaml b/playbooks/enroll-dynamic.yaml index 9bad99e62..a970695b1 100644 --- a/playbooks/enroll-dynamic.yaml +++ b/playbooks/enroll-dynamic.yaml @@ -1,4 +1,9 @@ --- +- hosts: localhost + name: "Gather facts on localhost" + become: no + gather_facts: yes + - hosts: baremetal name: "Enroll hardware from inventory into Ironic" become: no diff --git a/playbooks/roles/bifrost-cloud-config/defaults/main.yml b/playbooks/roles/bifrost-cloud-config/defaults/main.yml index 35a0ede0a..660b4abcf 100644 --- a/playbooks/roles/bifrost-cloud-config/defaults/main.yml +++ b/playbooks/roles/bifrost-cloud-config/defaults/main.yml @@ -3,7 +3,10 @@ noauth_mode: true network_interface: "virbr0" ans_network_interface: "{{ network_interface | replace('-', '_') }}" -internal_ip: "{{ hostvars[inventory_hostname]['ansible_' + ans_network_interface]['ipv4']['address'] }}" +# NOTE(dtantsur): dynamic playbooks are run on bare metal hosts, not on +# localhost, and the interface fact may not be available for them. +ans_interface_host: "{{ groups['target'][0] if 'target' in groups else '127.0.0.1' }}" +internal_ip: "{{ hostvars[ans_interface_host]['ansible_' + ans_network_interface]['ipv4']['address'] }}" enable_tls: false api_protocol: "{{ 'https' if enable_tls | bool else 'http' }}"