Import Hiera roles

The hiera roles (data and upgrade) have been imported. These roles will now
be tested using molecule which will ensure functionality via multiple
scenarios tests which should provide coverage for all currently available
code path's.

Because these roles use the ip filter from Ansible a change to the test
requirements has been made to include the require python library, netaddr.

Hieradata Test Matrix:
  - Default - Runs through the role top to bottom with all default
              settings
  - hieradata_vars - Rests role include functionality to generate
                     hiera templates
  - per-host - Tests running with hiera config with host specific
               values
  - all-hosts - Tests running through a standard multi-node deployment
                using mock hieradata

Hiera Upgrade Test Matix:
  - Default - Runs through the role top to bottom with all default
              settings

To ensure we maintain coverage for the hieradata and upgrade roles
additional voting scenario jobs have been added to the layout. These
jobs will execute whenever a change is made to either of the hiera
roles ensuring we're not experiencing any regressions on a critical
part of our deployment process.

Story: 2006044
Task: 34726
Task: 34728
Task: 34729
Story: 2006044
Task: 34730
Task: 34732
Task: 34733
Change-Id: I7f9e993735a0347aac12f728393639d88c80ff0f
Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
Kevin Carter 2019-07-24 10:46:02 -05:00 committed by Kevin Carter
parent 9204dbce60
commit 9743b73de6
54 changed files with 2795 additions and 22 deletions

View File

@ -0,0 +1,6 @@
========================
Role - tripleo-hieradata
========================
.. ansibleautoplugin::
:role: tripleo_ansible/roles/tripleo-hieradata

View File

@ -0,0 +1,6 @@
============================
Role - tripleo-upgrade-hiera
============================
.. ansibleautoplugin::
:role: tripleo_ansible/roles/tripleo-upgrade-hiera

View File

@ -1 +1,2 @@
pre-commit # MIT
pre-commit # MIT
netaddr # BSD

View File

@ -0,0 +1,54 @@
---
# 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.
# `hieradata_content` can be formatted for all hosts or for specific hosts
# containing potentially different values.
#
# Host specific example:
#
# controller1:
# extraconfig:
# foo: bar
# foo2: bar2
# other_hierafile:
# foo: bar3
# controller2:
# extraconfig:
# foo: bar2
# foo2: bar3
# other_hierafile:
# foo: bar
#
#
# Global format example:
#
# extraconfig:
# foo: bar
# foo2: bar2
# other_hierafile:
# foo: bar3
#
hieradata_template: ""
hieradata_files: []
# jinja2 escape trick for simple {{ and }} strings:
hieradata_variable_start_string: "{{ '{{' }}"
hieradata_variable_end_string: "{{ '}}' }}"
hieradata_per_host: false
hieradata_templates_list:
- bootstrap_node
- all_nodes
- vip_data

View File

@ -0,0 +1,22 @@
---
# 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: Cleanup temp file
file:
path: "{{ tempfile_1.path }}"
state: absent
delegate_to: localhost
connection: local

View File

