Refactor EDPM job
This patch looks huge, so let's split things in the following listing: - rename role to match the naming convention - role name shouldn't get hyphen, so let's use underscores instead. Playbooks don't need to follow this rule. This should make the role more portable in the future. - modify role - "disable" the main.yml - we must call specific task file. - no more condioned deploy based on variables. Makes it easier to follow and maintain. - update how the edpm inventory is edited - use plain YAML - output plain YAML - this format is consistent with latest changes in tripleo-ansible[1] These changes make the overall role easier to understand and maintain, while ensuring the playbook is also easier to read. It may also make the deploy a bit faster with the new way to run the various tasks. - update playbook - boostrap both nodes in a 2-stages way (check comment as to why). - deploy compute from the undercloud (mimic what an operator would do) - validate the compute from the undercloud (no actual change here) - target specific task_file during the different stages. It's easier to understand what's going on in there These changes should allow a better understanding of the overall playbook. - update edpm deploy script to use an environment file instead of CLI params - this makes the script lighter and easier to understand - adding new parameters in the env file is easier - reading the env file for debugging is better [1] https://review.opendev.org/c/openstack/tripleo-ansible/+/869357 Change-Id: I263f424a5a08214b9c46c5ea73b6b428709ad47b
This commit is contained in:
parent
8c8d3d557a
commit
5c22039cd0
@ -1,45 +1,50 @@
|
|||||||
---
|
---
|
||||||
# This playbook does:
|
# First, deploy the undercloud. This will also ensure the inventory is properly
|
||||||
# - On undercloud node
|
# populated with the subnode-1 host and all the needed data.
|
||||||
# + it bootstrap the node and deploy standalone
|
|
||||||
# + Generate 99 standalone vars and copy it to
|
|
||||||
# subnode-1
|
|
||||||
#
|
|
||||||
- hosts: undercloud
|
- hosts: undercloud
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
tags:
|
tags:
|
||||||
- standalone
|
- standalone
|
||||||
vars:
|
|
||||||
deploy_standalone: true
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Run External Data Plane management role
|
- name: Run External Data Plane management role
|
||||||
include_role:
|
include_role:
|
||||||
name: external-data-plane-management
|
name: external_data_plane_management
|
||||||
|
tasks_from: prepare_node.yml
|
||||||
|
|
||||||
# On subnode-1
|
# Now that we have the updated inventory, we can get to subnode-1 using the
|
||||||
# It bootstrap the node and install required packages
|
# correct data. Let's bootstrap it!
|
||||||
# copy 99 standalone vars to tripleo inventory
|
|
||||||
# Deploy compute services
|
|
||||||
- hosts: subnode-1
|
- hosts: subnode-1
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
tags:
|
tags:
|
||||||
- standalone
|
- standalone
|
||||||
vars:
|
|
||||||
deploy_standalone: false
|
|
||||||
copy_inventory: true
|
|
||||||
target_host: subnode-1
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Run External Data Plane management role
|
- name: Run External Data Plane management role
|
||||||
include_role:
|
include_role:
|
||||||
name: external-data-plane-management
|
name: external_data_plane_management
|
||||||
|
tasks_from: prepare_node.yml
|
||||||
|
|
||||||
# On Controller node
|
# On undercloud:
|
||||||
# Run validate_external_compute.sh
|
# + Deploy standalone
|
||||||
|
# + Deploy the external compute from within the undercloud
|
||||||
|
# + Validate external compute
|
||||||
- hosts: undercloud
|
- hosts: undercloud
|
||||||
gather_facts: true
|
gather_facts: false
|
||||||
tags:
|
tags:
|
||||||
- standalone
|
- standalone
|
||||||
tasks:
|
tasks:
|
||||||
- include_role:
|
- name: Deploy standalone
|
||||||
name: external-data-plane-management
|
include_role:
|
||||||
|
name: external_data_plane_management
|
||||||
|
tasks_from: deploy_standalone.yml
|
||||||
|
- name: Deploy remote compute
|
||||||
|
vars:
|
||||||
|
target_host: 'subnode-1'
|
||||||
|
include_role:
|
||||||
|
name: external_data_plane_management
|
||||||
|
tasks_from: compute_services_on_target_host.yml
|
||||||
|
- name: Validate EDPM deploy
|
||||||
|
vars:
|
||||||
|
target_host: 'subnode-1'
|
||||||
|
include_role:
|
||||||
|
name: external_data_plane_management
|
||||||
tasks_from: validate_edpm.yml
|
tasks_from: validate_edpm.yml
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
# It contains following tasks:
|
|
||||||
# - Set hostname for target node
|
|
||||||
# - Run repo-setup role to enable specific release files
|
|
||||||
# - Build depends-on changes using build-test-packages and enable gating repo
|
|
||||||
# to install built packages from gating repo
|
|
||||||
# - Install tripleo-ansible and its required dependencies
|
|
||||||
# - Copy standalone env vars to subnode-1
|
|
||||||
# - Change localhost to target hostname
|
|
||||||
# - Deploy compute services.
|
|
||||||
|
|
||||||
- name: Install Required packages
|
|
||||||
become: true
|
|
||||||
package:
|
|
||||||
name:
|
|
||||||
- ansible-collection-containers-podman
|
|
||||||
- python3-tenacity
|
|
||||||
- tripleo-ansible
|
|
||||||
- ansible-role-chrony
|
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Copy 99 standalone var from controller to compute node
|
|
||||||
copy:
|
|
||||||
src: "/home/{{ ansible_user }}/99-standalone-vars"
|
|
||||||
dest: "/usr/share/ansible/tripleo-inventory/99-standalone-vars"
|
|
||||||
become: true
|
|
||||||
when: copy_inventory | default('false') | bool
|
|
||||||
|
|
||||||
- name: Change localhost name to target host
|
|
||||||
become: true
|
|
||||||
lineinfile:
|
|
||||||
path: "/usr/share/ansible/tripleo-inventory/02-computes"
|
|
||||||
search_string: 'localhost:'
|
|
||||||
# 4 spaces is added to place at proper hostname position
|
|
||||||
# TODO(chkumar): Explore inifile module to manipulate yaml
|
|
||||||
# file later.
|
|
||||||
line: " {{ target_host }}:"
|
|
||||||
|
|
||||||
- name: Rename the host_vars file to target host
|
|
||||||
become: true
|
|
||||||
copy:
|
|
||||||
src: "/usr/share/ansible/tripleo-inventory/host_vars/localhost"
|
|
||||||
dest: "/usr/share/ansible/tripleo-inventory/host_vars/{{ target_host }}"
|
|
||||||
|
|
||||||
- name: Remove the old file
|
|
||||||
become: true
|
|
||||||
file:
|
|
||||||
path: "/usr/share/ansible/tripleo-inventory/host_vars/localhost"
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Generate deploy_compute.sh script
|
|
||||||
template:
|
|
||||||
src: deploy_compute.sh.j2
|
|
||||||
dest: "{{ working_dir }}/deploy_compute.sh"
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
- name: Run deploy_compute.sh script
|
|
||||||
shell: >
|
|
||||||
set -o pipefail &&
|
|
||||||
{{ working_dir }}/deploy_compute.sh
|
|
||||||
2>&1 {{ timestamper_cmd }} > {{ working_dir }}/deploy_compute.log
|
|
@ -1,24 +0,0 @@
|
|||||||
---
|
|
||||||
# This Playbook does the following things in order
|
|
||||||
|
|
||||||
# prepare_node.yml
|
|
||||||
# * It will run on both controller and compute node.
|
|
||||||
# - Add the host to tripleo-inventory
|
|
||||||
# - Run undercloud-setup
|
|
||||||
- import_tasks: prepare_node.yml
|
|
||||||
|
|
||||||
# deploy_standalone.yml
|
|
||||||
# * It will run on controller node
|
|
||||||
# - Deploy Standalone
|
|
||||||
# - Generate 99 standalone vars
|
|
||||||
- import_tasks: deploy_standalone.yml
|
|
||||||
when: deploy_standalone | bool
|
|
||||||
|
|
||||||
# compute_services_on_target_host.yml
|
|
||||||
# * It will run on target node.
|
|
||||||
# - Install the tripleo-ansible dependencies on target node
|
|
||||||
# - Copy 99 standalone vars from controller to
|
|
||||||
# compute node inventory
|
|
||||||
# - Deploy compute services on target node
|
|
||||||
- import_tasks: compute_services_on_target_host.yml
|
|
||||||
when: not deploy_standalone | bool
|
|
@ -1,19 +0,0 @@
|
|||||||
sudo ansible-playbook -i /usr/share/ansible/tripleo-inventory \
|
|
||||||
-e tripleo_iscsid_image={{ tripleo_iscsid_image }} \
|
|
||||||
-e tripleo_logrotate_crond_image={{ tripleo_logrotate_crond_image }} \
|
|
||||||
-e tripleo_nova_compute_container_image={{ tripleo_nova_compute_container_image }} \
|
|
||||||
-e tripleo_nova_libvirt_container_image={{ tripleo_nova_libvirt_container_image }} \
|
|
||||||
-e tripleo_ovn_controller_image={{ tripleo_ovn_controller_image }} \
|
|
||||||
-e tripleo_selinux_mode={{ tripleo_selinux_mode }} \
|
|
||||||
-e neutron_public_interface_name={{ neutron_public_interface_name }} \
|
|
||||||
-e tripleo_network_config_template={{ tripleo_network_config_template }} \
|
|
||||||
-e '{ctlplane_dns_nameservers: {{ ctlplane_dns_nameservers }}}' \
|
|
||||||
-e '{tripleo_container_registry_insecure_registries: {{ tripleo_container_registry_insecure_registries }}}' \
|
|
||||||
-e '{tripleo_hosts_entries_overcloud_hosts_entries: {{ tripleo_hosts_entries_overcloud_hosts_entries|to_json }}}' \
|
|
||||||
{% if not copy_inventory | bool %}
|
|
||||||
-e '{dns_search_domains: {{ dns_search_domains }}}' \
|
|
||||||
-e '{tripleo_ovn_dbs: {{ tripleo_ovn_dbs }}}' \
|
|
||||||
{% else %}
|
|
||||||
-e ctlplane_ip={{ ctlplane_ip }} \
|
|
||||||
{% endif %}
|
|
||||||
/usr/share/ansible/tripleo-playbooks/deploy-overcloud-compute.yml
|
|
@ -5,13 +5,11 @@ tripleo_logrotate_crond_image: "{{ docker_registry_host }}/{{ docker_registry_na
|
|||||||
tripleo_nova_compute_container_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-nova-compute:{{ docker_image_tag }}"
|
tripleo_nova_compute_container_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-nova-compute:{{ docker_image_tag }}"
|
||||||
tripleo_nova_libvirt_container_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-nova-libvirt:{{ docker_image_tag }}"
|
tripleo_nova_libvirt_container_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-nova-libvirt:{{ docker_image_tag }}"
|
||||||
tripleo_ovn_controller_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-ovn-controller:{{ docker_image_tag }}"
|
tripleo_ovn_controller_image: "{{ docker_registry_host }}/{{ docker_registry_namespace }}/openstack-ovn-controller:{{ docker_image_tag }}"
|
||||||
deploy_standalone: false
|
|
||||||
|
|
||||||
# tripleo-standalone-vars script related vars
|
# tripleo-standalone-vars script related vars
|
||||||
tripleo_standalone_vars: "/home/{{ ansible_user }}/src/opendev.org/openstack/tripleo-ansible/scripts/tripleo-standalone-vars"
|
tripleo_standalone_vars: "/home/{{ ansible_user }}/src/opendev.org/openstack/tripleo-ansible/scripts/tripleo-standalone-vars"
|
||||||
config_download_dir: "/home/{{ ansible_user }}/tripleo-deploy"
|
config_download_dir: "/home/{{ ansible_user }}/tripleo-deploy"
|
||||||
role_type: "Standalone"
|
role_type: "Standalone"
|
||||||
copy_inventory: false
|
|
||||||
target_host: undercloud
|
target_host: undercloud
|
||||||
|
|
||||||
timestamper_cmd: >-
|
timestamper_cmd: >-
|
@ -0,0 +1,96 @@
|
|||||||
|
---
|
||||||
|
# It contains following tasks:
|
||||||
|
# - Set hostname for target node
|
||||||
|
# - Copy standalone env vars to subnode-1
|
||||||
|
# - Change localhost to target hostname
|
||||||
|
# - Deploy compute services.
|
||||||
|
|
||||||
|
- name: Copy id_rsa key to working_dir
|
||||||
|
become: true
|
||||||
|
copy:
|
||||||
|
src: /etc/nodepool/id_rsa
|
||||||
|
dest: "{{ working_dir }}/.ssh/edpm_rsa"
|
||||||
|
owner: "{{ ansible_user }}"
|
||||||
|
mode: 0600
|
||||||
|
|
||||||
|
- name: Copy tripleo-inventory as EDPM env
|
||||||
|
become: true
|
||||||
|
copy:
|
||||||
|
src: /usr/share/ansible/tripleo-inventory/
|
||||||
|
dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/"
|
||||||
|
remote_src: true
|
||||||
|
directory_mode: 0755
|
||||||
|
owner: "{{ ansible_user }}"
|
||||||
|
|
||||||
|
- name: Copy 99 standalone var into EDPM inventory
|
||||||
|
copy:
|
||||||
|
src: "{{ working_dir }}/99-standalone-vars"
|
||||||
|
dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/99-standalone-vars"
|
||||||
|
remote_src: true
|
||||||
|
|
||||||
|
- name: Manipulate inventory
|
||||||
|
block:
|
||||||
|
- name: Get subnode IP
|
||||||
|
register: subnode_ip
|
||||||
|
slurp:
|
||||||
|
path: /etc/nodepool/sub_nodes
|
||||||
|
|
||||||
|
- name: Get inventory content
|
||||||
|
register: original_inventory
|
||||||
|
slurp:
|
||||||
|
path: "{{ working_dir }}/tripleo-deploy/edpm-inventory/02-computes"
|
||||||
|
|
||||||
|
- name: Set inventory host content
|
||||||
|
set_fact:
|
||||||
|
inventory_hosts: |
|
||||||
|
{
|
||||||
|
hosts: {
|
||||||
|
{{ target_host }}: {
|
||||||
|
ansible_host: "{{ subnode_ip['content']|b64decode|trim }}",
|
||||||
|
ansible_ssh_private_key_file: '{{ working_dir }}/.ssh/edpm_rsa',
|
||||||
|
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Update inventory content
|
||||||
|
set_fact:
|
||||||
|
updated_inventory: >-
|
||||||
|
{%- set _inventory = original_inventory['content']|b64decode|from_yaml %}
|
||||||
|
{%- set _hosts = inventory_hosts |from_yaml %}
|
||||||
|
{%- set _ = _inventory['Compute'].update( _hosts ) %}
|
||||||
|
{{ _inventory }}
|
||||||
|
|
||||||
|
- name: Output new inventory as clean yaml
|
||||||
|
copy:
|
||||||
|
dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/02-computes"
|
||||||
|
content: "{{ updated_inventory | from_yaml | to_nice_yaml }}"
|
||||||
|
|
||||||
|
- name: Rename the host_vars file to target host
|
||||||
|
copy:
|
||||||
|
src: "{{ working_dir }}/tripleo-deploy/edpm-inventory/host_vars/localhost"
|
||||||
|
dest: "{{ working_dir }}/tripleo-deploy/edpm-inventory/host_vars/{{ target_host }}"
|
||||||
|
remote_src: true
|
||||||
|
|
||||||
|
- name: Remove the old file
|
||||||
|
file:
|
||||||
|
path: "{{ working_dir }}/tripleo-deploy/edpm-inventory/host_vars/localhost"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Generate parameter file for deploy_compute task
|
||||||
|
template:
|
||||||
|
src: compute-parameter.yaml.j2
|
||||||
|
dest: "{{ working_dir }}/edpm-compute-parameter.yaml"
|
||||||
|
mode: 0644
|
||||||
|
|
||||||
|
- name: Generate deploy_compute.sh script
|
||||||
|
template:
|
||||||
|
src: deploy_compute.sh.j2
|
||||||
|
dest: "{{ working_dir }}/deploy_compute.sh"
|
||||||
|
mode: 0755
|
||||||
|
|
||||||
|
- name: Run deploy_compute.sh script
|
||||||
|
shell: >
|
||||||
|
set -o pipefail &&
|
||||||
|
{{ working_dir }}/deploy_compute.sh
|
||||||
|
2>&1 {{ timestamper_cmd }} > {{ working_dir }}/deploy_compute.log
|
4
roles/external_data_plane_management/tasks/main.yml
Normal file
4
roles/external_data_plane_management/tasks/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
- name: Do not do anything
|
||||||
|
fail:
|
||||||
|
msg: "This role doesn't do anything unless you include a specific task file"
|
@ -6,7 +6,7 @@
|
|||||||
include_role:
|
include_role:
|
||||||
name: tripleo-inventory
|
name: tripleo-inventory
|
||||||
|
|
||||||
- name: Prepare the node for installation
|
- name: Prepare nodes with repositories and custom builds
|
||||||
include_role:
|
include_role:
|
||||||
name: undercloud-setup
|
name: undercloud-setup
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
dest: "{{ working_dir }}/validate_external_compute.sh"
|
dest: "{{ working_dir }}/validate_external_compute.sh"
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: Run deploy_compute.sh script
|
- name: Run validate_external_compute.sh script
|
||||||
shell: >
|
shell: >
|
||||||
set -o pipefail &&
|
set -o pipefail &&
|
||||||
{{ working_dir }}/validate_external_compute.sh
|
{{ working_dir }}/validate_external_compute.sh
|
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
# Parameter file for the deploy-overcloud-compute.yml playbook
|
||||||
|
|
||||||
|
ctlplane_ip: "{{ ctlplane_ip }}"
|
||||||
|
tripleo_iscsid_image: "{{ tripleo_iscsid_image }}"
|
||||||
|
tripleo_logrotate_crond_image: "{{ tripleo_logrotate_crond_image }}"
|
||||||
|
tripleo_nova_compute_container_image: "{{ tripleo_nova_compute_container_image }}"
|
||||||
|
tripleo_nova_libvirt_container_image: "{{ tripleo_nova_libvirt_container_image }}"
|
||||||
|
tripleo_ovn_controller_image: "{{ tripleo_ovn_controller_image }}"
|
||||||
|
tripleo_selinux_mode: "{{ tripleo_selinux_mode }}"
|
||||||
|
neutron_public_interface_name: "{{ neutron_public_interface_name }}"
|
||||||
|
tripleo_network_config_template: "{{ tripleo_network_config_template }}"
|
||||||
|
ctlplane_dns_nameservers: {{ ctlplane_dns_nameservers }}
|
||||||
|
tripleo_container_registry_insecure_registries: {{ tripleo_container_registry_insecure_registries }}
|
||||||
|
tripleo_hosts_entries_overcloud_hosts_entries: {{ tripleo_hosts_entries_overcloud_hosts_entries|to_json }}
|
||||||
|
# For now, don't load firewall
|
||||||
|
deploy_tripleo_openstack_run_firewall: false
|
||||||
|
tripleo_sshd_configure_firewall: true
|
@ -0,0 +1,3 @@
|
|||||||
|
sudo ansible-playbook -i {{ working_dir }}/tripleo-deploy/edpm-inventory \
|
||||||
|
-e @{{ working_dir }}/edpm-compute-parameter.yaml \
|
||||||
|
/usr/share/ansible/tripleo-playbooks/deploy-overcloud-compute.yml
|
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# {{ target_host }}
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
# Discover new compute nodes
|
# Discover new compute nodes
|
||||||
@ -8,6 +8,16 @@ sudo podman exec -it nova_api nova-manage cell_v2 discover_hosts --verbose
|
|||||||
# Export standalone cloud
|
# Export standalone cloud
|
||||||
export OS_CLOUD=standalone
|
export OS_CLOUD=standalone
|
||||||
|
|
||||||
|
# Export some needed variables
|
||||||
|
export GATEWAY='{{ tempest_cidr|nthhost(1) }}'
|
||||||
|
export PUBLIC_NETWORK_CIDR='{{ tempest_cidr }}'
|
||||||
|
export PRIVATE_NETWORK_CIDR=192.168.74.0/28
|
||||||
|
export PUBLIC_NET_START='{{ tempest_cidr|nthhost(150) }}'
|
||||||
|
export PUBLIC_NET_END='{{ tempest_cidr|nthhost(200) }}'
|
||||||
|
export DNS_SERVER=1.1.1.1
|
||||||
|
export HYPER='{{ hostvars[target_host].ansible_fqdn }}'
|
||||||
|
export INSTANCE_NAME=myserver-$HYPER
|
||||||
|
|
||||||
# List Available Zones
|
# List Available Zones
|
||||||
openstack availability zone list
|
openstack availability zone list
|
||||||
|
|
||||||
@ -25,15 +35,6 @@ openstack network agent list
|
|||||||
|
|
||||||
# Steps to validate host
|
# Steps to validate host
|
||||||
# copied from https://github.com/fultonj/zed/blob/main/standalone/verify.sh
|
# copied from https://github.com/fultonj/zed/blob/main/standalone/verify.sh
|
||||||
export GATEWAY='{{ tempest_cidr|nthhost(1) }}'
|
|
||||||
export PUBLIC_NETWORK_CIDR='{{ tempest_cidr }}'
|
|
||||||
export PRIVATE_NETWORK_CIDR=192.168.74.0/28
|
|
||||||
export PUBLIC_NET_START='{{ tempest_cidr|nthhost(150) }}'
|
|
||||||
export PUBLIC_NET_END='{{ tempest_cidr|nthhost(200) }}'
|
|
||||||
export DNS_SERVER=1.1.1.1
|
|
||||||
export HYPER='{{ hostvars['subnode-1'].ansible_fqdn }}'
|
|
||||||
export INSTANCE_NAME=myserver-$HYPER
|
|
||||||
|
|
||||||
|
|
||||||
openstack keypair create --private-key ~/test_key default
|
openstack keypair create --private-key ~/test_key default
|
||||||
openstack keypair list
|
openstack keypair list
|
Loading…
Reference in New Issue
Block a user