Refactor Ansible sysinv data collection

This commit refactors ansible to use the sysinv-utils for generating
overrides files. It also updates CLIs to use command arguments
instead of using grep/awk. The current model can easily beak if for
example a column is added to the outputted data.

Story: 2006590
Task: 36892
Depends-On: https://review.opendev.org/693213/
Signed-off-by: Kristine Bujold <kristine.bujold@windriver.com>
Change-Id: Ife65cd95c0f7c0ec431a9298965acab50aac11d7
This commit is contained in:
Kristine Bujold 2019-11-06 11:23:19 -05:00
parent 164e8d6a37
commit cbd597f395
10 changed files with 67 additions and 348 deletions

View File

@ -1,2 +1,2 @@
SRC_DIR="src"
TIS_PATCH_VER=6
TIS_PATCH_VER=7

View File

@ -135,22 +135,17 @@
when: check_mariadb_pod.rc == 0
- block:
- name: Check if stx-openstack is applied
shell: >-
source /etc/platform/openrc; system application-list | grep stx-openstack | grep applied
failed_when: false
register: check_openstack_applied
- name: Check if stx-openstack is uploaded
- name: Get stx-openstack status
shell: >-
source /etc/platform/openrc; system application-list | grep stx-openstack | grep uploaded
source /etc/platform/openrc; system application-show stx-openstack --column status --format value
failed_when: false
register: check_openstack_uploaded
register: openstack_status
- name: Fail the backup if MariaDB is not running
fail:
msg: "WARNING: {{ mariadb_pod }} is not running. Cannot backup mariadb data."
when: check_openstack_applied.rc == 0
when: openstack_status.stdout == "applied"
when: check_mariadb_pod.rc != 0
# Now Postgres data and MariaDB data are stored in staging dir, we can estimate
@ -230,233 +225,12 @@
set_fact:
override_backup_file: "{{ override_dir.path }}/{{ host_override_backup_file }}"
- name: Retrieve dns_servers from sysinv db
shell: "source /etc/platform/openrc; system dns-show | grep nameservers | awk '{print $4}'"
register: dns_servers
- name: Create the override backup file
command: "/usr/bin/sysinv-utils create-host-overrides {{ override_backup_file }}"
failed_when: result.stderr != ""
register: result
- name: Create and write dns_servers into override backup file
lineinfile:
dest: "{{ override_backup_file }}"
line: "dns_servers:"
create: yes
- name: Write each dns server into override backup file
lineinfile:
dest: "{{ override_backup_file }}"
line: " - {{ item }}"
with_items: "{{ dns_servers.stdout.split(',') }}"
- name: Query addrpool in sysinv db
shell:
source /etc/platform/openrc; system addrpool-list --nowrap > {{ tempdir.path }}/addrpool.txt
- name: Retrieve pxeboot_subnet from sysinv db
shell: "grep pxeboot {{ tempdir.path }}/addrpool.txt | awk '{print $6\"/\"$8}'"
register: pxeboot_subnet
- name: Retrieve pxeboot_start_address from sysinv db
shell:
"grep pxeboot {{ tempdir.path }}/addrpool.txt | awk 'match($12, /-/) {print substr($12, 3, RSTART-3)}'"
register: pxeboot_start_address
- name: Retrieve pxeboot_end_address from sysinv db
shell: >-
grep pxeboot {{ tempdir.path }}/addrpool.txt |
awk 'split($12, array, "-") {print substr(array[2], 1, length(array[2])-2)}'
register: pxeboot_end_address
- name: Retrieve pxeboot_floating_address from sysinv db
shell: "grep pxeboot {{ tempdir.path }}/addrpool.txt | awk '{print $14}'"
register: pxeboot_floating_address
- name: Retrieve pxeboot_controller0_address from sysinv db
shell: "grep pxeboot {{ tempdir.path }}/addrpool.txt | awk '{print $16}'"
register: pxeboot_controller0_address
- name: Retrieve pxeboot_controller1_address from sysinv db
shell: "grep pxeboot {{ tempdir.path }}/addrpool.txt | awk '{print $18}'"
register: pxeboot_controller1_address
- name: Retrieve management_subnet from sysinv db
shell: "grep management {{ tempdir.path }}/addrpool.txt | awk '{print $6\"/\"$8}'"
register: management_subnet
- name: Retrieve management_start_address from sysinv db
shell:
"grep management {{ tempdir.path }}/addrpool.txt | awk 'match($12, /-/) {print substr($12, 3, RSTART-3)}'"
register: management_start_address
- name: Retrieve management_end_address from sysinv db
shell: >-
grep management {{ tempdir.path }}/addrpool.txt |
awk 'split($12, array, "-") {print substr(array[2], 1, length(array[2])-2)}'
register: management_end_address
- name: Retrieve management_floating_address from sysinv db
shell: "grep management {{ tempdir.path }}/addrpool.txt | awk '{print $14}'"
register: management_floating_address
- name: Retrieve management_controller0_address from sysinv db
shell: "grep management {{ tempdir.path }}/addrpool.txt | awk '{print $16}'"
register: management_controller0_address
- name: Retrieve management_controller1_address from sysinv db
shell: "grep management {{ tempdir.path }}/addrpool.txt | awk '{print $18}'"
register: management_controller1_address
- name: Retrieve management_multicast_subnet from sysinv db
shell: "grep multicast-subnet {{ tempdir.path }}/addrpool.txt | awk '{print $6\"/\"$8}'"
register: management_multicast_subnet
- name: Retrieve management_multicast_start_address from sysinv db
shell:
"grep multicast-subnet {{ tempdir.path }}/addrpool.txt | awk 'match($12, /-/) {print substr($12, 3, RSTART-3)}'"
register: management_multicast_start_address
- name: Retrieve management_multicast_end_address from sysinv db
shell: >-
grep multicast-subnet {{ tempdir.path }}/addrpool.txt |
awk 'split($12, array, "-") {print substr(array[2], 1, length(array[2])-2)}'
register: management_multicast_end_address
- name: Retrieve cluster_host_subnet from sysinv db
shell:
"grep cluster-host-subnet {{ tempdir.path }}/addrpool.txt | awk '{print $6\"/\"$8}'"
register: cluster_host_subnet
- name: Retrieve cluster_host_start_address from sysinv db
shell:
"grep cluster-host-subnet {{ tempdir.path }}/addrpool.txt | awk 'match($12, /-/) {print substr($12, 3, RSTART-3)}'"
register: cluster_host_start_address
- name: Retrieve cluster_host_end_address from sysinv db
shell: >-
grep cluster-host-subnet {{ tempdir.path }}/addrpool.txt |
awk 'split($12, array, "-") {print substr(array[2], 1, length(array[2])-2)}'
register: cluster_host_end_address
- name: Retrieve cluster_host_floating_address from sysinv db
shell: "grep cluster-host-subnet {{ tempdir.path }}/addrpool.txt | awk '{print $14}'"
register: cluster_host_floating_address
- name: Retrieve cluster_host_controller0_address from sysinv db
shell: "grep cluster-host-subnet {{ tempdir.path }}/addrpool.txt | awk '{print $16}'"
register: cluster_host_controller0_address
- name: Retrieve cluster_host_controller1_address from sysinv db
shell: "grep cluster-host-subnet {{ tempdir.path }}/addrpool.txt | awk '{print $18}'"
register: cluster_host_controller1_address
- name: Retrieve cluster_pod_subnet from sysinv db
shell: "grep cluster-pod-subnet {{ tempdir.path }}/addrpool.txt | awk '{print $6\"/\"$8}'"
register: cluster_pod_subnet
- name: Retrieve cluster_pod_start_address from sysinv db
shell:
"grep cluster-pod-subnet {{ tempdir.path }}/addrpool.txt | awk 'match($12, /-/) {print substr($12, 3, RSTART-3)}'"
register: cluster_pod_start_address
- name: Retrieve cluster_pod_end_address from sysinv db
shell: >-
grep cluster-pod-subnet {{ tempdir.path }}/addrpool.txt |
awk 'split($12, array, "-") {print substr(array[2], 1, length(array[2])-2)}'
register: cluster_pod_end_address
- name: Retrieve cluster_service_subnet from sysinv db
shell: "grep cluster-service-subnet {{ tempdir.path }}/addrpool.txt | awk '{print $6\"/\"$8}'"
register: cluster_service_subnet
- name: Retrieve cluster_service_start_address from sysinv db
shell:
grep cluster-service-subnet {{ tempdir.path }}/addrpool.txt | awk 'match($12, /-/) {print substr($12, 3, RSTART-3)}'
register: cluster_service_start_address
- name: Retrieve cluster_service_end_address from sysinv db
shell: >-
grep cluster-service-subnet {{ tempdir.path }}/addrpool.txt |
awk 'split($12, array, "-") {print substr(array[2], 1, length(array[2])-2)}'
register: cluster_service_end_address
- name: Retrieve external_oam_subnet from sysinv db
shell: "grep oam {{ tempdir.path }}/addrpool.txt | awk '{print $6\"/\"$8}'"
register: external_oam_subnet
- name: Retrieve external_oam_start_address from sysinv db
shell:
"grep oam {{ tempdir.path }}/addrpool.txt | awk 'match($12, /-/) {print substr($12, 3, RSTART-3)}'"
register: external_oam_start_address
- name: Retrieve external_oam_end_address from sysinv db
shell: >-
grep oam {{ tempdir.path }}/addrpool.txt |
awk 'split($12, array, "-") {print substr(array[2], 1, length(array[2])-2)}'
register: external_oam_end_address
- name: Retrieve external_oam_gateway_address from sysinv db
shell: "grep oam {{ tempdir.path }}/addrpool.txt | awk '{print $20}'"
register: external_oam_gateway_address
- name: Retrieve external_oam_floating_address from sysinv db
shell: "grep oam {{ tempdir.path }}/addrpool.txt | awk '{print $14}'"
register: external_oam_floating_address
- block:
- name: Retrieve external_oam_controller0_address from sysinv db
shell: "grep oam {{ tempdir.path }}/addrpool.txt | awk '{print $16}'"
register: external_oam_controller0_address
- name: Retrieve external_oam_controller1_address from sysinv db
shell: "grep oam {{ tempdir.path }}/addrpool.txt | awk '{print $18}'"
register: external_oam_controller1_address
when: system_mode != 'simplex'
- name: Write entries to override backup file
lineinfile:
dest: "{{ override_backup_file }}"
line: "{{ item }}"
with_items:
- "pxeboot_subnet: {{ pxeboot_subnet.stdout }}"
- "pxeboot_start_address: {{ pxeboot_start_address.stdout }}"
- "pxeboot_end_address: {{ pxeboot_end_address.stdout }}"
- "pxeboot_floating_address: {{ pxeboot_floating_address.stdout }}"
- "pxeboot_node_0_address: {{ pxeboot_controller0_address.stdout }}"
- "pxeboot_node_1_address: {{ pxeboot_controller1_address.stdout }}"
- "management_subnet: {{ management_subnet.stdout }}"
- "management_start_address: {{ management_start_address.stdout }}"
- "management_end_address: {{ management_end_address.stdout }}"
- "management_floating_address: {{ management_floating_address.stdout }}"
- "management_node_0_address: {{ management_controller0_address.stdout }}"
- "management_node_1_address: {{ management_controller1_address.stdout }}"
- "management_multicast_subnet: {{ management_multicast_subnet.stdout }}"
- "management_multicast_start_address: {{ management_multicast_start_address.stdout }}"
- "management_multicast_end_address: {{ management_multicast_end_address.stdout }}"
- "cluster_host_subnet: {{ cluster_host_subnet.stdout }}"
- "cluster_host_start_address: {{ cluster_host_start_address.stdout }}"
- "cluster_host_end_address: {{ cluster_host_end_address.stdout }}"
- "cluster_host_floating_address: {{ cluster_host_floating_address.stdout }}"
- "cluster_host_node_0_address: {{ cluster_host_controller0_address.stdout }}"
- "cluster_host_node_1_address: {{ cluster_host_controller1_address.stdout }}"
- "cluster_pod_subnet: {{ cluster_pod_subnet.stdout }}"
- "cluster_pod_start_address: {{ cluster_pod_start_address.stdout }}"
- "cluster_pod_end_address: {{ cluster_pod_end_address.stdout }}"
- "cluster_service_subnet: {{ cluster_service_subnet.stdout }}"
- "cluster_sevice_start_address: {{ cluster_service_start_address.stdout }}"
- "cluster_service_end_address: {{ cluster_service_end_address.stdout }}"
- "external_oam_subnet: {{ external_oam_subnet.stdout }}"
- "external_oam_start_address: {{ external_oam_start_address.stdout }}"
- "external_oam_end_address: {{ external_oam_end_address.stdout }}"
- "external_oam_gateway_address: {{ external_oam_gateway_address.stdout }}"
- "external_oam_floating_address: {{ external_oam_floating_address.stdout }}"
- name: Write external_oam_node_x_address to override backup file
lineinfile:
dest: "{{ override_backup_file }}"
line: "{{ item }}"
with_items:
- "external_oam_node_0_address: {{ external_oam_controller0_address.stdout }}"
- "external_oam_node_1_address: {{ external_oam_controller1_address.stdout }}"
when: system_mode != 'simplex'
- debug: var=result.stdout
- name: Get docker registries information
include_role:
@ -469,47 +243,6 @@
marker: ""
block: "{{ registries|default({}) | to_nice_yaml(indent=2) }}"
- name: Check if docker no-proxy exists
shell: >-
grep -w no_proxy {{ tempdir.path }}/docker.txt |
awk '{if ($8=="no_proxy") print $10}'
register: docker_no_proxy
failed_when: false
- block:
- name: Write no_proxy into override backup file
lineinfile:
dest: "{{ override_backup_file }}"
line: "docker_no_proxy:"
- name: Write each no_proxy address into override backup file
lineinfile:
dest: "{{ override_backup_file }}"
line: " - {{ item }}"
with_items: "{{ docker_no_proxy.stdout.split(',') }}"
- name: Remove the open and close parenthesis around IPV6 address
command: sed -i -e 's/[][]//g' {{ override_backup_file }}
args:
warn: false
when: docker_no_proxy.stdout != ""
- name: Look for docker proxy entries
shell: >-
grep -w proxy {{ tempdir.path }}/docker.txt | grep -w -v no_proxy |
awk '{if ($6=="proxy") print "docker_" $8 ": " $10}'
register: check_docker_proxy
failed_when: false
- block:
- name: Write docker proxy to override backup file
lineinfile:
dest: "{{ override_backup_file }}"
line: "{{ item }}"
with_items: "{{ check_docker_proxy.stdout }}"
when: check_docker_proxy.stdout != ""
- name: Attach timestamp to the platform backup filename
set_fact:
platform_backup_file: "{{ platform_backup_filename_prefix }}_{{ lookup('pipe', 'date +%Y_%m_%d_%H_%M_%S') }}.tgz"
@ -560,7 +293,7 @@
{{ mariadb_dir.path }} 2>/dev/null)"
args:
warn: false
when: check_mariadb_pod.rc == 0 or check_openstack_uploaded.rc == 0
when: check_mariadb_pod.rc == 0 or openstack_status.stdout == "uploaded"
- name: Notify the user backup tar file(s) are available
debug:
@ -579,7 +312,7 @@
src: "{{ openstack_backup_file_path}}"
dest: "{{ host_backup_dir }}/"
flat: yes
when: check_mariadb_pod.rc == 0 or check_openstack_uploaded.rc == 0
when: check_mariadb_pod.rc == 0 or openstack_status.stdout == "uploaded"
- name: Notify the user where the backup tar file(s) can be found
debug:

