ddfd6b6202
Kayobe uses a number of virtual environments on the remote hosts for python dependencies such as shade, python-openstackclient, docker, etc. By default these are stored in /opt/kayobe/venvs/. Typically we do not provide version restrictions when installing these packages, so over the course of time they may become stale and incompatible. This change installs the latest version of packages allowed by OpenStack upper constraints. It also adds a new variable, 'pip_upper_constraints_file', to set the upper constraints file. The existing variable 'kolla_upper_constraints_file' now defaults to the value of 'pip_upper_constraints_file'. Change-Id: I8d2956f95bbc44b5a9e88e7569372048a62f12f5 Story: 2005923 Task: 34193
64 lines
2.6 KiB
YAML
64 lines
2.6 KiB
YAML
---
|
|
# This playbook will ensure that all baremetal compute nodes are named after
|
|
# their inventory host names. It matches the ipmi address in the inventory to
|
|
# the one gathered from inspection
|
|
|
|
- name: Rename baremetal compute nodes
|
|
hosts: controllers[0]
|
|
gather_facts: False
|
|
vars:
|
|
venv: "{{ virtualenv_path }}/openstack-cli"
|
|
pre_tasks:
|
|
- name: Set up openstack cli virtualenv
|
|
pip:
|
|
virtualenv: "{{ venv }}"
|
|
name:
|
|
- python-openstackclient
|
|
- python-ironicclient
|
|
state: latest
|
|
extra_args: "{% if pip_upper_constraints_file %}-c {{ pip_upper_constraints_file }}{% endif %}"
|
|
|
|
- name: Rename baremetal compute nodes
|
|
hosts: baremetal-compute
|
|
gather_facts: False
|
|
vars:
|
|
venv: "{{ virtualenv_path }}/openstack-cli"
|
|
controller_host: "{{ groups['controllers'][0] }}"
|
|
tasks:
|
|
- name: Fail if ipmi host variable not set
|
|
vars:
|
|
ipmi_address: "{{ hostvars[inventory_hostname].ipmi_address }}"
|
|
fail:
|
|
msg: >
|
|
The host variable, ipmi_address is not defined for {{ inventory_hostname }}. This variable is required
|
|
to run this playbook.
|
|
when: ipmi_address is not defined or not ipmi_address
|
|
- name: Get list of nodes
|
|
command: >
|
|
{{ venv }}/bin/openstack baremetal node list -f json --fields uuid name driver_info
|
|
register: nodes
|
|
delegate_to: "{{ controller_host }}"
|
|
environment: "{{ openstack_auth_env }}"
|
|
run_once: true
|
|
changed_when: false
|
|
vars:
|
|
# NOTE: Without this, the controller's ansible_host variable will not
|
|
# be respected when using delegate_to.
|
|
ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}"
|
|
|
|
- name: Rename baremetal compute nodes
|
|
command: >
|
|
{{ venv }}/bin/openstack baremetal node set --name "{{ inventory_hostname }}" "{{ node['UUID'] }}"
|
|
delegate_to: "{{ controller_host }}"
|
|
environment: "{{ openstack_auth_env }}"
|
|
vars:
|
|
# NOTE: Without this, the controller's ansible_host variable will not
|
|
# be respected when using delegate_to.
|
|
ansible_host: "{{ hostvars[controller_host].ansible_host | default(controller_host) }}"
|
|
ipmi_address: "{{ hostvars[inventory_hostname].ipmi_address }}"
|
|
matching_nodes: "{{ (nodes.stdout | from_json) | selectattr('Driver Info.ipmi_address', 'defined') | selectattr('Driver Info.ipmi_address', 'equalto', ipmi_address) | list }}"
|
|
node: "{{ matching_nodes | first }}"
|
|
when:
|
|
- matching_nodes | length > 0
|
|
- node['Name'] != inventory_hostname
|