Add validation to verify the RHSM version.
One of the requirements in the upgrade/update to certain versions
is that the RHSM version configure in the node matches the version
OSP works with. If there is a mismatch on the RHSM version, we would
end up getting wrong packages and finish in an unrecoverable situation.
This validation uses the subscription-manager command to get the
configured release and then checks if it matches the one configured
in check_rhsm_version_expected parameter.
Change-Id: I950395ff8387b01d102fee3a53ad269bb73f16fd
(cherry picked from commit e5784a871c
)
This commit is contained in:
parent
9437f20b04
commit
e8f1810c22
|
@ -0,0 +1,6 @@
|
||||||
|
=========================
|
||||||
|
Role - check_rhsm_version
|
||||||
|
=========================
|
||||||
|
|
||||||
|
.. ansibleautoplugin::
|
||||||
|
:role: roles/check_rhsm_version
|
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
metadata:
|
||||||
|
name: Verify that the RSHM version configured is the right one
|
||||||
|
description: |
|
||||||
|
This validation checks the RHSM version of the target node via
|
||||||
|
subscription-manager release --show and makes sure that the
|
||||||
|
release matches the value set in check_rhsm_version_expected.
|
||||||
|
groups:
|
||||||
|
- pre-undercloud-upgrade
|
||||||
|
- pre-overcloud-upgrade
|
||||||
|
check_rhsm_version_debug: false
|
||||||
|
roles:
|
||||||
|
- check_rhsm_version
|
|
@ -0,0 +1,29 @@
|
||||||
|
---
|
||||||
|
# Copyright 2020 Red Hat, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
# All variables intended for modification should place placed in this file.
|
||||||
|
|
||||||
|
# All variables within this role should have a prefix of "check_rhsm_version"
|
||||||
|
check_rhsm_version_debug: false
|
||||||
|
|
||||||
|
# subscription manager command used to retrieve the
|
||||||
|
# rhsm release. Parametrized mostly for testing
|
||||||
|
check_rhsm_version_command: "subscription-manager release --show"
|
||||||
|
|
||||||
|
# Version expected by the validation, if the configured RHSM version
|
||||||
|
# does not match the validation will fail.
|
||||||
|
check_rhsm_version_expected: "8.2"
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Molecule managed
|
||||||
|
# Copyright 2020 Red Hat, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
{% if item.registry is defined %}
|
||||||
|
FROM {{ item.registry.url }}/{{ item.image }}
|
||||||
|
{% else %}
|
||||||
|
FROM {{ item.image }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
||||||
|
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
|
||||||
|
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||||
|
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
|
||||||
|
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
|
||||||
|
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
|
||||||
|
|
||||||
|
{% for pkg in item.easy_install | default([]) %}
|
||||||
|
# install pip for centos where there is no python-pip rpm in default repos
|
||||||
|
RUN easy_install {{ pkg }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
CMD ["sh", "-c", "while true; do sleep 10000; done"]
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
# Copyright 2020 Red Hat, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
roles:
|
||||||
|
- role: "check_rhsm_version"
|
||||||
|
vars:
|
||||||
|
check_rhsm_version_command: "echo 'Release: 8.2'"
|
||||||
|
check_rhsm_version_expected: "8.2"
|
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
|
||||||
|
log: true
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: centos8
|
||||||
|
hostname: centos8
|
||||||
|
image: centos:8
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
pkg_extras: python*-setuptools
|
||||||
|
volumes:
|
||||||
|
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
|
||||||
|
environment:
|
||||||
|
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||||
|
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
vvv: true
|
||||||
|
log: true
|
||||||
|
env:
|
||||||
|
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||||
|
ANSIBLE_LIBRARY: "../../../../library"
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
test_sequence:
|
||||||
|
- destroy
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- verify
|
||||||
|
- destroy
|
||||||
|
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Molecule managed
|
||||||
|
# Copyright 2020 Red Hat, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
{% if item.registry is defined %}
|
||||||
|
FROM {{ item.registry.url }}/{{ item.image }}
|
||||||
|
{% else %}
|
||||||
|
FROM {{ item.image }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
||||||
|
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
|
||||||
|
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||||
|
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
|
||||||
|
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
|
||||||
|
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
|
||||||
|
|
||||||
|
{% for pkg in item.easy_install | default([]) %}
|
||||||
|
# install pip for centos where there is no python-pip rpm in default repos
|
||||||
|
RUN easy_install {{ pkg }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
CMD ["sh", "-c", "while true; do sleep 10000; done"]
|
|
@ -0,0 +1,43 @@
|
||||||
|
---
|
||||||
|
# Copyright 2020 Red Hat, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
tasks:
|
||||||
|
- name: detect wrong rhsm version
|
||||||
|
block:
|
||||||
|
- name: run validation with wrong rhsm version
|
||||||
|
include_role:
|
||||||
|
name: "check_rhsm_version"
|
||||||
|
vars:
|
||||||
|
check_rhsm_version_command: "echo 'Release: 8.4'"
|
||||||
|
check_rhsm_version_expected: "8.2"
|
||||||
|
rescue:
|
||||||
|
- name: Clear host errors
|
||||||
|
meta: clear_host_errors
|
||||||
|
|
||||||
|
- name: Status message
|
||||||
|
debug:
|
||||||
|
msg: "Detected RHSM version mismatch!"
|
||||||
|
|
||||||
|
- name: End play
|
||||||
|
meta: end_play
|
||||||
|
|
||||||
|
- name: Fail the test
|
||||||
|
fail:
|
||||||
|
msg: |
|
||||||
|
The rhsm version mismatch should have detected but it wasn't..
|
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
driver:
|
||||||
|
name: docker
|
||||||
|
|
||||||
|
log: true
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: centos8
|
||||||
|
hostname: centos8
|
||||||
|
image: centos:8
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
pkg_extras: python*-setuptools
|
||||||
|
volumes:
|
||||||
|
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
|
||||||
|
environment:
|
||||||
|
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||||
|
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||||
|
|
||||||
|
provisioner:
|
||||||
|
name: ansible
|
||||||
|
options:
|
||||||
|
vvv: true
|
||||||
|
log: true
|
||||||
|
env:
|
||||||
|
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||||
|
ANSIBLE_LIBRARY: "../../../../library"
|
||||||
|
|
||||||
|
scenario:
|
||||||
|
test_sequence:
|
||||||
|
- destroy
|
||||||
|
- create
|
||||||
|
- prepare
|
||||||
|
- converge
|
||||||
|
- verify
|
||||||
|
- destroy
|
||||||
|
|
||||||
|
verifier:
|
||||||
|
name: testinfra
|
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
# Copyright 2020 Red Hat, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
|
# "check_rhsm_version" tasks
|
||||||
|
- name: Retrieve RHSM version
|
||||||
|
become: true
|
||||||
|
command: "{{ check_rhsm_version_command }}"
|
||||||
|
register: rhsm_version_ret
|
||||||
|
|
||||||
|
- name: Check RHSM version
|
||||||
|
fail:
|
||||||
|
msg: '{{ check_rhsm_version_expected }} does not match configured rhsm_version {{ rhsm_version_ret.stdout }}'
|
||||||
|
when: "check_rhsm_version_expected not in rhsm_version_ret.stdout"
|
|
@ -4,6 +4,7 @@
|
||||||
jobs:
|
jobs:
|
||||||
- tripleo-validations-centos-8-molecule-ceph
|
- tripleo-validations-centos-8-molecule-ceph
|
||||||
- tripleo-validations-centos-8-molecule-check_network_gateway
|
- tripleo-validations-centos-8-molecule-check_network_gateway
|
||||||
|
- tripleo-validations-centos-8-molecule-check_rhsm_version
|
||||||
- tripleo-validations-centos-8-molecule-controller_token
|
- tripleo-validations-centos-8-molecule-controller_token
|
||||||
- tripleo-validations-centos-8-molecule-controller_ulimits
|
- tripleo-validations-centos-8-molecule-controller_ulimits
|
||||||
- tripleo-validations-centos-8-molecule-ctlplane_ip_range
|
- tripleo-validations-centos-8-molecule-ctlplane_ip_range
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
jobs:
|
jobs:
|
||||||
- tripleo-validations-centos-8-molecule-ceph
|
- tripleo-validations-centos-8-molecule-ceph
|
||||||
- tripleo-validations-centos-8-molecule-check_network_gateway
|
- tripleo-validations-centos-8-molecule-check_network_gateway
|
||||||
|
- tripleo-validations-centos-8-molecule-check_rhsm_version
|
||||||
- tripleo-validations-centos-8-molecule-controller_token
|
- tripleo-validations-centos-8-molecule-controller_token
|
||||||
- tripleo-validations-centos-8-molecule-controller_ulimits
|
- tripleo-validations-centos-8-molecule-controller_ulimits
|
||||||
- tripleo-validations-centos-8-molecule-ctlplane_ip_range
|
- tripleo-validations-centos-8-molecule-ctlplane_ip_range
|
||||||
|
@ -305,3 +307,10 @@
|
||||||
parent: tripleo-validations-centos-8-base
|
parent: tripleo-validations-centos-8-base
|
||||||
vars:
|
vars:
|
||||||
tripleo_validations_role_name: package_version
|
tripleo_validations_role_name: package_version
|
||||||
|
- job:
|
||||||
|
files:
|
||||||
|
- ^roles/check_rhsm_version/.*
|
||||||
|
name: tripleo-validations-centos-8-molecule-check_rhsm_version
|
||||||
|
parent: tripleo-validations-centos-8-base
|
||||||
|
vars:
|
||||||
|
tripleo_validations_role_name: check_rhsm_version
|
||||||
|
|
Loading…
Reference in New Issue