View File

@ -78,11 +78,11 @@
line: "nameserver {{ controller_floating_address }}"
insertbefore: BOF
- name: Check for controller-0 online status
shell: source /etc/platform/openrc; system host-list | grep online
register: online_check
until: online_check.rc == 0
- name: Check controller-0 is in online state
shell: source /etc/platform/openrc; system host-show controller-0 --column availability --format value
register: check_online
retries: 10
until: check_online.stdout == "online"
- name: Wait for {{ pods_wait_time }} seconds to ensure kube-system pods are all started
wait_for:

View File

@ -96,12 +96,13 @@
- name: Find old registry secrets in Barbican
shell: "{{ item }}"
failed_when: false
with_items:
- "source /etc/platform/openrc; openstack secret list | grep k8s-registry-secret | awk '{print $2}'"
- "source /etc/platform/openrc; openstack secret list | grep gcr-registry-secret | awk '{print $2}'"
- "source /etc/platform/openrc; openstack secret list | grep quay-registry-secret | awk '{print $2}'"
- "source /etc/platform/openrc; openstack secret list | grep docker-registry-secret | awk '{print $2}'"
- "source /etc/platform/openrc; openstack secret list | grep elastic-registry-secret | awk '{print $2}'"
- "source /etc/platform/openrc; openstack secret list -c 'Secret href' -n k8s-registry-secret -f value"
- "source /etc/platform/openrc; openstack secret list -c 'Secret href' -n gcr-registry-secret -f value"
- "source /etc/platform/openrc; openstack secret list -c 'Secret href' -n quay-registry-secret -f value"
- "source /etc/platform/openrc; openstack secret list -c 'Secret href' -n docker-registry-secret -f value"
- "source /etc/platform/openrc; openstack secret list -c 'Secret href' -n elastic-registry-secret -f value"
register: old_barbican_secrets
- name: Delete old registry secrets in Barbican

