
Currently we install python dependencies on the Ansible control host each time the ip-allocation and console-allocation roles are executed. This is inefficient, particularly in the case of the ip-allocation role which is run serially for all hosts. It is also unnecessary since we have these packages available in the Python environment used to execute kayobe. The kolla-ansible role also has an implicit dependency on PyYAML for managing kolla passwords. This change uses ansible_playbook_python as the Python interpreter for the necessary tasks in these roles to avoid installing dependencies on the system on CentOS 8 and Ubuntu. For CentOS 7 we still need to use the platform Python, due to needing SELinux bindings. Change-Id: Ic6a1c69a34241f4fbe617a0b12aec9b1528ba352 Story: 2006574 Task: 38825
73 lines
2.7 KiB
YAML
73 lines
2.7 KiB
YAML
---
|
|
- block:
|
|
- name: Include OS family-specific variables
|
|
include_vars: "{{ hostvars.localhost.ansible_os_family }}.yml"
|
|
|
|
# Note: Currently we install these using the system package manager rather than
|
|
# pip to a virtualenv. This is because Yum is required elsewhere and cannot
|
|
# easily be installed in a virtualenv.
|
|
- name: Ensure package dependencies are installed
|
|
local_action:
|
|
module: package
|
|
name: "{{ item }}"
|
|
state: present
|
|
use: "{{ console_allocation_package_manager }}"
|
|
become: True
|
|
with_items: "{{ console_allocation_package_dependencies }}"
|
|
run_once: True
|
|
when:
|
|
- hostvars.localhost.ansible_os_family == 'RedHat'
|
|
- hostvars.localhost.ansible_distribution_major_version | int == 7
|
|
|
|
- name: Validate allocation pool start
|
|
vars:
|
|
port: "{{ console_allocation_pool_start | int(default=-1) }}"
|
|
fail:
|
|
msg: >-
|
|
You must must define an console_allocation_pool_start. This should
|
|
be a valid TCP port.
|
|
when: >-
|
|
console_allocation_pool_end is none or
|
|
port | int < 0 or port | int > 65535
|
|
|
|
- name: Validate allocation pool end
|
|
vars:
|
|
port: "{{ console_allocation_pool_end | int(default=-1) }}"
|
|
fail:
|
|
msg: >-
|
|
You must must define an console_allocation_pool_end. This should
|
|
be a valid TCP port.
|
|
when: >-
|
|
console_allocation_pool_end is none or
|
|
port | int < 0 or port | int > 65535
|
|
|
|
- name: Validate that allocation start is less than allocation end
|
|
fail:
|
|
msg: >-
|
|
console_allocation_start and console_allocation_end define a range
|
|
of TCP ports. You have defined a range with a start that is less than
|
|
the end
|
|
when:
|
|
- (console_allocation_pool_start | int) > (console_allocation_pool_end | int)
|
|
|
|
- name: Ensure Ironic serial console ports are allocated
|
|
vars:
|
|
# NOTE(mgoddard): Use the Python interpreter used to run ansible-playbook,
|
|
# since this has Python dependencies available to it (PyYAML). On CentOS 7
|
|
# we use the system Python to ensure that we can import SELinux bindings.
|
|
ansible_python_interpreter: >-
|
|
{{ '/usr/libexec/platform-python'
|
|
if hostvars.localhost.ansible_os_family == 'RedHat' and hostvars.localhost.ansible_distribution_major_version | int == 7
|
|
else ansible_playbook_python }}
|
|
local_action:
|
|
module: console_allocation
|
|
allocation_file: "{{ console_allocation_filename }}"
|
|
nodes: "{{ console_allocation_ironic_nodes }}"
|
|
allocation_pool_start: "{{ console_allocation_pool_start }}"
|
|
allocation_pool_end: "{{ console_allocation_pool_end }}"
|
|
register: result
|
|
|
|
- name: Register a fact containing the console allocation result
|
|
set_fact:
|
|
console_allocation_result: "{{ result }}"
|