add support for rhel8/centos8 virthosts

Enable the use of CentOS or RHEL as a
virthost for the undercloud/overcloud
deployment.

Fix bug w/ python mismatch w/ delegation
in the virtbmc role.

Change-Id: I8455f4272cf062d63258e8f6bd4c731062322538
This commit is contained in:
Wes Hayutin 2020-01-11 15:07:42 -05:00 committed by Sagi Shnaidman
parent 0cbecb4bec
commit 5f888ca2e8
11 changed files with 120 additions and 27 deletions

View File

@ -8,6 +8,9 @@ fact_caching = jsonfile
fact_caching_connection = $VIRTUAL_ENV/ansible_facts_cache
fact_caching_timeout = 0
stdout_callback = debug
# https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html
# this may fix a few things in the future
interpreter_python = auto
# Attempt to load custom modules whether it's installed system-wide or from a virtual environment
callback_plugins = /usr/lib/python2.7/site-packages/ara/plugins/callbacks:$VIRTUAL_ENV/lib/python2.7/site-packages/ara/plugins/callbacks:$VIRTUAL_ENV/lib/python3.6/site-packages/ara/plugins/callbacks:/usr/local/lib/python2.7/dist-packages/ara/plugins/callbacks

View File

@ -1,2 +1,10 @@
---
qemu_bridge_conf: /etc/qemu-kvm/bridge.conf
libvirt_packages:
- qemu-kvm
- libvirt
- libvirt-python
- libguestfs-tools
- python-lxml
- polkit-pkla-compat
- python-netaddr

View File

@ -0,0 +1,17 @@
libvirt_packages:
- libvirt
- libvirt-daemon
- qemu-kvm-common
- qemu-kvm
- libvirt-daemon-kvm
- libvirt-daemon-driver-network
- libvirt-daemon-driver-qemu
- libguestfs-tools
- python3
- python3-lxml
- python3-netaddr
- python3-pip
- python3-devel
- python3-libvirt
ansible_pkg_mgr: dnf

View File

@ -0,0 +1,17 @@
libvirt_packages:
- libvirt
- libvirt-daemon
- qemu-kvm-common
- qemu-kvm
- libvirt-daemon-kvm
- libvirt-daemon-driver-network
- libvirt-daemon-driver-qemu
- libguestfs-tools
- python3
- python3-lxml
- python3-netaddr
- python3-pip
- python3-devel
- python3-libvirt
ansible_pkg_mgr: dnf

View File

@ -53,7 +53,7 @@
'{{ working_dir }}/undercloud-resized.qcow2'
2>&1 | tee -a {{ working_dir }}/virt-resize.log
register: result
no_log: result is success
no_log: true
changed_when: true
- name: Rename resized image to original name
@ -66,9 +66,9 @@
no_log: true
shell: >
import crypt;
print crypt.crypt("{{ vm_pass }}", "$1$SecretSalt$")
print(crypt.crypt("{{ vm_pass }}", "$1$SecretSalt$"))
args:
executable: /usr/bin/python
executable: "/usr/bin/python{{ ansible_python['version']['major'] }}"
register: hash
changed_when: false

View File

@ -9,13 +9,6 @@
LIBVIRT_DEFAULT_URI: "{{ libvirt_uri }}"
block:
# ensure python-netaddr is installed for next task
- name: ensure python-netaddr
become: true
package:
name: python-netaddr
state: present
# Generate MAC addresses that we'll use for the overcloud nodes.
# By generating these in advance we can populate the
# `instackenv.json` file with MAC addresses without running

View File

@ -26,7 +26,6 @@
ansible_user: zuul
subnode_private_ip: "{{ ip_result.stdout_lines[0] }}"
subnode_public_ip: "{{ ip_result.stdout_lines[0] }}"
ansible_python_interpreter: "{{ python_interpreter|default('/usr/bin/python') }}"
- name: Add {{ item.name }} to known_hosts
known_hosts:

View File

@ -1,12 +1,8 @@
---
# The packages required to set up our desired libvirt environment.
libvirt_packages:
- qemu-kvm
- libvirt
- libvirt-python
- libguestfs-tools
- python-lxml
- polkit-pkla-compat
# moved to roles/environment/vars
# libvirt_packages:
# The name of the libvirt service.
libvirtd_service: libvirtd

View File

@ -0,0 +1,3 @@
---
dependencies:
- environment

View File

@ -43,6 +43,7 @@
path: "{{ local_working_dir }}/ssh.config.ansible"
state: touch
# Add the virthost to the in-memory inventory. The inventory is not
# written out to disk unless you call the `tripleo-inventory` role.
- name: Add the virthost to the inventory
@ -52,3 +53,51 @@
ansible_fqdn: "{{ virthost }}"
ansible_user: "root"
ansible_host: "{{ virthost }}"
# The following idempotent code ensures when running
# with 127.0.0.2 that the non_root_user facts are known
# to both the virthost and localhost hostvars
# duplicates roles/provision/remote/tasks/main.yml#L40-L71
# This avoids the need to delegate in
# roles/virtbmc/tasks/configure-vbmc.yml#L30-L33
# The delegation fails across mixed virthosts
# with different python interps.
# Create a non-root user on the target host. This is the user that
# will own the virtual infrastructure on which we deploy openstack.
# when: virthost == '127.0.0.2'
- name: remove the need to delegate back to virthost for the virtbmc
block:
- name: Create non-root user
user:
name: "{{ non_root_user }}"
state: present
shell: /bin/bash
create_home: true
become: true
- name: Get the non-root user UID
command: "id {{ non_root_user }} -u"
register: non_root_user_uid_output
changed_when: false
retries: 3
delay: 5
until: non_root_user_uid_output is not failed
- name: Get the non-root user homedir
shell: |
set -o pipefail
getent passwd {{ non_root_user }} | cut -d: -f6
register: non_root_user_homedir_output
changed_when: false
- name: Save the non-root user UID
set_fact:
non_root_user_uid: "{{ non_root_user_uid_output.stdout }}"
cacheable: true
- name: Save the non-root user homedir
set_fact:
non_root_user_homedir: "{{ non_root_user_homedir_output.stdout }}"
cacheable: true
when: virthost == '127.0.0.2'

View File

@ -27,15 +27,23 @@
session_timout=20
become: true
- name: get virthost non_root_user userid
command: id -u {{ non_root_user }}
register: non_root_user_uid
delegate_to: virthost
changed_when: false
- name: set fact on non_root_user_uid
set_fact:
non_root_user_uid: "{{ non_root_user_uid.stdout }}"
# when running with 127.0.0.2 as
# the virthost ensure
- name: get the non_root_user_uuid
block:
- name: get virthost non_root_user userid
command: id -u {{ non_root_user }}
register: non_root_user_uid
delegate_to: virthost
changed_when: false
- name: set fact on non_root_user_uid
set_fact:
non_root_user_uid: "{{ non_root_user_uid.stdout }}"
rescue:
# set in roles/provision/local
- name: set fact on non_root_user_uid
set_fact:
non_root_user_uid: "{{ hostvars['localhost']['non_root_user_uid'] }}"
# The first network defined with an address will be used for vbmc access.
- name: set vbmc address if there is a (nat) network defined with an address