View File

@ -9,20 +9,19 @@
- block:
- name: Query the {{ registry.name }}
shell: >-
source /etc/platform/openrc; system service-parameter-list --nowrap |
awk '{if ($6 == "{{ registry.name | regex_replace('_', '-') }}") print $8"="$10;}'
shell: source /etc/platform/openrc;
system service-parameter-list --section "{{ registry.name | regex_replace('_', '-') }}"
--column name --column value --format yaml
register: running_registry_output
# Make sure variables are empty to allow succesive executions
# Make sure variables are empty to allow successive executions
- set_fact:
running_registry: { }
registry_filtered: { }
- set_fact:
running_registry:
"{{ running_registry | combine({inner_item.split('=')[0]:inner_item.split('=')[1]}, recursive=True) }}"
with_items: "{{ running_registry_output.stdout_lines }}"
running_registry: "{{ running_registry|default({}) | combine({inner_item.name:inner_item.value}) }}"
with_items: "{{ running_registry_output.stdout | from_yaml }}"
loop_control:
loop_var: inner_item

View File

@ -37,7 +37,7 @@
when: active_ctlr.rc != 0
- name: Search for stx-openstack application
shell: source /etc/platform/openrc; system application-list | grep 'stx-openstack'
shell: source /etc/platform/openrc; system application-show stx-openstack --column status --format value
register: check_openstack
failed_when: false
@ -49,7 +49,7 @@
backed up or it has already been restored successfully.
- meta: end_play
when: check_openstack.rc != 0 or check_openstack.stdout is search('applied')
when: check_openstack.rc != 0 or check_openstack.stdout == "applied"
# If stx-application is not in uploaded state, it means restore_openstack playbook
# has been run and was not successful. Re-run the playbook is not supported.
@ -58,18 +58,17 @@
msg: >-
stx-openstack application must be in uploaded state for the restore to proceed.
The restore must have failed already.
when: check_openstack.stdout is not search('uploaded')
when: check_openstack.stdout != "uploaded"
- name: Check if platform-integ-apps was applied successfully during controller-0 unlock
shell: >-
source /etc/platform/openrc; system application-list |
grep 'platform-integ-apps.*applied.*completed'
source /etc/platform/openrc; system application-show platform-integ-apps --column status --format value
register: check_platform_integ
- name: Fail if platform-integ-apps was not applied successfully
fail:
msg: Application platform-integ-apps was not applied successfully during controller-0 unlock
when: check_platform_integ.rc != 0
when: check_platform_integ.stdout not in ['applied', 'completed']
- name: For remote play set target_backup_dir to {{ backup_dir }}
set_fact:

