forked from openstack-k8s-operators/ci-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a hook to move ironic nodes to manageable -> avaialable state.
- Loading branch information
1 parent
3280af0
commit f13f402
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
- name: Manage and Provide ironic baremetal nodes | ||
hosts: "{{ cifmw_target_hook_host | default('localhost') }}" | ||
gather_facts: false | ||
environment: | ||
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" | ||
PATH: "{{ cifmw_path }}" | ||
tasks: | ||
- name: Move all nodes to managed state | ||
cifmw.general.ci_script: | ||
output_dir: "{{ cifmw_basedir }}/artifacts" | ||
executable: "/bin/bash" | ||
script: | | ||
set -xe -o pipefail | ||
oc project {{ namespace }} | ||
BAREMETAL_NODES=$(oc rsh openstackclient openstack baremetal node list -c UUID -f value) | ||
# Manage nodes | ||
for node in $BAREMETAL_NODES; do | ||
CURRENT_STATE=$(oc rsh openstackclient openstack baremetal node show $node -f value -c provision_state) | ||
if [ "${CURRENT_STATE}" == "enroll" ]; then | ||
oc rsh openstackclient openstack baremetal node manage $node | ||
fi | ||
done | ||
- name: Wait for nodes to reach manageable state | ||
register: _os_out | ||
ansible.builtin.shell: | | ||
set -xe -o pipefail | ||
oc project {{ namespace }} > /dev/null | ||
oc rsh openstackclient \ | ||
openstack baremetal node list -f value -c "Provisioning State" | ||
until: '_os_out.stdout_lines | difference(["manageable"]) | length == 0' | ||
retries: 6 | ||
delay: 10 | ||
|
||
- name: Move all nodes to managed active state | ||
cifmw.general.ci_script: | ||
output_dir: "{{ cifmw_basedir }}/artifacts" | ||
executable: "/bin/bash" | ||
script: | | ||
set -xe -o pipefail | ||
oc project {{ namespace }} | ||
BAREMETAL_NODES=$(oc rsh openstackclient openstack baremetal node list -c UUID -f value) | ||
# Provide nodes | ||
for node in $BAREMETAL_NODES; do | ||
CURRENT_STATE=$(oc rsh openstackclient openstack baremetal node show $node -f value -c provision_state) | ||
if [ "${CURRENT_STATE}" == "manageable" ]; then | ||
oc rsh openstackclient openstack baremetal node provide $node | ||
fi | ||
done | ||
- name: Wait for nodes to reach available state | ||
register: _os_out | ||
ansible.builtin.shell: | | ||
set -xe -o pipefail | ||
oc project {{ namespace }} > /dev/null | ||
oc rsh openstackclient \ | ||
openstack baremetal node list -f value -c "Provisioning State" | ||
until: '_os_out.stdout_lines | difference(["available"]) | length == 0' | ||
retries: 60 | ||
delay: 10 |