From d6aa4ea16e917996d6009956b4edcd1ed4275c72 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 21 Apr 2021 12:18:11 +0100 Subject: [PATCH] Ubuntu: simplify OS distro selection Adds a new 'os_distribution' variable which can be used to select the OS distribution, with sensible defaults for other variables. The default value is 'centos'. This patch changes the default value for the '*_bootstrap_user' variables from using the $USER environment variable to using fixed defaults equal to the os_distribution variable. This aligns with the standard user configured in most cloud images, and images created via DIB. Note that we are continuing to use a CentOS based IPA image, since we have been unable to get IPA to build for Ubuntu. Depends-On: https://review.opendev.org/c/openstack/kayobe-config-dev/+/788234 Change-Id: I9e10239f58fe209867116fa2e10f1ce74220b966 Story: 2004960 Task: 42323 --- ansible/group_vars/all/bifrost | 17 ++++++++++------- ansible/group_vars/all/compute | 4 ++-- ansible/group_vars/all/controllers | 4 ++-- ansible/group_vars/all/globals | 7 +++++++ ansible/group_vars/all/kolla | 5 +++-- ansible/group_vars/all/seed | 4 ++-- ansible/group_vars/all/seed-hypervisor | 4 ++-- ansible/group_vars/all/seed-vm | 13 +++++++++++-- ansible/group_vars/all/storage | 4 ++-- etc/kayobe/bifrost.yml | 8 +++++--- etc/kayobe/compute.yml | 2 +- etc/kayobe/controllers.yml | 2 +- etc/kayobe/globals.yml | 7 +++++++ etc/kayobe/kolla.yml | 3 ++- etc/kayobe/seed-hypervisor.yml | 2 +- etc/kayobe/seed-vm.yml | 3 +++ etc/kayobe/seed.yml | 2 +- etc/kayobe/storage.yml | 2 +- .../notes/os-distribution-69445eb19a611d43.yaml | 14 ++++++++++++++ 19 files changed, 77 insertions(+), 30 deletions(-) create mode 100644 releasenotes/notes/os-distribution-69445eb19a611d43.yaml diff --git a/ansible/group_vars/all/bifrost b/ansible/group_vars/all/bifrost index 81224ed1e..d26c9c868 100644 --- a/ansible/group_vars/all/bifrost +++ b/ansible/group_vars/all/bifrost @@ -18,15 +18,18 @@ kolla_bifrost_firewalld_internal_zone: trusted ############################################################################### # Diskimage-builder configuration. -# DIB base OS element. -kolla_bifrost_dib_os_element: "centos" +# DIB base OS element. Default is {{ os_distribution }}. +kolla_bifrost_dib_os_element: "{{ os_distribution }}" -# DIB image OS release. -kolla_bifrost_dib_os_release: "8" +# DIB image OS release. Default is "focal" when os_distribution is "ubuntu", or +# "8" otherwise. +kolla_bifrost_dib_os_release: "{{ 'focal' if os_distribution == 'ubuntu' else '8' }}" -# List of default DIB elements. +# List of default DIB elements. Default is ["disable-selinux", +# "enable-serial-console", "vm"] when os_distribution is "centos", or +# ["enable-serial-console", "vm"] otherwise. kolla_bifrost_dib_elements_default: - - "disable-selinux" + - "{% if os_distribution == 'centos' %}disable-selinux{% endif %}" - "enable-serial-console" - "vm" @@ -34,7 +37,7 @@ kolla_bifrost_dib_elements_default: kolla_bifrost_dib_elements_extra: [] # List of all DIB elements. -kolla_bifrost_dib_elements: "{{ kolla_bifrost_dib_elements_default + kolla_bifrost_dib_elements_extra }}" +kolla_bifrost_dib_elements: "{{ kolla_bifrost_dib_elements_default | select | list + kolla_bifrost_dib_elements_extra }}" # DIB init element. kolla_bifrost_dib_init_element: "cloud-init-datasources" diff --git a/ansible/group_vars/all/compute b/ansible/group_vars/all/compute index eb5f7bd90..61bbe91f1 100644 --- a/ansible/group_vars/all/compute +++ b/ansible/group_vars/all/compute @@ -3,8 +3,8 @@ # Compute node configuration. # User with which to access the computes via SSH during bootstrap, in order -# to setup the Kayobe user account. -compute_bootstrap_user: "{{ lookup('env', 'USER') }}" +# to setup the Kayobe user account. Default is {{ os_distribution }}. +compute_bootstrap_user: "{{ os_distribution }}" ############################################################################### # Compute network interface configuration. diff --git a/ansible/group_vars/all/controllers b/ansible/group_vars/all/controllers index e820bcf11..0c09024fa 100644 --- a/ansible/group_vars/all/controllers +++ b/ansible/group_vars/all/controllers @@ -3,8 +3,8 @@ # Controller node configuration. # User with which to access the controllers via SSH during bootstrap, in order -# to setup the Kayobe user account. -controller_bootstrap_user: "{{ lookup('env', 'USER') }}" +# to setup the Kayobe user account. Default is {{ os_distribution }}. +controller_bootstrap_user: "{{ os_distribution }}" ############################################################################### # Controller network interface configuration. diff --git a/ansible/group_vars/all/globals b/ansible/group_vars/all/globals index e5dc329c4..9d9d6e314 100644 --- a/ansible/group_vars/all/globals +++ b/ansible/group_vars/all/globals @@ -40,3 +40,10 @@ virtualenv_path: "{{ base_path ~ '/venvs' }}" # User with which to access remote hosts. This user will be created if it does # not exist. kayobe_ansible_user: "stack" + +############################################################################### +# OS distribution. + +# OS distribution name. Valid options are "centos", "ubuntu". Default is +# "centos". +os_distribution: "centos" diff --git a/ansible/group_vars/all/kolla b/ansible/group_vars/all/kolla index 3c98b95f5..33aef2c69 100644 --- a/ansible/group_vars/all/kolla +++ b/ansible/group_vars/all/kolla @@ -52,8 +52,9 @@ kolla_node_custom_config_path: "{{ kolla_config_path }}/config" ############################################################################### # Kolla configuration. -# Kolla base container image distribution. -kolla_base_distro: "centos" +# Kolla base container image distribution. Options are "centos", "debian", +# "ubuntu". Default is {{ os_distribution }}. +kolla_base_distro: "{{ os_distribution }}" # Kolla container image type: binary or source. kolla_install_type: "binary" diff --git a/ansible/group_vars/all/seed b/ansible/group_vars/all/seed index 620dedce1..decdd2a52 100644 --- a/ansible/group_vars/all/seed +++ b/ansible/group_vars/all/seed @@ -3,8 +3,8 @@ # Seed node configuration. # User with which to access the seed via SSH during bootstrap, in order to -# setup the Kayobe user account. -seed_bootstrap_user: "{{ lookup('env', 'USER') }}" +# setup the Kayobe user account. Default is {{ os_distribution }}. +seed_bootstrap_user: "{{ os_distribution }}" ############################################################################### # Seed network interface configuration. diff --git a/ansible/group_vars/all/seed-hypervisor b/ansible/group_vars/all/seed-hypervisor index 2826b9577..9ee93d118 100644 --- a/ansible/group_vars/all/seed-hypervisor +++ b/ansible/group_vars/all/seed-hypervisor @@ -3,8 +3,8 @@ # Seed hypervisor node configuration. # User with which to access the seed hypervisor via SSH during bootstrap, in -# order to setup the Kayobe user account. -seed_hypervisor_bootstrap_user: "{{ lookup('env', 'USER') }}" +# order to setup the Kayobe user account. Default is {{ os_distribution }}. +seed_hypervisor_bootstrap_user: "{{ os_distribution }}" ############################################################################### # Seed hypervisor network interface configuration. diff --git a/ansible/group_vars/all/seed-vm b/ansible/group_vars/all/seed-vm index 5af51c369..4dcda8285 100644 --- a/ansible/group_vars/all/seed-vm +++ b/ansible/group_vars/all/seed-vm @@ -40,8 +40,17 @@ seed_vm_root_capacity: 50G # Format of the seed VM root volume. seed_vm_root_format: qcow2 -# Base image for the seed VM root volume. -seed_vm_root_image: "https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20210210.0.x86_64.qcow2" +# Base image for the seed VM root volume. Default is +# "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img" +# when os_distribution is "ubuntu", or +# "https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20210210.0.x86_64.qcow2" +# otherwise. +seed_vm_root_image: >- + {%- if os_distribution == 'ubuntu' %} + https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img + {%- else -%} + https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20210210.0.x86_64.qcow2 + {%- endif %} # Capacity of the seed VM data volume. seed_vm_data_capacity: 100G diff --git a/ansible/group_vars/all/storage b/ansible/group_vars/all/storage index bc2187140..b474e3091 100644 --- a/ansible/group_vars/all/storage +++ b/ansible/group_vars/all/storage @@ -3,8 +3,8 @@ # Storage node configuration. # User with which to access the storages via SSH during bootstrap, in order -# to setup the Kayobe user account. -storage_bootstrap_user: "{{ lookup('env', 'USER') }}" +# to setup the Kayobe user account. Default is {{ os_distribution }}. +storage_bootstrap_user: "{{ os_distribution }}" ############################################################################### # Storage network interface configuration. diff --git a/etc/kayobe/bifrost.yml b/etc/kayobe/bifrost.yml index bd7e97e1d..8d20ebebe 100644 --- a/etc/kayobe/bifrost.yml +++ b/etc/kayobe/bifrost.yml @@ -18,14 +18,16 @@ ############################################################################### # Diskimage-builder configuration. -# DIB base OS element. Default is "centos". +# DIB base OS element. Default is {{ os_distribution }}. #kolla_bifrost_dib_os_element: -# DIB image OS release. Default is "8". +# DIB image OS release. Default is "focal" when os_distribution is "ubuntu", or +# "8" otherwise. #kolla_bifrost_dib_os_release: # List of default DIB elements. Default is ["disable-selinux", -# "enable-serial-console", "vm"]. +# "enable-serial-console", "vm"] when os_distribution is "centos", or +# ["enable-serial-console", "vm"] otherwise. #kolla_bifrost_dib_elements_default: # List of additional DIB elements. Default is none. diff --git a/etc/kayobe/compute.yml b/etc/kayobe/compute.yml index ab47953fc..59a68fa78 100644 --- a/etc/kayobe/compute.yml +++ b/etc/kayobe/compute.yml @@ -3,7 +3,7 @@ # Compute node configuration. # User with which to access the computes via SSH during bootstrap, in order -# to setup the Kayobe user account. +# to setup the Kayobe user account. Default is {{ os_distribution }}. #compute_bootstrap_user: ############################################################################### diff --git a/etc/kayobe/controllers.yml b/etc/kayobe/controllers.yml index 2fbe85b66..6a4e45eeb 100644 --- a/etc/kayobe/controllers.yml +++ b/etc/kayobe/controllers.yml @@ -3,7 +3,7 @@ # Controller node configuration. # User with which to access the controllers via SSH during bootstrap, in order -# to setup the Kayobe user account. +# to setup the Kayobe user account. Default is {{ os_distribution }}. #controller_bootstrap_user: ############################################################################### diff --git a/etc/kayobe/globals.yml b/etc/kayobe/globals.yml index bfe9b8a3f..64290d926 100644 --- a/etc/kayobe/globals.yml +++ b/etc/kayobe/globals.yml @@ -42,6 +42,13 @@ # not exist. #kayobe_ansible_user: +############################################################################### +# OS distribution. + +# OS distribution name. Valid options are "centos", "ubuntu". Default is +# "centos". +#os_distribution: + ############################################################################### # Dummy variable to allow Ansible to accept this file. workaround_ansible_issue_8743: yes diff --git a/etc/kayobe/kolla.yml b/etc/kayobe/kolla.yml index 74f805fad..96fba2662 100644 --- a/etc/kayobe/kolla.yml +++ b/etc/kayobe/kolla.yml @@ -61,7 +61,8 @@ ############################################################################### # Kolla configuration. -# Kolla base container image distribution. Default is 'centos'. +# Kolla base container image distribution. Options are "centos", "debian", +# "ubuntu". Default is {{ os_distribution }}. #kolla_base_distro: # Kolla container image type: binary or source. Default is 'binary'. diff --git a/etc/kayobe/seed-hypervisor.yml b/etc/kayobe/seed-hypervisor.yml index 1ef898893..b14c82344 100644 --- a/etc/kayobe/seed-hypervisor.yml +++ b/etc/kayobe/seed-hypervisor.yml @@ -3,7 +3,7 @@ # Seed hypervisor node configuration. # User with which to access the seed hypervisor via SSH during bootstrap, in -# order to setup the Kayobe user account. +# order to setup the Kayobe user account. Default is {{ os_distribution }}. #seed_hypervisor_bootstrap_user: ############################################################################### diff --git a/etc/kayobe/seed-vm.yml b/etc/kayobe/seed-vm.yml index 0c4f89887..9ad7a7438 100644 --- a/etc/kayobe/seed-vm.yml +++ b/etc/kayobe/seed-vm.yml @@ -24,7 +24,10 @@ #seed_vm_root_format: # Base image for the seed VM root volume. Default is +# "https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img" +# when os_distribution is "ubuntu", or # "https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20210210.0.x86_64.qcow2" +# otherwise. #seed_vm_root_image: # Capacity of the seed VM data volume. diff --git a/etc/kayobe/seed.yml b/etc/kayobe/seed.yml index 88efbcc7b..35f2aadaa 100644 --- a/etc/kayobe/seed.yml +++ b/etc/kayobe/seed.yml @@ -3,7 +3,7 @@ # Seed node configuration. # User with which to access the seed via SSH during bootstrap, in order to -# setup the Kayobe user account. +# setup the Kayobe user account. Default is {{ os_distribution }}. #seed_bootstrap_user: ############################################################################### diff --git a/etc/kayobe/storage.yml b/etc/kayobe/storage.yml index c8ee66f62..47f63dbaa 100644 --- a/etc/kayobe/storage.yml +++ b/etc/kayobe/storage.yml @@ -3,7 +3,7 @@ # Storage node configuration. # User with which to access the storages via SSH during bootstrap, in order -# to setup the Kayobe user account. +# to setup the Kayobe user account. Default is {{ os_distribution }}. #storage_bootstrap_user: ############################################################################### diff --git a/releasenotes/notes/os-distribution-69445eb19a611d43.yaml b/releasenotes/notes/os-distribution-69445eb19a611d43.yaml new file mode 100644 index 000000000..69c1f8816 --- /dev/null +++ b/releasenotes/notes/os-distribution-69445eb19a611d43.yaml @@ -0,0 +1,14 @@ +--- +features: + - | + Adds an ``os_distribution`` variable in ``etc/kayobe/globals.yml``, with a + default value of ``centos``. The variable can also be set to ``ubuntu``, + and sets sensible default values for other variables. +upgrade: + - | + Modifies the default value of ``controller_bootstrap_user``, + ``compute_bootstrap_user``, ``seed_bootstrap_user``, + ``seed_hypervisor_bootstrap_user`` and ``storage_bootstrap_user`` from + using the ``$USER`` environment variable of the Ansible control host to + ``os_distribution``. This provides a more predictable default that does not + depend on the Ansible execution environment.