View File

@ -25,17 +25,17 @@
shell: source /etc/platform/openrc; system application-apply --mode normal stx-openstack
- name: Checking stx-openstack apply progress for the remaining Openstack services... (max 50 mins)
shell: source /etc/platform/openrc; system application-list | grep 'stx-openstack'
shell: >-
source /etc/platform/openrc; system application-show stx-openstack --column status --format value
register: check_app_state
until: check_app_state.stdout is search('applied') or
check_app_state.stdout is search('apply-failed')
until: check_app_state.stdout in ['applied', 'apply-failed']
retries: 50
delay: 60
- name: Fail if the remaining Openstack services cannot be restored successfully
fail:
msg: stx-openstack application is not applied successfully.
when: check_app_state.stdout is not search('applied')
when: check_app_state.stdout != "applied"
- name: Remove restore_openstack_in_progress flag file
file:
@ -78,10 +78,10 @@
source /etc/platform/openrc; system application-apply --mode restore_db stx-openstack
- name: Checking MariaDB apply progress ... (max 30 mins)
shell: source /etc/platform/openrc; system application-list | grep 'stx-openstack'
shell: >-
source /etc/platform/openrc; system application-show stx-openstack --column status --format value
register: check_app_state
until: check_app_state.stdout is search('applied') or
check_app_state.stdout is search('apply-failed')
until: check_app_state.stdout in ['applied', 'apply-failed']
retries: 30
delay: 60
@ -97,7 +97,7 @@
msg: >-
MariaDB service cannot be restored successfully.
Restore StarlingX Openstack application failed.
when: check_app_state.stdout is not search('applied') or
when: check_app_state.stdout != "applied" or
check_mariadb_pod.rc != 0
- block:
@ -163,10 +163,9 @@
- name: Checking Cinder and Glance apply progress... (max 30 mins)
shell: >-
source /etc/platform/openrc; system application-list | grep 'stx-openstack'
source /etc/platform/openrc; system application-show stx-openstack --column status --format value
register: check_app_state
until: check_app_state.stdout is search('applied') or
check_app_state.stdout is search('apply-failed')
until: check_app_state.stdout in ['applied', 'apply-failed']
retries: 30
delay: 60
@ -175,7 +174,7 @@
msg: >-
Cinder and Glance services cannot be restored successfully.
Restore stx-openstack application failed.
when: check_app_state.stdout is not search('applied')
when: check_app_state.stdout != "applied"
- block:
- name: Inform user to restore Glance images and Cinder volumes
@ -196,17 +195,17 @@
shell: source /etc/platform/openrc; system application-apply --mode normal stx-openstack
- name: Checking stx-openstack apply progress for the remaining Openstack services... (max 50 mins)
shell: source /etc/platform/openrc; system application-list | grep 'stx-openstack'
shell: >-
source /etc/platform/openrc; system application-show stx-openstack --column status --format value
register: check_app_state
until: check_app_state.stdout is search('applied') or
check_app_state.stdout is search('apply-failed')
until: check_app_state.stdout in ['applied', 'apply-failed']
retries: 50
delay: 60
- name: Fail if the remaining Openstack services cannot be restored successfully
fail:
msg: stx-openstack application is not applied successfully.
when: check_app_state.stdout is not search('applied')
when: check_app_state.stdout != "applied"
- debug:
msg: Restore stx-openstack application is successful!

