Add validation to verify undercloud.conf content.
This validation checks the correctness of the undercloud.conf file. The checks run as part of the verification are: - All parameters assigned to a file path point to an existing file location in the system. - No deprecated parameters are included in undercloud.conf - All required parameters are present in undercloud.conf - No deprecated hw types are included in the enabled_hw_types parameters. Change-Id: Ic543e21c4aa60b05991f0c4866a6408b924304fd
This commit is contained in:
parent
e8162a593d
commit
99fdf8ae6a
@ -63,6 +63,7 @@
|
||||
- tripleo-validations-centos-8-molecule-ceph
|
||||
- tripleo-validations-centos-8-molecule-check_network_gateway
|
||||
- tripleo-validations-centos-8-molecule-check_rhsm_version
|
||||
- tripleo-validations-centos-8-molecule-check_undercloud_conf
|
||||
- tripleo-validations-centos-8-molecule-controller_token
|
||||
- tripleo-validations-centos-8-molecule-controller_ulimits
|
||||
- tripleo-validations-centos-8-molecule-ctlplane_ip_range
|
||||
@ -84,6 +85,7 @@
|
||||
- tripleo-validations-centos-8-molecule-ceph
|
||||
- tripleo-validations-centos-8-molecule-check_network_gateway
|
||||
- tripleo-validations-centos-8-molecule-check_rhsm_version
|
||||
- tripleo-validations-centos-8-molecule-check_undercloud_conf
|
||||
- tripleo-validations-centos-8-molecule-controller_token
|
||||
- tripleo-validations-centos-8-molecule-controller_ulimits
|
||||
- tripleo-validations-centos-8-molecule-ctlplane_ip_range
|
||||
@ -388,3 +390,10 @@
|
||||
parent: tripleo-validations-centos-8-base
|
||||
vars:
|
||||
tripleo_validations_role_name: check_rhsm_version
|
||||
- job:
|
||||
files:
|
||||
- ^roles/check_undercloud_conf/.*
|
||||
name: tripleo-validations-centos-8-molecule-check_undercloud_conf
|
||||
parent: tripleo-validations-centos-8-base
|
||||
vars:
|
||||
tripleo_validations_role_name: check_undercloud_conf
|
||||
|
6
doc/source/roles/role-check_undercloud_conf.rst
Normal file
6
doc/source/roles/role-check_undercloud_conf.rst
Normal file
@ -0,0 +1,6 @@
|
||||
============================
|
||||
Role - check_undercloud_conf
|
||||
============================
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:role: roles/check_undercloud_conf
|
15
playbooks/check-undercloud-conf.yaml
Normal file
15
playbooks/check-undercloud-conf.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- hosts: undercloud
|
||||
vars:
|
||||
metadata:
|
||||
name: Verify undercloud.conf correctness
|
||||
description: |
|
||||
This validation verifies that no deprecated, invalid or
|
||||
incompatible parameters are being passwed in the Undercloud's
|
||||
undercloud.conf configuration file.
|
||||
groups:
|
||||
- prep
|
||||
- pre-undercloud-upgrade
|
||||
check_undercloud_conf_debug: false
|
||||
roles:
|
||||
- check_undercloud_conf
|
41
roles/check_undercloud_conf/defaults/main.yml
Normal file
41
roles/check_undercloud_conf/defaults/main.yml
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
# 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_undercloud_conf"
|
||||
check_undercloud_conf_debug: false
|
||||
required_params:
|
||||
- container_images_file
|
||||
deprecated_params:
|
||||
- masquerade_network
|
||||
- docker_images_file
|
||||
- enabled_drivers
|
||||
- docker_bip
|
||||
- network_gateway
|
||||
- network_cidr
|
||||
- discovery_interface
|
||||
- discovery_runbench
|
||||
- docker_insecure_registries
|
||||
- docker_registry_mirror
|
||||
- ipxe_enabled
|
||||
unsupported_drivers:
|
||||
- pxe_ipmitool
|
||||
- pxe_drac
|
||||
- pxe_ilo
|
||||
- pxe_irmc
|
||||
- fake_pxe
|
37
roles/check_undercloud_conf/molecule/config_OK/Dockerfile.j2
Normal file
37
roles/check_undercloud_conf/molecule/config_OK/Dockerfile.j2
Normal file
@ -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"]
|
45
roles/check_undercloud_conf/molecule/config_OK/converge.yml
Normal file
45
roles/check_undercloud_conf/molecule/config_OK/converge.yml
Normal file
@ -0,0 +1,45 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
# Validate a correct undercloud.conf with content:
|
||||
#
|
||||
# [DEFAULT]
|
||||
# local_interface = em0
|
||||
# local_ip = 192.168.24.1/24
|
||||
# undercloud_public_host = 192.168.24.2
|
||||
# undercloud_admin_host = 192.168.24.3
|
||||
# undercloud_nameservers = 172.16.0.1,10.0.0.1
|
||||
# undercloud_ntp_servers=clock1.rdu2.redhat.com
|
||||
# overcloud_domain_name=redhat.local
|
||||
# undercloud_service_certificate = /undercloud.pem
|
||||
# hieradata_override = /hiera_override.yaml
|
||||
# container_images_file= /containers-prepare-parameter.yaml
|
||||
# enabled_hw_types = ipmi,redfish
|
||||
# custom_env_files = /skip_rhel_release.yaml
|
||||
#
|
||||
# [ctlplane-subnet]
|
||||
# local_subnet = ctlplane-subnet
|
||||
# cidr = 192.168.24.0/24
|
||||
# dhcp_start = 192.168.24.5
|
||||
# dhcp_end = 192.168.24.55
|
||||
# gateway = 192.168.24.1
|
||||
# inspection_iprange = 192.168.24.100,192.168.24.120
|
||||
#
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
roles:
|
||||
- role: "check_undercloud_conf"
|
51
roles/check_undercloud_conf/molecule/config_OK/molecule.yml
Normal file
51
roles/check_undercloud_conf/molecule/config_OK/molecule.yml
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
driver:
|
||||
name: podman
|
||||
|
||||
log: true
|
||||
|
||||
platforms:
|
||||
- name: ubi8
|
||||
hostname: ubi8
|
||||
image: ubi8/ubi-init
|
||||
registry:
|
||||
url: registry.access.redhat.com
|
||||
pkg_extras: python*-setuptools python*-pyyaml
|
||||
volumes:
|
||||
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
|
||||
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
|
||||
- /opt/yum.repos.d:/etc/yum.repos.d:rw
|
||||
privileged: true
|
||||
environment: &env
|
||||
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||
ulimits: &ulimit
|
||||
- host
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
options:
|
||||
vvv: true
|
||||
inventory:
|
||||
hosts:
|
||||
all:
|
||||
hosts:
|
||||
ubi8:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
vars:
|
||||
ansible_user: root
|
||||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- destroy
|
||||
|
||||
verifier:
|
||||
name: testinfra
|
84
roles/check_undercloud_conf/molecule/config_OK/prepare.yml
Normal file
84
roles/check_undercloud_conf/molecule/config_OK/prepare.yml
Normal file
@ -0,0 +1,84 @@
|
||||
---
|
||||
# Copyright 2019 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: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: install hiera
|
||||
package:
|
||||
name: hiera
|
||||
|
||||
- name: create hiera tree
|
||||
file:
|
||||
path: /etc/puppet
|
||||
state: directory
|
||||
|
||||
- name: populate hiera.yaml
|
||||
copy:
|
||||
dest: /etc/puppet/hiera.yaml
|
||||
content: |
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: "/etc/puppet/"
|
||||
:hierarchy:
|
||||
- "common"
|
||||
- "service_configs"
|
||||
|
||||
- name: populate hiera content
|
||||
copy:
|
||||
dest: /etc/puppet/common.yaml
|
||||
content: |
|
||||
tripleo_undercloud_conf_file: /undercloud.conf
|
||||
|
||||
- name: populate undercloud.conf
|
||||
copy:
|
||||
dest: /undercloud.conf
|
||||
content: |
|
||||
[DEFAULT]
|
||||
local_interface = em0
|
||||
local_ip = 192.168.24.1/24
|
||||
undercloud_public_host = 192.168.24.2
|
||||
undercloud_admin_host = 192.168.24.3
|
||||
undercloud_nameservers = 172.16.0.1,10.0.0.1
|
||||
undercloud_ntp_servers=clock1.rdu2.redhat.com
|
||||
overcloud_domain_name=redhat.local
|
||||
undercloud_service_certificate = /undercloud.pem
|
||||
hieradata_override = /hiera_override.yaml
|
||||
container_images_file= /containers-prepare-parameter.yaml
|
||||
enabled_hardware_types = ipmi,redfish
|
||||
custom_env_files = /skip_rhel_release.yaml
|
||||
|
||||
[ctlplane-subnet]
|
||||
local_subnet = ctlplane-subnet
|
||||
cidr = 192.168.24.0/24
|
||||
dhcp_start = 192.168.24.5
|
||||
dhcp_end = 192.168.24.55
|
||||
gateway = 192.168.24.1
|
||||
inspection_iprange = 192.168.24.100,192.168.24.120
|
||||
|
||||
- name: create files with random content
|
||||
copy:
|
||||
dest: "/{{ item }}"
|
||||
content: |
|
||||
I'm the file {{ item }}
|
||||
loop:
|
||||
- 'undercloud.pem'
|
||||
- 'hiera_override.yaml'
|
||||
- 'containers-prepare-parameter.yaml'
|
||||
- 'skip_rhel_release.yaml'
|
37
roles/check_undercloud_conf/molecule/default/Dockerfile.j2
Normal file
37
roles/check_undercloud_conf/molecule/default/Dockerfile.j2
Normal file
@ -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"]
|
55
roles/check_undercloud_conf/molecule/default/converge.yml
Normal file
55
roles/check_undercloud_conf/molecule/default/converge.yml
Normal file
@ -0,0 +1,55 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
# Validate an undercloud.conf with the following content:
|
||||
#
|
||||
# [DEFAULT]
|
||||
# container_images_file= /home/stack/containers-prepare-parameter.yaml
|
||||
#
|
||||
# The validation should fail as the file /home/stack/containers-prepare-parameter.yaml
|
||||
# does not exist.
|
||||
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: detect non existing file assigned to a parameter
|
||||
block:
|
||||
- name: run validation check_undercloud_conf
|
||||
include_role:
|
||||
name: "check_undercloud_conf"
|
||||
rescue:
|
||||
- name: Clear host errors
|
||||
meta: clear_host_errors
|
||||
|
||||
- name: Detect right error message
|
||||
fail:
|
||||
msg: "Test failed due to wrong error: {{ ansible_failed_result.results.0.msg }}"
|
||||
when:
|
||||
- not ansible_failed_result.results.0.msg |
|
||||
regex_search("^File configured in .* does not exist$")
|
||||
|
||||
- name: Status message
|
||||
debug:
|
||||
msg: "Detected undercloud.conf configuration issue!"
|
||||
|
||||
- name: End play
|
||||
meta: end_play
|
||||
|
||||
- name: Fail the test
|
||||
fail:
|
||||
msg: |
|
||||
A configuration issue should have been detected but it wasn't..
|
51
roles/check_undercloud_conf/molecule/default/molecule.yml
Normal file
51
roles/check_undercloud_conf/molecule/default/molecule.yml
Normal file
@ -0,0 +1,51 @@
|
||||
---
|
||||
driver:
|
||||
name: podman
|
||||
|
||||
log: true
|
||||
|
||||
platforms:
|
||||
- name: ubi8
|
||||
hostname: ubi8
|
||||
image: ubi8/ubi-init
|
||||
registry:
|
||||
url: registry.access.redhat.com
|
||||
pkg_extras: python*-setuptools python*-pyyaml
|
||||
volumes:
|
||||
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
|
||||
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
|
||||
- /opt/yum.repos.d:/etc/yum.repos.d:rw
|
||||
privileged: true
|
||||
environment: &env
|
||||
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||
ulimits: &ulimit
|
||||
- host
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
options:
|
||||
vvv: true
|
||||
inventory:
|
||||
hosts:
|
||||
all:
|
||||
hosts:
|
||||
ubi8:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
vars:
|
||||
ansible_user: root
|
||||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- destroy
|
||||
|
||||
verifier:
|
||||
name: testinfra
|
53
roles/check_undercloud_conf/molecule/default/prepare.yml
Normal file
53
roles/check_undercloud_conf/molecule/default/prepare.yml
Normal file
@ -0,0 +1,53 @@
|
||||
---
|
||||
# Copyright 2019 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: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: install hiera
|
||||
package:
|
||||
name: hiera
|
||||
|
||||
- name: create hiera tree
|
||||
file:
|
||||
path: /etc/puppet
|
||||
state: directory
|
||||
|
||||
- name: populate hiera.yaml
|
||||
copy:
|
||||
dest: /etc/puppet/hiera.yaml
|
||||
content: |
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: "/etc/puppet/"
|
||||
:hierarchy:
|
||||
- "common"
|
||||
- "service_configs"
|
||||
|
||||
- name: populate hiera content
|
||||
copy:
|
||||
dest: /etc/puppet/common.yaml
|
||||
content: |
|
||||
tripleo_undercloud_conf_file: /undercloud.conf
|
||||
|
||||
- name: populate undercloud.conf
|
||||
copy:
|
||||
dest: /undercloud.conf
|
||||
content: |
|
||||
[DEFAULT]
|
||||
container_images_file= /home/stack/containers-prepare-parameter.yaml
|
@ -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,71 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
# Validate that the validation fails when the undercloud.conf contains
|
||||
# deprecated drivers in the enabled_hardware_types:
|
||||
#
|
||||
# [DEFAULT]
|
||||
# local_interface = em0
|
||||
# local_ip = 192.168.24.1/24
|
||||
# undercloud_public_host = 192.168.24.2
|
||||
# undercloud_admin_host = 192.168.24.3
|
||||
# undercloud_nameservers = 172.16.0.1,10.0.0.1
|
||||
# undercloud_ntp_servers=clock1.rdu2.redhat.com
|
||||
# overcloud_domain_name=redhat.local
|
||||
# undercloud_service_certificate = /undercloud.pem
|
||||
# hieradata_override = /hiera_override.yaml
|
||||
# container_images_file= /containers-prepare-parameter.yaml
|
||||
# enabled_hardware_types = pxe_ipmitool,pxe_drac,fake_pxe,ipmi,redfish
|
||||
# custom_env_files = /skip_rhel_release.yaml
|
||||
#
|
||||
# [ctlplane-subnet]
|
||||
# local_subnet = ctlplane-subnet
|
||||
# cidr = 192.168.24.0/24
|
||||
# dhcp_start = 192.168.24.5
|
||||
# dhcp_end = 192.168.24.55
|
||||
# gateway = 192.168.24.1
|
||||
# inspection_iprange = 192.168.24.100,192.168.24.120
|
||||
#
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: detect deprecated parameters in undercloud conf
|
||||
block:
|
||||
- name: run validation check_undercloud_conf
|
||||
include_role:
|
||||
name: "check_undercloud_conf"
|
||||
rescue:
|
||||
- name: Clear host errors
|
||||
meta: clear_host_errors
|
||||
|
||||
- name: Detect right error message
|
||||
fail:
|
||||
msg: "Test failed due to wrong error: {{ ansible_failed_result.msg }}"
|
||||
when:
|
||||
- not ansible_failed_result.msg | regex_search("^Hardware type\\(s\\) .* are not supported any more$")
|
||||
|
||||
- name: Status message
|
||||
debug:
|
||||
msg: "Detected undercloud.conf configuration issue!"
|
||||
|
||||
- name: End play
|
||||
meta: end_play
|
||||
|
||||
- name: Fail the test
|
||||
fail:
|
||||
msg: |
|
||||
A configuration issue should have been detected but it wasn't..
|
@ -0,0 +1,51 @@
|
||||
---
|
||||
driver:
|
||||
name: podman
|
||||
|
||||
log: true
|
||||
|
||||
platforms:
|
||||
- name: ubi8
|
||||
hostname: ubi8
|
||||
image: ubi8/ubi-init
|
||||
registry:
|
||||
url: registry.access.redhat.com
|
||||
pkg_extras: python*-setuptools python*-pyyaml
|
||||
volumes:
|
||||
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
|
||||
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
|
||||
- /opt/yum.repos.d:/etc/yum.repos.d:rw
|
||||
privileged: true
|
||||
environment: &env
|
||||
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||
ulimits: &ulimit
|
||||
- host
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
options:
|
||||
vvv: true
|
||||
inventory:
|
||||
hosts:
|
||||
all:
|
||||
hosts:
|
||||
ubi8:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
vars:
|
||||
ansible_user: root
|
||||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- destroy
|
||||
|
||||
verifier:
|
||||
name: testinfra
|
@ -0,0 +1,84 @@
|
||||
---
|
||||
# Copyright 2019 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: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: install hiera
|
||||
package:
|
||||
name: hiera
|
||||
|
||||
- name: create hiera tree
|
||||
file:
|
||||
path: /etc/puppet
|
||||
state: directory
|
||||
|
||||
- name: populate hiera.yaml
|
||||
copy:
|
||||
dest: /etc/puppet/hiera.yaml
|
||||
content: |
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: "/etc/puppet/"
|
||||
:hierarchy:
|
||||
- "common"
|
||||
- "service_configs"
|
||||
|
||||
- name: populate hiera content
|
||||
copy:
|
||||
dest: /etc/puppet/common.yaml
|
||||
content: |
|
||||
tripleo_undercloud_conf_file: /undercloud.conf
|
||||
|
||||
- name: populate undercloud.conf
|
||||
copy:
|
||||
dest: /undercloud.conf
|
||||
content: |
|
||||
[DEFAULT]
|
||||
local_interface = em0
|
||||
local_ip = 192.168.24.1/24
|
||||
undercloud_public_host = 192.168.24.2
|
||||
undercloud_admin_host = 192.168.24.3
|
||||
undercloud_nameservers = 172.16.0.1,10.0.0.1
|
||||
undercloud_ntp_servers=clock1.rdu2.redhat.com
|
||||
overcloud_domain_name=redhat.local
|
||||
undercloud_service_certificate = /undercloud.pem
|
||||
hieradata_override = /hiera_override.yaml
|
||||
container_images_file= /containers-prepare-parameter.yaml
|
||||
enabled_hardware_types = pxe_ipmitool,pxe_drac,fake_pxe,ipmi,redfish
|
||||
custom_env_files = /skip_rhel_release.yaml
|
||||
|
||||
[ctlplane-subnet]
|
||||
local_subnet = ctlplane-subnet
|
||||
cidr = 192.168.24.0/24
|
||||
dhcp_start = 192.168.24.5
|
||||
dhcp_end = 192.168.24.55
|
||||
gateway = 192.168.24.1
|
||||
inspection_iprange = 192.168.24.100,192.168.24.120
|
||||
|
||||
- name: create files with random content
|
||||
copy:
|
||||
dest: "/{{ item }}"
|
||||
content: |
|
||||
I'm the file {{ item }}
|
||||
loop:
|
||||
- 'undercloud.pem'
|
||||
- 'hiera_override.yaml'
|
||||
- 'containers-prepare-parameter.yaml'
|
||||
- 'skip_rhel_release.yaml'
|
@ -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,61 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
# Validate that the validation fails when undercloud.conf contains
|
||||
# deprecated parameters:
|
||||
#
|
||||
#
|
||||
# [DEFAULT]
|
||||
# container_images_file= /containers-prepare-parameter.yaml
|
||||
# enabled_drivers = ipxe
|
||||
# masquerade_network=192.168.24.0/24
|
||||
# ipxe_enabled = true
|
||||
# docker_insecure_registries = 'docker.io'
|
||||
# custom_env_files = /skip_rhel_release.yaml
|
||||
# network_cidr = 192.168.24.0/24
|
||||
# network_gateway =192.168.24.1
|
||||
#
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: detect deprecated parameters in undercloud conf
|
||||
block:
|
||||
- name: run validation check_undercloud_conf
|
||||
include_role:
|
||||
name: "check_undercloud_conf"
|
||||
rescue:
|
||||
- name: Clear host errors
|
||||
meta: clear_host_errors
|
||||
|
||||
- name: Detect right error message
|
||||
fail:
|
||||
msg: "Test failed due to wrong error: {{ ansible_failed_result.msg }}"
|
||||
when:
|
||||
- not ansible_failed_result.msg |
|
||||
regex_search("^Parameters .* are deprecated for .*$")
|
||||
|
||||
- name: Status message
|
||||
debug:
|
||||
msg: "Detected undercloud.conf configuration issue!"
|
||||
|
||||
- name: End play
|
||||
meta: end_play
|
||||
|
||||
- name: Fail the test
|
||||
fail:
|
||||
msg: |
|
||||
A configuration issue should have been detected but it wasn't..
|
@ -0,0 +1,51 @@
|
||||
---
|
||||
driver:
|
||||
name: podman
|
||||
|
||||
log: true
|
||||
|
||||
platforms:
|
||||
- name: ubi8
|
||||
hostname: ubi8
|
||||
image: ubi8/ubi-init
|
||||
registry:
|
||||
url: registry.access.redhat.com
|
||||
pkg_extras: python*-setuptools python*-pyyaml
|
||||
volumes:
|
||||
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
|
||||
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
|
||||
- /opt/yum.repos.d:/etc/yum.repos.d:rw
|
||||
privileged: true
|
||||
environment: &env
|
||||
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||
ulimits: &ulimit
|
||||
- host
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
options:
|
||||
vvv: true
|
||||
inventory:
|
||||
hosts:
|
||||
all:
|
||||
hosts:
|
||||
ubi8:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
vars:
|
||||
ansible_user: root
|
||||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- destroy
|
||||
|
||||
verifier:
|
||||
name: testinfra
|
@ -0,0 +1,70 @@
|
||||
---
|
||||
# Copyright 2019 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: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: install hiera
|
||||
package:
|
||||
name: hiera
|
||||
|
||||
- name: create hiera tree
|
||||
file:
|
||||
path: /etc/puppet
|
||||
state: directory
|
||||
|
||||
- name: populate hiera.yaml
|
||||
copy:
|
||||
dest: /etc/puppet/hiera.yaml
|
||||
content: |
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: "/etc/puppet/"
|
||||
:hierarchy:
|
||||
- "common"
|
||||
- "service_configs"
|
||||
|
||||
- name: populate hiera content
|
||||
copy:
|
||||
dest: /etc/puppet/common.yaml
|
||||
content: |
|
||||
tripleo_undercloud_conf_file: /undercloud.conf
|
||||
|
||||
- name: populate undercloud.conf
|
||||
copy:
|
||||
dest: /undercloud.conf
|
||||
content: |
|
||||
[DEFAULT]
|
||||
container_images_file= /containers-prepare-parameter.yaml
|
||||
enabled_drivers = ipxe
|
||||
masquerade_network=192.168.24.0/24
|
||||
ipxe_enabled = true
|
||||
docker_insecure_registries = 'docker.io'
|
||||
custom_env_files = /skip_rhel_release.yaml
|
||||
network_cidr = 192.168.24.0/24
|
||||
network_gateway =192.168.24.1
|
||||
|
||||
- name: create files with random content
|
||||
copy:
|
||||
dest: "/{{ item }}"
|
||||
content: |
|
||||
I'm the file {{ item }}
|
||||
loop:
|
||||
- 'containers-prepare-parameter.yaml'
|
||||
- 'skip_rhel_release.yaml'
|
@ -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,71 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
# Validate that the validation fails when the undercloud.conf does not contain
|
||||
# a required parameter. In this case, container_images_file:
|
||||
#
|
||||
# [DEFAULT]
|
||||
# local_interface = em0
|
||||
# local_ip = 192.168.24.1/24
|
||||
# undercloud_public_host = 192.168.24.2
|
||||
# undercloud_admin_host = 192.168.24.3
|
||||
# undercloud_nameservers = 172.16.0.1,10.0.0.1
|
||||
# undercloud_ntp_servers=clock1.rdu2.redhat.com
|
||||
# overcloud_domain_name=redhat.local
|
||||
# undercloud_service_certificate = /undercloud.pem
|
||||
# hieradata_override = /hiera_override.yaml
|
||||
# enabled_hardware_types = ipmi,redfish
|
||||
# custom_env_files = /skip_rhel_release.yaml
|
||||
#
|
||||
# [ctlplane-subnet]
|
||||
# local_subnet = ctlplane-subnet
|
||||
# cidr = 192.168.24.0/24
|
||||
# dhcp_start = 192.168.24.5
|
||||
# dhcp_end = 192.168.24.55
|
||||
# gateway = 192.168.24.1
|
||||
# inspection_iprange = 192.168.24.100,192.168.24.120
|
||||
#
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: detect missing required parameter from conf
|
||||
block:
|
||||
- name: run validation check_undercloud_conf
|
||||
include_role:
|
||||
name: "check_undercloud_conf"
|
||||
rescue:
|
||||
- name: Clear host errors
|
||||
meta: clear_host_errors
|
||||
|
||||
- name: Detect right error message
|
||||
fail:
|
||||
msg: "Test failed due to wrong error: {{ ansible_failed_result.results.0.msg }}"
|
||||
when:
|
||||
- not ansible_failed_result.results.0.msg |
|
||||
regex_search("^Property .* is required in .*$")
|
||||
|
||||
- name: Status message
|
||||
debug:
|
||||
msg: "Detected undercloud.conf configuration issue!"
|
||||
|
||||
- name: End play
|
||||
meta: end_play
|
||||
|
||||
- name: Fail the test
|
||||
fail:
|
||||
msg: |
|
||||
A configuration issue should have been detected but it wasn't..
|
@ -0,0 +1,51 @@
|
||||
---
|
||||
driver:
|
||||
name: podman
|
||||
|
||||
log: true
|
||||
|
||||
platforms:
|
||||
- name: ubi8
|
||||
hostname: ubi8
|
||||
image: ubi8/ubi-init
|
||||
registry:
|
||||
url: registry.access.redhat.com
|
||||
pkg_extras: python*-setuptools python*-pyyaml
|
||||
volumes:
|
||||
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
|
||||
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg
|
||||
- /opt/yum.repos.d:/etc/yum.repos.d:rw
|
||||
privileged: true
|
||||
environment: &env
|
||||
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||
ulimits: &ulimit
|
||||
- host
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
options:
|
||||
vvv: true
|
||||
inventory:
|
||||
hosts:
|
||||
all:
|
||||
hosts:
|
||||
ubi8:
|
||||
ansible_python_interpreter: /usr/bin/python3
|
||||
vars:
|
||||
ansible_user: root
|
||||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
ANSIBLE_LIBRARY: "${ANSIBLE_LIBRARY:-/usr/share/ansible/plugins/modules}"
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- destroy
|
||||
|
||||
verifier:
|
||||
name: testinfra
|
@ -0,0 +1,82 @@
|
||||
---
|
||||
# Copyright 2019 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: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: install hiera
|
||||
package:
|
||||
name: hiera
|
||||
|
||||
- name: create hiera tree
|
||||
file:
|
||||
path: /etc/puppet
|
||||
state: directory
|
||||
|
||||
- name: populate hiera.yaml
|
||||
copy:
|
||||
dest: /etc/puppet/hiera.yaml
|
||||
content: |
|
||||
:backends:
|
||||
- yaml
|
||||
:yaml:
|
||||
:datadir: "/etc/puppet/"
|
||||
:hierarchy:
|
||||
- "common"
|
||||
- "service_configs"
|
||||
|
||||
- name: populate hiera content
|
||||
copy:
|
||||
dest: /etc/puppet/common.yaml
|
||||
content: |
|
||||
tripleo_undercloud_conf_file: /undercloud.conf
|
||||
|
||||
- name: populate undercloud.conf
|
||||
copy:
|
||||
dest: /undercloud.conf
|
||||
content: |
|
||||
[DEFAULT]
|
||||
local_interface = em0
|
||||
local_ip = 192.168.24.1/24
|
||||
undercloud_public_host = 192.168.24.2
|
||||
undercloud_admin_host = 192.168.24.3
|
||||
undercloud_nameservers = 172.16.0.1,10.0.0.1
|
||||
undercloud_ntp_servers=clock1.rdu2.redhat.com
|
||||
overcloud_domain_name=redhat.local
|
||||
undercloud_service_certificate = /undercloud.pem
|
||||
hieradata_override = /hiera_override.yaml
|
||||
enabled_hardware_types = ipmi,redfish
|
||||
custom_env_files = /skip_rhel_release.yaml
|
||||
|
||||
[ctlplane-subnet]
|
||||
local_subnet = ctlplane-subnet
|
||||
cidr = 192.168.24.0/24
|
||||
dhcp_start = 192.168.24.5
|
||||
dhcp_end = 192.168.24.55
|
||||
gateway = 192.168.24.1
|
||||
inspection_iprange = 192.168.24.100,192.168.24.120
|
||||
|
||||
- name: create files with random content
|
||||
copy:
|
||||
dest: "/{{ item }}"
|
||||
content: |
|
||||
I'm the file {{ item }}
|
||||
loop:
|
||||
- 'undercloud.pem'
|
||||
- 'hiera_override.yaml'
|
||||
- 'skip_rhel_release.yaml'
|
46
roles/check_undercloud_conf/tasks/check_syntax.yml
Normal file
46
roles/check_undercloud_conf/tasks/check_syntax.yml
Normal file
@ -0,0 +1,46 @@
|
||||
---
|
||||
- name: Verify required properties
|
||||
lineinfile:
|
||||
name: "{{ tripleo_undercloud_conf_file }}"
|
||||
regexp: "^{{ item }}\\s*=.*$"
|
||||
state: absent
|
||||
check_mode: true
|
||||
register: uc_conf
|
||||
loop: "{{ required_params }}"
|
||||
|
||||
- name: "Fail if parameter not present in {{ tripleo_undercloud_conf_file }}"
|
||||
fail:
|
||||
msg: >-
|
||||
Property {{ item.item }} is required in
|
||||
{{ tripleo_undercloud_conf_file }}"
|
||||
failed_when: not item.changed
|
||||
loop: "{{ uc_conf.results }}"
|
||||
|
||||
- name: Check deprecated parameters
|
||||
vars:
|
||||
common_deprecated: "{{ uc_conf_props | intersect(deprecated_params) }}"
|
||||
fail:
|
||||
msg: >-
|
||||
Parameters {{ common_deprecated | join(', ') }} are deprecated for
|
||||
{{ tripleo_undercloud_conf_file }}
|
||||
when:
|
||||
- common_deprecated is defined
|
||||
- common_deprecated|length > 0
|
||||
|
||||
- name: Get hw_types from conf file
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: enabled_hardware_types
|
||||
register: hw_types
|
||||
|
||||
- name: Check deprecated drivers
|
||||
vars:
|
||||
hw_types_common: "{{ hw_types.value.split(',')|intersect(unsupported_drivers) }}"
|
||||
fail:
|
||||
msg: >-
|
||||
Hardware type(s) {{ hw_types_common | join(', ') }}
|
||||
are not supported any more
|
||||
when:
|
||||
- "'enabled_hardware_types' in uc_conf_props"
|
||||
- hw_types_common|length > 0
|
66
roles/check_undercloud_conf/tasks/main.yml
Normal file
66
roles/check_undercloud_conf/tasks/main.yml
Normal file
@ -0,0 +1,66 @@
|
||||
---
|
||||
# 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_undercloud_conf" tasks
|
||||
- name: Get the path of tripleo undercloud config file
|
||||
become: true
|
||||
hiera:
|
||||
name: "tripleo_undercloud_conf_file"
|
||||
|
||||
- name: "Retrieve {{ tripleo_undercloud_conf_file }} content"
|
||||
slurp:
|
||||
src: "{{ tripleo_undercloud_conf_file }}"
|
||||
register: uc_conf_content
|
||||
|
||||
- name: Store all properties and file type properties
|
||||
# b64decode will return all lines delimited by \n character in a
|
||||
# single string. Therefore, we can really use ^/$.
|
||||
# Get the string ([a-zA-Z0-9_]) after each \n skipping whitespaces
|
||||
# until the equals.
|
||||
# For the file properties, store all properties which after the =
|
||||
# matches a directory. Being the directory optionally started
|
||||
# by . or ~, followed by / and anything else until getting to \n.
|
||||
# Ex: container_images_file= /home/stack/containers-prepare-parameter.yaml
|
||||
set_fact:
|
||||
uc_conf_props: "{{ uc_conf_content['content'] | b64decode |
|
||||
regex_findall('\\\n\\s*(\\w+)\\s*=[^\\\n]') }}"
|
||||
uc_file_props: "{{ uc_conf_content['content'] | b64decode |
|
||||
regex_findall('\\\n\\s*(\\w+)\\s*=\\s*[.~]*\\/[^\\\n]') }}"
|
||||
|
||||
- name: Get value from conf file
|
||||
validations_read_ini:
|
||||
path: "{{ tripleo_undercloud_conf_file }}"
|
||||
section: DEFAULT
|
||||
key: "{{ item }}"
|
||||
register: conf_values
|
||||
loop: "{{ uc_file_props }}"
|
||||
|
||||
- name: Check file property point to existing file
|
||||
stat:
|
||||
path: "{{ item.value }}"
|
||||
register: file_prop_stat
|
||||
loop: "{{ conf_values.results }}"
|
||||
|
||||
- name: fail if location doesn't exist
|
||||
fail:
|
||||
msg: >-
|
||||
File configured in {{ tripleo_undercloud_conf_file }} {{ item.item.item }}
|
||||
does not exist
|
||||
when: not item.stat.exists
|
||||
loop: "{{ file_prop_stat.results }}"
|
||||
|
||||
- include_tasks: check_syntax.yml
|
Loading…
x
Reference in New Issue
Block a user