122 lines
4.5 KiB
YAML
122 lines
4.5 KiB
YAML
---
|
|
# Use bifrost to provision the overcloud nodes with a base OS.
|
|
|
|
- name: Ensure the Bifrost controller inventory is provisioned
|
|
hosts: seed
|
|
vars:
|
|
# Allow the set of hosts to be limited by the --limit argument to kayobe or
|
|
# a reduced inventory and pass this on to Bifrost.
|
|
bifrost_limit: "{{ groups['controllers'] | join(':') }}"
|
|
# Set to False to avoid waiting for the controllers to become active.
|
|
wait_active: True
|
|
wait_active_timeout: 600
|
|
wait_active_interval: 10
|
|
provisionable_states:
|
|
- enroll
|
|
- manageable
|
|
- available
|
|
gather_facts: no
|
|
tasks:
|
|
- name: Check the Bifrost controller inventory provision state
|
|
command: >
|
|
docker exec bifrost_deploy
|
|
bash -c '. env-vars &&
|
|
export OS_URL=$IRONIC_URL &&
|
|
export OS_TOKEN=$OS_AUTH_TOKEN &&
|
|
export BIFROST_INVENTORY_SOURCE=ironic &&
|
|
ansible baremetal
|
|
--connection local
|
|
--inventory /etc/bifrost/inventory/
|
|
-e @/etc/bifrost/bifrost.yml
|
|
-e @/etc/bifrost/dib.yml
|
|
{% if bifrost_limit %}--limit {{ bifrost_limit }}{% endif %}
|
|
-m command
|
|
-a "openstack baremetal node show {% raw %}{{ inventory_hostname }}{% endraw %} -f value -c provision_state"'
|
|
register: provision_state
|
|
changed_when: False
|
|
failed_when: >
|
|
{{ provision_state | failed or
|
|
provision_state.stdout_lines[1] not in provisionable_states }}
|
|
|
|
- name: Ensure the Bifrost controller inventory is managed
|
|
command: >
|
|
docker exec bifrost_deploy
|
|
bash -c '. env-vars &&
|
|
export BIFROST_INVENTORY_SOURCE=ironic &&
|
|
ansible baremetal -vvvv
|
|
--connection local
|
|
--inventory /etc/bifrost/inventory/
|
|
-e @/etc/bifrost/bifrost.yml
|
|
-e @/etc/bifrost/dib.yml
|
|
{% if bifrost_limit %}--limit {{ bifrost_limit }}{% endif %}
|
|
-m command
|
|
-a "ironic node-set-provision-state {% raw %}{{ inventory_hostname }}{% endraw %} manage"'
|
|
when: "{{ provision_state.stdout_lines[1] == 'enroll' }}"
|
|
|
|
- name: Ensure the Bifrost controller inventory is provided
|
|
command: >
|
|
docker exec bifrost_deploy
|
|
bash -c '. env-vars &&
|
|
export BIFROST_INVENTORY_SOURCE=ironic &&
|
|
ansible baremetal -vvvv
|
|
--connection local
|
|
--inventory /etc/bifrost/inventory/
|
|
-e @/etc/bifrost/bifrost.yml
|
|
-e @/etc/bifrost/dib.yml
|
|
{% if bifrost_limit %}--limit {{ bifrost_limit }}{% endif %}
|
|
-m command
|
|
-a "ironic node-set-provision-state {% raw %}{{ inventory_hostname }}{% endraw %} provide"'
|
|
when: "{{ provision_state.stdout_lines[1] == 'manageable' }}"
|
|
|
|
- name: Ensure the Bifrost controller inventory is provisioned
|
|
command: >
|
|
docker exec bifrost_deploy
|
|
bash -c '. env-vars &&
|
|
export BIFROST_INVENTORY_SOURCE=ironic &&
|
|
ansible-playbook -vvvv
|
|
/bifrost/playbooks/deploy-dynamic.yaml
|
|
--inventory /etc/bifrost/inventory/
|
|
-e @/etc/bifrost/bifrost.yml
|
|
-e @/etc/bifrost/dib.yml
|
|
{% if bifrost_limit %}--limit {{ bifrost_limit }}{% endif %}'
|
|
|
|
- name: Wait for the Bifrost controller inventory to become active
|
|
command: >
|
|
docker exec bifrost_deploy
|
|
bash -c '. env-vars &&
|
|
export OS_URL=$IRONIC_URL &&
|
|
export OS_TOKEN=$OS_AUTH_TOKEN &&
|
|
export BIFROST_INVENTORY_SOURCE=ironic &&
|
|
ansible baremetal
|
|
--connection local
|
|
--inventory /etc/bifrost/inventory/
|
|
-e @/etc/bifrost/bifrost.yml
|
|
-e @/etc/bifrost/dib.yml
|
|
{% if bifrost_limit %}--limit {{ bifrost_limit }}{% endif %}
|
|
-m command
|
|
-a "openstack baremetal node show {% raw %}{{ inventory_hostname }}{% endraw %} -f value -c provision_state"'
|
|
register: provision_state
|
|
until: "{{ provision_state.stdout_lines[1] in ['active', 'deploy failed'] }}"
|
|
retries: "{{ wait_active_timeout // wait_active_interval }}"
|
|
delay: "{{ wait_active_interval }}"
|
|
when: "{{ wait_active | bool }}"
|
|
changed_when: False
|
|
|
|
- name: Wait for the controller hosts to be available
|
|
hosts: controllers
|
|
gather_facts: no
|
|
vars:
|
|
# Set to False to avoid waiting for the controllers to be accessible via
|
|
# SSH.
|
|
wait_ssh: True
|
|
wait_ssh_timeout: 600
|
|
tasks:
|
|
- name: Wait for SSH access to the controllers
|
|
local_action:
|
|
module: wait_for
|
|
host: "{{ ansible_host }}"
|
|
port: 22
|
|
state: started
|
|
timeout: "{{ wait_ssh_timeout }}"
|
|
when: "{{ wait_ssh | bool }}"
|