View File

@ -347,18 +347,19 @@
# "online" state. This will ensure that keystone, sysinv and
# mtcAgent are indeed in-service after being restated.
- name: Check controller-0 is in online state
shell: source /etc/platform/openrc; system host-list | grep online
shell: source /etc/platform/openrc; system host-show controller-0 --column availability --format value
register: check_online
failed_when: false
retries: 30
delay: 10
until: check_online.stdout == "online"
- name: Inform user that restore_platform is not successful
debug:
msg: >-
Platform restore was unsuccessful. Please refer to the system administration
guide for next step.
when: check_online.rc != 0
when: check_online.stdout != "online"
# Restore ceph-mon data
- block:
@ -369,8 +370,8 @@
# - For systems with storage nodes we get ceph-mon data from storage-0
# ceph-mon that is already up and will not be reinstalled.
- name: Check if setup has storage nodes
shell: source /etc/platform/openrc; system host-list | awk '$6=="storage"{exit 1}'
register: storage_nodes
shell: source /etc/platform/openrc; system host-list --format value --column personality
register: node_personalities
failed_when: false
# Get system_mode after restore and create flag file to skip wiping OSDs
@ -396,7 +397,7 @@
# Recover ceph data for systems with controller storage
- include_role:
name: recover-ceph-data
when: storage_nodes.rc == 0
when: node_personalities.stdout is not search('storage')
- name: Mark crushmap as restored
file:
@ -413,7 +414,7 @@
msg: >-
Controller-0 is now online. The next step is to unlock this controller.
Please refer to the system administration guide for more details.
when: check_online.rc == 0
when: check_online.stdout == "online"
# Remove temporary staging area used by the copy module
- name: Remove {{ ansible_remote_tmp }} directory

