From b8a97b8ad3631af9f045353fc432fc1f7244ee58 Mon Sep 17 00:00:00 2001 From: Chuck Carmack Date: Fri, 3 Jun 2016 15:50:28 +0000 Subject: [PATCH] Add redeploy-dynamic playbook The playbook unprovisions the nodes, giving each node a configurable amount of time to change to provision state 'available'. Then it deploys the nodes, giving each node a configurable amount of time to change to provision state 'active' Change-Id: I1e477c2dee3d0c40f467cd9e1906fd3dfa7cc1bd --- README.rst | 8 ++ playbooks/redeploy-dynamic.yaml | 74 +++++++++++++++++++ .../redeploy-dynamic-cc8b69f79a6869cd.yaml | 9 +++ 3 files changed, 91 insertions(+) create mode 100644 playbooks/redeploy-dynamic.yaml create mode 100644 releasenotes/notes/redeploy-dynamic-cc8b69f79a6869cd.yaml diff --git a/README.rst b/README.rst index 224e22e0d..f5224a0cc 100644 --- a/README.rst +++ b/README.rst @@ -350,6 +350,14 @@ Note:: or set the ssh_public_key_path option on the ansible-playbook command line by setting the variable. Example: "-e ssh_public_key_path=~/.ssh/id_rsa.pub" +If the hosts need to be re-deployed, the dynamic redeploy playbook may be used:: + + export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json + ansible-playbook -vvvv -i inventory/bifrost_inventory.py redeploy-dynamic.yaml + +This playbook will undeploy the hosts, followed by a deployment, allowing +a configurable timeout for the hosts to transition in each step. + Testing with a single command ============================= diff --git a/playbooks/redeploy-dynamic.yaml b/playbooks/redeploy-dynamic.yaml new file mode 100644 index 000000000..f0f9298f7 --- /dev/null +++ b/playbooks/redeploy-dynamic.yaml @@ -0,0 +1,74 @@ +# This playbook redeploys nodes by doing the following: +# 1) For each node in provision active state, unprovision the node +# (ie. set the provision state to 'available' +# 2) Each node is given a configurable amount of time to transition +# to 'available' state. +# 3) For each node now in 'available' state, deploy the node. +# 4) Each node is given a configurable amount of time to transition +# to 'active' state. +# +# To utilize: +# export BIFROST_INVENTORY_SOURCE= +# ansible-playbook -vvvv -i inventory/bifrost_inventory.py redeploy-dynamic.yaml +# NOTE: 'ironic' may be used as the data source, in which case ironic will +# will be queried for all the nodes. +# +# NOTE(TheJulia): The format of this example will cause hosts to be deployed +# utilizing DHCP on eth0 of Ubuntu/Debian hosts. It is advisable you build +# your deployment image with the dhcp-all-interfaces element when deploying +# other operating systems or if your target node has multiple ethernet +# interfaces. +--- +- hosts: localhost + connection: local + name: "Collect facts" + become: no + gather_facts: yes +- hosts: baremetal + name: "Unprovision the nodes" + become: no + connection: local + pre_tasks: + - name: "Pull initial ironic facts" + os_ironic_facts: + auth_type: "{{ auth_type | default(omit) }}" + auth: "{{ auth | default(omit) }}" + name: "{{ inventory_hostname }}" + ironic_url: "{{ ironic_url }}" + skip_items: [] + roles: + - { role: bifrost-unprovision-node-dynamic, when: (provision_state == "active" + or provision_state == "deploy failed" + or provision_state == "error") and maintenance | bool != true } + post_tasks: + - name: "Pull ironic facts until provision state available" + os_ironic_facts: + auth_type: "{{ auth_type | default(omit) }}" + auth: "{{ auth | default(omit) }}" + name: "{{ inventory_hostname }}" + ironic_url: "{{ ironic_url }}" + skip_items: [] + register: result + until: provision_state == "available" + retries: "{{ available_state_wait_retries | default(15) }}" + delay: "{{ provision_state_retry_interval | default(20) }}" +- hosts: baremetal + name: "Activate the nodes" + become: no + connection: local + roles: + - { role: bifrost-configdrives-dynamic, when: provision_state == "available" and maintenance | bool != true } + - { role: bifrost-deploy-nodes-dynamic, when: provision_state == "available" and maintenance | bool != true } + post_tasks: + - name: "Pull ironic facts until provision state active" + os_ironic_facts: + auth_type: "{{ auth_type | default(omit) }}" + auth: "{{ auth | default(omit) }}" + name: "{{ inventory_hostname }}" + ironic_url: "{{ ironic_url }}" + skip_items: [] + register: result + until: provision_state == "active" + retries: "{{ active_state_wait_retries | default(30) }}" + delay: "{{ provision_state_retry_interval | default(20) }}" + diff --git a/releasenotes/notes/redeploy-dynamic-cc8b69f79a6869cd.yaml b/releasenotes/notes/redeploy-dynamic-cc8b69f79a6869cd.yaml new file mode 100644 index 000000000..6363d425f --- /dev/null +++ b/releasenotes/notes/redeploy-dynamic-cc8b69f79a6869cd.yaml @@ -0,0 +1,9 @@ +--- +features: + - A new playbook was added to redeploy nodes. + The playbook transitions each node's provision state + to 'available', waiting for the nodes to reach + that state. Next, the playbook deploys the + nodes, waiting for the nodes to reach provision + state 'active'. The playbook is redeploy-dynamic.yaml + in the playbooks directory.