@ -0,0 +1,44 @@
---
# 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.
galaxy_info:
author: OpenStack
description: TripleO OpenStack Role -- tripleo-hieradata
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.7
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Fedora
versions:
- 28
- name: CentOS
versions:
- 7
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@ -0,0 +1,37 @@
# Molecule managed
# 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.
{% 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 python 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"]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
dockerfile: Dockerfile
pkg_extras: python-setuptools
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
- name: fedora28
hostname: fedora28
image: fedora:28
dockerfile: Dockerfile
pkg_extras: python*-setuptools
environment:
<<: *env
provisioner:
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,22 @@
---
# 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: Converge
hosts: all
roles:
- role: tripleo-hieradata
hieradata_template: "{{ playbook_dir }}/mock-hieradata.j2.yaml"

View File

@ -0,0 +1,21 @@
---
# 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
roles:
- role: test_deps

View File

@ -0,0 +1,28 @@
# 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.
import os
import json
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_hieradata_files(host):
assert host.file("/etc/puppet/hieradata/standalone_extraconfig.json").exists

View File

@ -0,0 +1,37 @@
# Molecule managed
# 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.
{% 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 python 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"]

View File

@ -0,0 +1,48 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
dockerfile: Dockerfile
pkg_extras: python-setuptools
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
- name: fedora28
hostname: fedora28
image: fedora:28
dockerfile: Dockerfile
pkg_extras: python*-setuptools
environment:
<<: *env
provisioner:
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,21 @@
---
# 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: Converge
hosts: all
roles:
- role: tripleo-hieradata

View File

@ -0,0 +1,21 @@
---
# 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
roles:
- role: test_deps

View File

@ -0,0 +1,37 @@
# Molecule managed
# 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.
{% 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 python 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"]

View File

@ -0,0 +1,3 @@
---
datafiles: {}

View File

@ -0,0 +1,225 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
dockerfile: Dockerfile
pkg_extras: python-setuptools
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
- name: fedora28
hostname: fedora28
image: fedora:28
dockerfile: Dockerfile
pkg_extras: python*-setuptools
environment:
<<: *env
provisioner:
name: ansible
inventory:
hosts:
all:
vars:
all_nodes_extra_map_data: {}
bootstrap_nodeid: standalone
cloud_domain: localdomain
cloud_names:
cloud_name_ctlplane: standalone.ctlplane.localdomain
container_cli: podman
control_virtual_ip: 192.168.24.1
ctlplane_ip: 192.168.24.2
ctlplane_subnet_cidr: 24
deploy_artifact_urls: ''
deploy_identifier: '1564455089'
deploy_steps_max: 6
enable_internal_tls: false
enabled_networks: []
enabled_services:
- keystone_admin_api
- keystone_public_api
- ca_certs
- ceph_client
- ceph_mds
- ceph_mgr
- ceph_mon
- ceph_rgw
- ceph_osd
- certmonger_user
- clustercheck
- container_image_prepare
- logrotate_crond
- docker
- docker_registry
- glance_api
- haproxy
- iscsid
- kernel
- keystone
- manila_api
- manila_backend_cephfs
- manila_scheduler
- manila_share
- memcached
- mysql
- mysql_client
- neutron_api
- neutron_plugin_ml2_ovn
- nova_api
- nova_compute
- nova_conductor
- nova_libvirt
- nova_metadata
- nova_migration_target
- nova_scheduler
- nova_vnc_proxy
- ovn_controller
- ovn_dbs
- ovn_metadata
- openstack_clients
- oslo_messaging_notify
- oslo_messaging_rpc
- pacemaker
- placement
- podman
- snmp
- sshd
- chrony
- timezone
- logrotate_tmpwatch
- tripleo_firewall
- tripleo_packages
- tuned
extraconfig:
foo: bar1
foo2: bar2
hosts_entry: '
192.168.24.1 standalone.localdomain standalone
192.168.24.1 standalone.ctlplane.localdomain standalone.ctlplane
'
net_vip_map:
ctlplane: 192.168.24.1
ctlplane_subnet: 192.168.24.1/24
ctlplane_uri: 192.168.24.1
redis: 192.168.24.1
network_virtual_ips:
ctlplane:
index: 1
ip_address: 192.168.24.1
network_cidrs:
External_cidr: 192.168.24.2/24
networks: null
nova_additional_cell: false
ping_test_ips:
Standalone: 192.168.24.1
primary_role_name: Standalone
role_networks:
- Internal
service_configs:
foo: bar3
service_net_map:
aodh_api_network: ctlplane
apache_network: ctlplane
barbican_api_network: ctlplane
bindnetwork: ctlplane
ceph_cluster_network: ctlplane
ceph_grafana_network: ctlplane
ceph_mon_network: ctlplane
ceph_rgw_network: ctlplane
cinder_api_network: ctlplane
cinder_iscsi_network: ctlplane
designate_api_network: ctlplane
docker_registry_network: ctlplane
ec2_api_metadata_network: ctlplane
ec2_api_network: ctlplane
etcd_network: ctlplane
ganesha_network: ctlplane
glance_api_network: ctlplane
gnocchi_api_network: ctlplane
haproxy_network: ctlplane
heat_api_cfn_network: ctlplane
heat_api_cloudwatch_network: ctlplane
heat_api_network: ctlplane
horizon_network: ctlplane
ironic_api_network: ctlplane
ironic_inspector_network: ctlplane
ironic_network: ctlplane
keystone_admin_api_network: ctlplane
keystone_public_api_network: ctlplane
manila_api_network: ctlplane
memcached_network: ctlplane
metrics_qdr_network: ctlplane
mistral_api_network: ctlplane
mongodb_network: ctlplane
mysql_network: ctlplane
neutron_api_network: ctlplane
neutron_tenant_network: ctlplane
nova_api_network: ctlplane
nova_libvirt_network: ctlplane
nova_metadata_network: ctlplane
nova_vnc_proxy_network: ctlplane
novajoin_network: ctlplane
octavia_api_network: ctlplane
opendaylight_api_network: ctlplane
openshift_infra_network: ctlplane
openshift_master_network: ctlplane
oslo_messaging_notify_network: ctlplane
oslo_messaging_rpc_network: ctlplane
ovn_dbs_network: ctlplane
pacemaker_network: ctlplane
pacemaker_remote_network: ctlplane
panko_api_network: ctlplane
placement_network: ctlplane
public_network: ctlplane
qdr_network: ctlplane
rabbitmq_network: ctlplane
redis_network: ctlplane
sahara_api_network: ctlplane
snmpd_network: ctlplane
standalone_hostname_resolve_network: ctlplane
swift_proxy_network: ctlplane
swift_storage_network: ctlplane
tacker_api_network: ctlplane
zaqar_api_network: ctlplane
stack_action: CREATE
stack_update_type: ''
validate_controllers_icmp: true
validate_fqdn: false
validate_gateways_icmp: true
validate_ntp: true
Standalone:
hosts:
fedora28: {}
centos7: {}
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,46 @@
---
# 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: Converge
hosts: all
pre_tasks:
- name: Create puppet hieradata directory
file:
path: /etc/puppet/hieradata
state: directory
- name: Set mock network ip facts
set_fact:
CTRLPlane_ip: 192.168.24.2
ctlplane_ip: 192.168.24.2
Internal_ip: 192.168.25.2
tasks:
- name: Create hieradata from templates
include_role:
name: tripleo-hieradata
tasks_from: hieradata_vars.yaml
vars:
hieradata_templates_list:
- all_nodes
- bootstrap_node
- cloud_domain
- extraconfig
- fqdn
- net_ip_map
- service_configs
- vip_data

View File

@ -0,0 +1,21 @@
---
# 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
roles:
- role: test_deps

View File

@ -0,0 +1,44 @@
# 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.
import os
import json
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_json_render(host):
rendered_files = [
"all_nodes",
"bootstrap_node",
"cloud_domain",
"extraconfig",
"fqdn",
"net_ip_map",
"service_configs",
"vip_data"
]
for f in rendered_files:
json.loads(
host.file(
'/etc/puppet/hieradata/{}.json'.format(f)
).content_string
)

View File

@ -0,0 +1,37 @@
# Molecule managed
# 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.
{% 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 python 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"]

View File

@ -0,0 +1,16 @@
---
fedora28:
datafiles:
extraconfig:
foo: bar1
foo2: bar2
service_configs:
foo: bar3
centos7:
datafiles:
extraconfig:
foo: bar1
foo2: bar2
service_configs:
foo: bar3

View File

@ -0,0 +1,48 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
dockerfile: Dockerfile
pkg_extras: python-setuptools
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
- name: fedora28
hostname: fedora28
image: fedora:28
dockerfile: Dockerfile
pkg_extras: python*-setuptools
environment:
<<: *env
provisioner:
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,26 @@
---
# 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: Converge
hosts: all
roles:
- role: tripleo-hieradata
hieradata_template: "{{ playbook_dir }}/mock-hieradata.j2.yaml"
hieradata_per_host: true
hieradata_files:
- node
- common

View File

@ -0,0 +1,21 @@
---
# 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
roles:
- role: test_deps

View File

@ -0,0 +1,29 @@
# 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.
import os
import json
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_hieradata_files(host):
assert host.file("/etc/puppet/hieradata/extraconfig.json").exists
assert host.file("/etc/puppet/hieradata/service_configs.json").exists

View File

@ -0,0 +1,24 @@
---
# 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: Copy hieradata files
copy:
dest: /etc/puppet/hieradata/{{ item.key }}.json
mode: 0600
content: "{{ item.value }}"
loop: "{{ hieradata_content['datafiles'] | default({}) | dict2items }}"
loop_control:
label: "{{ item.key }}"

View File

@ -0,0 +1,21 @@
---
# 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: Render hieradata from template
template:
src: templates/{{ item }}.j2
dest: "{{ dest_path | default('/etc/puppet/hieradata/' ~ item ~ '.json') }}"
loop: "{{ hieradata_templates_list }}"

View File

@ -0,0 +1,74 @@
---
# 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: Create /etc/puppet/hieradata
file:
path: /etc/puppet/hieradata
state: directory
mode: 0700
- name: Write hiera config
when:
- (hieradata_files | length) > 0
copy:
mode: 0600
dest: /etc/puppet/hiera.yaml
# TODO(emilien) Switch to Hiera5 format once we stop calling Hiera CLI
# which is deprecated and should be replaced by "puppet lookup" command.
content: |
---
:backends:
- json
:json:
:datadir: /etc/puppet/hieradata
:hierarchy:
{{ hieradata_files }}
- name: hieradata block
run_once: true
block:
- name: Create temporary file
tempfile:
state: file
suffix: temp
register: tempfile_1
changed_when: false
notify:
- Cleanup temp file
- name: Template hieradata file
template:
src: "{{ hieradata_template }}"
dest: "{{ tempfile_1.path }}"
variable_start_string: "{{ hieradata_variable_start_string }}"
variable_end_string: "{{ hieradata_variable_end_string }}"
changed_when: false
when:
- (hieradata_template | string)
notify:
- Cleanup temp file
- name: Read temp file
slurp:
src: "{{ tempfile_1.path }}"
register: tempfile_1_slurp
changed_when: false
notify:
- Cleanup temp file
- include_tasks: "{{ (hieradata_per_host | bool) | ternary('per_host.yml', 'all_hosts.yml') }}"
vars:
hieradata_content: "{{ tempfile_1_slurp['content'] | b64decode | from_yaml }}"

View File

@ -0,0 +1,22 @@
---
# 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: Copy hieradata for host {{ inventory_hostname }}
copy:
dest: "/etc/puppet/hieradata/{{ item }}.json"
mode: 0600
content: "{{ hieradata_content[inventory_hostname]['datafiles'][item] }}"
loop: "{{ hieradata_content[inventory_hostname]['datafiles'] | list }}"

View File

@ -0,0 +1,42 @@
{% set all_nodes = {} %}
{% set _ = all_nodes.__setitem__('enabled_services', (enabled_services | unique)) %}
{% for service in enabled_services %}
{# <service>_enabled: true #}
{% set _ = all_nodes.__setitem__((service ~ '_enabled'), true) %}
{# <service>_node_ips: <list of ips> #}
{% set _ = all_nodes.__setitem__((service ~ '_node_ips'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_ip') | list)) %}
{% if nova_additional_cell %}
{# <service>_cell_node_names: <list of hostnames> #}
{% set _ = all_nodes.__setitem__((service ~ '_cell_node_names'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_hostname') | list)) %}
{% else %}
{# <service>_node_names: <list of hostnames> #}
{% set _ = all_nodes.__setitem__((service ~ '_node_names'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_hostname') | list)) %}
{% endif %}
{# <service>_short_node_names: <list of hostnames> #}
{% set _ = all_nodes.__setitem__((service ~ '_short_node_names'), (groups[service] | default ([]) | map('extract', hostvars, 'inventory_hostname') | list)) %}
{# <service>_short_bootstrap_node_name: hostname #}
{% set services = (groups[service] | default ([]) | map('extract', hostvars, 'inventory_hostname')) | list %}
{% if (services | length) > 0 %}
{% set _ = all_nodes.__setitem__((service ~ '_short_bootstrap_node_name'), (services | first)) %}
{% endif %}
{# <service>_bootstrap_node_ip: hostname #}
{% set services = (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_ip')) | list %}
{% if (services | length) > 0 %}
{% set _ = all_nodes.__setitem__((service ~ '_bootstrap_node_ip'), (services | first)) %}
{% endif %}
{% endfor %}
{# <service>_network: <network> #}
{% for key, value in service_net_map.items() %}
{% set _ = all_nodes.__setitem__(key, value) %}
{% endfor %}
{% if 'redis' in enabled_services %}
{% set _ = all_nodes.__setitem__('redis_vip', (net_vip_map.redis)) %}
{% endif %}
{% set _ = all_nodes.__setitem__('deploy_identifier', deploy_identifier) %}
{% set _ = all_nodes.__setitem__('stack_action', stack_action) %}
{% set _ = all_nodes.__setitem__('stack_update_type', stack_update_type) %}
{% set _ = all_nodes.__setitem__('container_cli', container_cli) %}
{% set _ = all_nodes.__setitem__('controller_node_ips', (groups[primary_role_name] | default([]) | map('extract', hostvars, 'ctlplane_ip') | list | join(','))) %}
{% set _ = all_nodes.__setitem__('controller_node_names', (groups[primary_role_name] | default([]) | map('extract', hostvars, 'inventory_hostname') | list | join(','))) %}
{# RENDER #}
{{ all_nodes | to_nice_json }}

View File

@ -0,0 +1,4 @@
{% set boostrap_node = {} %}
{% set _ = boostrap_node.__setitem__('boostrap_node_id', bootstrap_nodeid) %}
{# RENDER #}
{{ boostrap_node | to_nice_json }}

View File

@ -0,0 +1,4 @@
{% set cloud_domain_data = {} %}
{% set _ = cloud_domain_data.__setitem__('tripleo::clouddomain', cloud_domain) %}
{# RENDER #}
{{ cloud_domain_data | to_nice_json }}

View File

@ -0,0 +1 @@
{{ extraconfig | default({}) | to_nice_json }}

View File

@ -0,0 +1,12 @@
{% set fqdn = {} %}
{% set _ = fqdn.__setitem__('fqdn_ctlplane', (inventory_hostname ~ '.ctlplane.' ~ cloud_domain)) %}
{% set _ = fqdn.__setitem__('fqdn_canonical', (inventory_hostname ~ '.' ~ cloud_domain)) %}
{% if role_networks %}
{% for network in enabled_networks %}
{% if network in role_networks %}
{% set _ = fqdn.__setitem__(('fqdn_' ~ networks[network]['name_lower']), (inventory_hostname ~ '.' ~ network | lower ~ '.' ~ cloud_domain)) %}
{% endif %}
{% endfor %}
{% endif %}
{# RENDER #}
{{ fqdn | to_nice_json }}

View File

@ -0,0 +1,18 @@
{% set net_ip_map = {} %}
{% set _ = net_ip_map.__setitem__('ctlplane', ctlplane_ip) %}
{% set _ = net_ip_map.__setitem__('ctlplane_subnet', ctlplane_ip ~ '/' ~ ctlplane_subnet_cidr) %}
{% set _ = net_ip_map.__setitem__('ctlplane_uri', (ctlplane_ip | ipwrap)) %}
{% for network in enabled_networks %}
{% if network_cidrs and ((network ~ '_cidr') in network_cidrs) %}
{% set _ = net_ip_map.__setitem__(networks[network]['name'], (hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'])) %}
{% set _ = net_ip_map.__setitem__((networks[network]['name'] ~ '_subnet'), (hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'] ~ '/' ~ network_cidrs[network ~ '_cidr'])) %}
{% set _ = net_ip_map.__setitem__((networks[network]['name'] ~ '_uri'), (hostvars[inventory_hostname][networks[network]['name'] ~ '_ip'] | ipwrap)) %}
{% else %}
{# just add empty entries for this network if it doesn't apply to this role. matches previous behavior from Heat #}
{% set _ = net_ip_map.__setitem__(networks[network]['name'], "") %}
{% set _ = net_ip_map.__setitem__((networks[network]['name'] ~ '_subnet'), "") %}
{% set _ = net_ip_map.__setitem__((networks[network]['name'] ~ '_uri'), "") %}
{% endif %}
{% endfor %}
{# RENDER #}
{{ net_ip_map | to_nice_json }}

View File

@ -0,0 +1 @@
{{ role_extraconfig | default({}) | to_nice_json }}

View File

@ -0,0 +1 @@
{{ service_configs | default({}) | to_nice_json }}

View File

@ -0,0 +1,45 @@
{% set vip_data = {} %}
{% set _ = vip_data.__setitem__('controller_virtual_ip', control_virtual_ip) %}
{% set _ = vip_data.__setitem__('keystone_admin_api_vip', (net_vip_map[service_net_map['keystone_admin_api_network']])) %}
{% set _ = vip_data.__setitem__('keystone_public_api_vip', (net_vip_map[service_net_map['keystone_public_api_network']])) %}
{% if 'External' in enabled_networks %}
{% set _ = vip_data.__setitem__('public_virtual_ip', (net_vip_map[networks['External']['name_lower']])) %}
{% else %}
{% set _ = vip_data.__setitem__('public_virtual_ip', (net_vip_map.ctlplane)) %}
{% endif %}
{% if 'InternalApi' in enabled_networks %}
{# the internal_api_virtual_ip is needed for contrail only #}
{% set _ = vip_data.__setitem__('internal_api_virtual_ip', (net_vip_map[networks['InternalApi']['name_lower']])) %}
{% endif %}
{% set _ = vip_data.__setitem__('network_virtual_ips', network_virtual_ips) %}
{% for network in enabled_networks %}
{% if network == 'StorageNFS' %}
{% set _ = vip_data.__setitem__('ganesha_vip', (net_vip_map[storagenfs_net_name])) %}
{% endif %}
{% endfor %}
{# public_virtual_ip and controller_virtual_ip are needed in both HAproxy & keepalived. #}
{% if 'External' in enabled_networks %}
{% set _ = vip_data.__setitem__('tripleo::haproxy::public_virtual_ip', (net_vip_map[networks['External']['name_lower']])) %}
{% set _ = vip_data.__setitem__('tripleo::keepalived::public_virtual_ip', (net_vip_map[networks['External']['name_lower']])) %}
{% else %}
{% set _ = vip_data.__setitem__('tripleo::haproxy::public_virtual_ip', (net_vip_map.ctlplane)) %}
{% set _ = vip_data.__setitem__('tripleo::keepalived::public_virtual_ip', (net_vip_map.ctlplane)) %}
{% endif %}
{% set _ = vip_data.__setitem__('tripleo::haproxy::controller_virtual_ip', (net_vip_map.ctlplane)) %}
{% set _ = vip_data.__setitem__('tripleo::keepalived::controller_virtual_ip', (net_vip_map.ctlplane)) %}
{% set _ = vip_data.__setitem__('tripleo::keepalived::redis_virtual_ip', (net_vip_map.redis)) %}
{% set _ = vip_data.__setitem__('tripleo::redis_notification::haproxy_monitor_ip', (net_vip_map.ctlplane)) %}
{% for key, value in cloud_names.items() %}
{% set _ = vip_data.__setitem__(key, value) %}
{% endfor %}
{% set _ = vip_data.__setitem__('enable_internal_tls', (enable_internal_tls | lower | bool)) %}
{% for service in enabled_services %}
{% if service_net_map.get(service ~ '_network', 'noop') in net_vip_map %}
{# we set explicit vips for these services, no need to calculate them dynamically #}
{% if service not in ['redis', 'ganesha', 'keystone_admin_api_vip', 'keystone_public_api_vip'] %}
{% set _ = vip_data.__setitem__((service ~ '_vip'), (net_vip_map[service_net_map[service ~ '_network']])) %}
{% endif %}
{% endif %}
{% endfor %}
{# RENDER #}
{{ vip_data | to_nice_json }}

View File

@ -0,0 +1,17 @@
---
# 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.
tripleo_upgrade_hiera_file: /etc/puppet/hieradata/upgrade.json

View File

@ -0,0 +1,44 @@
---
# 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.
galaxy_info:
author: OpenStack
description: TripleO OpenStack Role -- tripleo-upgrade-hiera
company: Red Hat
license: Apache-2.0
min_ansible_version: 2.7
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Fedora
versions:
- 28
- name: CentOS
versions:
- 7
galaxy_tags:
- tripleo
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
dependencies: []

View File

@ -0,0 +1,37 @@
# Molecule managed
# 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.
{% 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 python 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"]

View File

@ -0,0 +1,48 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
dockerfile: Dockerfile
pkg_extras: python-setuptools
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
- name: fedora28
hostname: fedora28
image: fedora:28
dockerfile: Dockerfile
pkg_extras: python*-setuptools
environment:
<<: *env
provisioner:
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,62 @@
---
# 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: Converge
hosts: all
roles:
- role: tripleo-upgrade-hiera
post_tasks:
- name: test tripleo-upgrade-hiera - add a first value
include_role:
name: tripleo-upgrade-hiera
tasks_from: set.yml
vars:
tripleo_upgrade_key: pacemaker_short_node_names_override
tripleo_upgrade_value:
- "controller-0"
- name: test tripleo-upgrade-hiera - add another value
include_role:
name: tripleo-upgrade-hiera
tasks_from: set.yml
vars:
tripleo_upgrade_key: mysql_short_node_names_override
tripleo_upgrade_value:
- "controller-0"
- "controller-1"
- name: test tripleo-upgrade-hiera - update a value
include_role:
name: tripleo-upgrade-hiera
tasks_from: set.yml
vars:
tripleo_upgrade_key: mysql_short_node_names_override
tripleo_upgrade_value:
- "controller-1"
- name: test tripleo-upgrade-hiera - remove a value
include_role:
name: tripleo-upgrade-hiera
tasks_from: remove.yml
vars:
tripleo_upgrade_key: pacemaker_short_node_names_override
- name: test tripleo-upgrade-hiera - remove all values
include_role:
name: tripleo-upgrade-hiera
tasks_from: remove-all.yml

View File

@ -0,0 +1,21 @@
---
# 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
roles:
- role: test_deps

View File

@ -0,0 +1,54 @@
---
# 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: create the directory for hiera file
file:
path: "{{ tripleo_upgrade_hiera_file | dirname }}"
owner: "root"
group: "root"
mode: 0755
state: directory
become: true
- name: check if the upgrade file exists.
stat:
path: "{{ tripleo_upgrade_hiera_file }}"
register: _tripleo_upgrade_hiera_file
become: true
- name: check if the file contains valid json
command: "jq . {{ tripleo_upgrade_hiera_file }}"
register: _tripleo_upgrade_hiera_test
become: true
when:
- _tripleo_upgrade_hiera_file.stat.exists | bool
- name: create the hiera file when no file or empty file.
copy:
dest: "{{ tripleo_upgrade_hiera_file }}"
owner: "root"
group: "root"
mode: 0644
content: "{}"
become: true
when:
- not (_tripleo_upgrade_hiera_file.stat.exists | bool) or
(_tripleo_upgrade_hiera_test.stdout | length) > 0
- name: load the json hiera data
command: "jq . {{ tripleo_upgrade_hiera_file }}"
register: tripleo_upgrade_hiera_command
become: true

View File

@ -0,0 +1,21 @@
---
# 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: Install jq package
package:
name: jq
state: present

View File

@ -0,0 +1,21 @@
---
# 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: delete the upgrade hiera file
file:
path: "{{ tripleo_upgrade_hiera_file }}"
state: absent
become: true

View File

@ -0,0 +1,37 @@
---
# 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: ensure tripleo-upgrade hiera file exists
include_tasks: create-tripleo-upgrade-file.yml
- name: reset tripleo_upgrade_hiera_data_del fact
set_fact:
tripleo_upgrade_hiera_data_del: {}
- name: remove a tripleo-upgrade key
set_fact:
tripleo_upgrade_hiera_data_del: "{{ tripleo_upgrade_hiera_data_del|combine({upgrade_hiera_item.key: upgrade_hiera_item.value}) }}"
cacheable: false
when: upgrade_hiera_item.key != tripleo_upgrade_key
loop_control:
loop_var: upgrade_hiera_item
loop: "{{ tripleo_upgrade_hiera_command.stdout | from_json | default({}) | dict2items }}"
- name: write the updated tripleo-upgrade hiera data
copy:
content: "{{ tripleo_upgrade_hiera_data_del | to_nice_json }}"
dest: "{{ tripleo_upgrade_hiera_file }}"
become: true

View File

@ -0,0 +1,29 @@
---
# 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: ensure tripleo-upgrade hiera file exists
include_tasks: create-tripleo-upgrade-file.yml
- name: set/update the tripleo-upgrade key/value
set_fact:
tripleo_upgrade_hiera_data_add: "{{ tripleo_upgrade_hiera_command.stdout | from_json | combine({ tripleo_upgrade_key: tripleo_upgrade_value }) }}"
cacheable: false
- name: write the updated tripleo-upgrade hiera data
copy:
content: "{{ tripleo_upgrade_hiera_data_add | to_nice_json }}"
dest: "{{ tripleo_upgrade_hiera_file }}"
become: true

View File

@ -7,40 +7,55 @@
jobs:
- openstack-tox-linters
- tripleo-ansible-docs
- tripleo-ci-centos-7-scenario004-standalone:
files: &scenario004
- ^tripleo_ansible/.*
- tripleo-ci-centos-7-containers-multinode: &containers_multinode
files:
- ^tripleo_ansible/roles/tripleo-hieradata/.*
- ^tripleo_ansible/roles/tripleo-upgrade-hiera/.*
irrelevant-files: &irrelevant_scenario_files
- .*.md$
- .*.rst$
- .*.txt$
- ^tripleo_ansible/.*molecule.*
- ^tripleo_ansible/.*meta.*
- tripleo-ci-centos-7-scenario010-standalone:
files: &scenario010
- tripleo-ci-centos-7-scenario001-standalone: &scenario001
files:
- ^tripleo_ansible/roles/tripleo-hieradata/.*
- ^tripleo_ansible/roles/tripleo-upgrade-hiera/.*
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario002-standalone: &scenario002
files:
- ^tripleo_ansible/roles/tripleo-hieradata/.*
- ^tripleo_ansible/roles/tripleo-upgrade-hiera/.*
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario003-standalone: &scenario003
files:
- ^tripleo_ansible/roles/tripleo-create-admin/.*
- ^tripleo_ansible/roles/tripleo-hieradata/.*
- ^tripleo_ansible/roles/tripleo-upgrade-hiera/.*
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario004-standalone: &scenario004
files:
- ^tripleo_ansible/.*
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario010-standalone: &scenario010
files:
- ^tripleo_ansible/.*octavia.*
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario003-standalone:
files: &scenario003
- ^tripleo_ansible/roles/tripleo-create-admin/.*
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario012-standalone:
files: &scenario012
- ^tripleo_ansible/roles/tripleo-module-load/.*
- tripleo-ci-centos-7-standalone-upgrade: &standalone_upgrade
files:
- ^tripleo_ansible/roles/tripleo-hieradata/.*
- ^tripleo_ansible/roles/tripleo-upgrade-hiera/.*
irrelevant-files: *irrelevant_scenario_files
gate:
jobs:
- openstack-tox-linters
- tripleo-ansible-docs
- tripleo-ci-centos-7-scenario004-standalone:
files: *scenario004
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario010-standalone:
files: *scenario010
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-scenario003-standalone:
files: *scenario003
irrelevant-files: *irrelevant_scenario_files
- tripleo-ci-centos-7-containers-multinode: *containers_multinode
- tripleo-ci-centos-7-scenario001-standalone: *scenario001
- tripleo-ci-centos-7-scenario002-standalone: *scenario002
- tripleo-ci-centos-7-scenario003-standalone: *scenario003
- tripleo-ci-centos-7-scenario004-standalone: *scenario004
- tripleo-ci-centos-7-scenario010-standalone: *scenario010
post:
jobs:
- publish-openstack-python-branch-tarball

View File

@ -24,6 +24,8 @@
- tripleo-ansible-centos-7-molecule-tripleo-timezone
- tripleo-ansible-centos-7-molecule-tripleo-config
- tripleo-ansible-centos-7-molecule-tripleo-container-stop
- tripleo-ansible-centos-7-molecule-tripleo-hieradata
- tripleo-ansible-centos-7-molecule-tripleo-upgrade-hiera
gate:
jobs:
- tripleo-ansible-centos-7-molecule-aide
@ -48,6 +50,8 @@
- tripleo-ansible-centos-7-molecule-tripleo-timezone
- tripleo-ansible-centos-7-molecule-tripleo-config
- tripleo-ansible-centos-7-molecule-tripleo-container-stop
- tripleo-ansible-centos-7-molecule-tripleo-hieradata
- tripleo-ansible-centos-7-molecule-tripleo-upgrade-hiera
name: tripleo-ansible-molecule-jobs
- job:
files:
@ -209,3 +213,17 @@
parent: tripleo-ansible-centos-7-base
vars:
tripleo_role_name: tripleo-container-stop
- job:
files:
- ^tripleo_ansible/roles/tripleo-hieradata/.*
name: tripleo-ansible-centos-7-molecule-tripleo-hieradata
parent: tripleo-ansible-centos-7-base
vars:
tripleo_role_name: tripleo-hieradata
- job:
files:
- ^tripleo_ansible/roles/tripleo-upgrade-hiera/.*
name: tripleo-ansible-centos-7-molecule-tripleo-upgrade-hiera
parent: tripleo-ansible-centos-7-base
vars:
tripleo_role_name: tripleo-upgrade-hiera