View File

@ -71,7 +71,7 @@
- name: Retrieve management IP
shell: >-
source /etc/platform/openrc;
system host-show controller-0 | grep mgmt_ip | awk '{print $4}'
system host-show controller-0 --format value --column mgmt_ip
register: mgmt_ip
- name: Set derived facts for subsequent tasks/roles

View File

@ -9,38 +9,25 @@
vars:
upgrade_k8s_networking: true
overrides_file: "/tmp/upgrade_overrides.yaml"
tasks:
# TODO(kbujold): This comment from the review will be implemented in a separate submission.
# "I would recommend that we follow the same model as we did for for the Puppet
# hiera data generation to avoid scraping CLI command output. The output is not
# intended for machine consumption. Create a command line utility that shares the
# same code as the sysinv-conductor to generate the required Ansible formatted
# data (yaml) directly from the DB. See sysinv/cmd/puppet.py as an example.
# This same utility command can be used by B&R to generate the required restore
# data form the running system directly from the DB in a format that is understood
# the Playbooks."
- name: Create the upgrade overrides file
command: "/usr/bin/sysinv-utils create-host-overrides {{ overrides_file }}"
failed_when: result.stderr != ""
register: result
- name: Dump address pool data to temp file
shell:
source /etc/platform/openrc; system addrpool-list --nowrap > /tmp/addrpool.txt
- name: Retrieve cluster_pod_subnet
shell: "grep cluster-pod-subnet /tmp/addrpool.txt | awk '{print $6\"/\"$8}'"
register: cluster_pod_subnet
- name: Retrieve cluster_floating_address
shell: "grep cluster-host-subnet /tmp/addrpool.txt | awk '{print $14}'"
register: cluster_floating_address
- name: Read the overrides variables
include_vars:
file: "{{ overrides_file }}"
- name: Set networking facts
set_fact:
kubelet_cni_bin_dir: "/usr/libexec/cni"
cluster_pod_subnet: "{{ cluster_pod_subnet.stdout }}"
cluster_network_ipv4: "{{ cluster_pod_subnet.stdout | ipv4 }}"
cluster_network_ipv6: "{{ cluster_pod_subnet.stdout | ipv6 }}"
cluster_floating_address: "{{ cluster_floating_address.stdout }}"
cluster_network_ipv4: "{{ cluster_pod_subnet | ipv4 }}"
cluster_network_ipv6: "{{ cluster_pod_subnet | ipv6 }}"
cluster_floating_address: "{{ cluster_host_floating_address }}"
- name: Set images facts
include_vars: