Import tripleo-bootstrap role

This change imports the tripleo-bootstrap role. Variables have been
broken-out into the new role structure which makes this role uniform
with other roles that have been created and imported.

* Molecule tests have been added to exercise this role on fed28 & cent7.

Change-Id: Ia9fe61d1793537796ff3fff8caf07ea7ea0a9dfd
Signed-off-by: Kevin Carter <kecarter@redhat.com>
changes/88/666288/5
Kevin Carter 4 years ago committed by Kevin Carter (cloudnull)
parent 7ce3a92ff5
commit 49f66705eb
  1. 23
      doc/source/roles/role-tripleo-bootstrap.rst
  2. 6
      tox.ini
  3. 14
      tripleo_ansible/roles/tripleo-bootstrap/README.md
  4. 30
      tripleo_ansible/roles/tripleo-bootstrap/defaults/main.yml
  5. 44
      tripleo_ansible/roles/tripleo-bootstrap/meta/main.yml
  6. 37
      tripleo_ansible/roles/tripleo-bootstrap/molecule/default/Dockerfile
  7. 68
      tripleo_ansible/roles/tripleo-bootstrap/molecule/default/molecule.yml
  8. 21
      tripleo_ansible/roles/tripleo-bootstrap/molecule/default/playbook.yml
  9. 21
      tripleo_ansible/roles/tripleo-bootstrap/molecule/default/prepare.yml
  10. 32
      tripleo_ansible/roles/tripleo-bootstrap/molecule/default/tests/test_default.py
  11. 15
      tripleo_ansible/roles/tripleo-bootstrap/molecule/default/verify.yml
  12. 117
      tripleo_ansible/roles/tripleo-bootstrap/tasks/main.yml
  13. 28
      tripleo_ansible/roles/tripleo-bootstrap/vars/fedora-28.yml
  14. 28
      tripleo_ansible/roles/tripleo-bootstrap/vars/redhat-8.yml
  15. 25
      tripleo_ansible/roles/tripleo-bootstrap/vars/redhat.yml
  16. 10
      zuul.d/molecule.yaml

@ -0,0 +1,23 @@
========================================
TripleO-Ansible Role - tripleo-bootstrap
========================================
This role provides for the following services:
* tripleo-bootstrap
Default variables
~~~~~~~~~~~~~~~~~
.. literalinclude:: ../../../tripleo_ansible/roles/tripleo-bootstrap/defaults/main.yml
:language: yaml
:start-after: under the License.
Example playbook
~~~~~~~~~~~~~~~~
.. literalinclude:: ../../../tripleo_ansible/roles/tripleo-bootstrap/molecule/default/playbook.yml
:language: yaml
:start-after: under the License.

@ -172,3 +172,9 @@ basepython = {[testenv:mol]basepython}
deps = {[testenv:mol]deps}
changedir = {toxinidir}/tripleo_ansible/roles/tuned
commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py
[testenv:mol-tripleo-bootstrap]
basepython = {[testenv:mol]basepython}
deps = {[testenv:mol]deps}
changedir = {toxinidir}/tripleo_ansible/roles/tripleo-bootstrap
commands = python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py

@ -0,0 +1,14 @@
tripleo-bootstrap
=================
An Ansible role to bootstrap a TripleO deployment.
Dependencies
------------
This role needs repositories to be deployed as it works now.
Author Information
------------------
OpenStack TripleO team

@ -0,0 +1,30 @@
---
# 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.
# All variables intended for modification should place placed in this file.
# List of packages that are requred to bootstrap TripleO.
tripleo_bootstrap_packages_bootstrap: "{{ _tripleo_bootstrap_packages_bootstrap | default([]) }}"
# List of packages that are required for legacy networking to function.
# NOTE: We are using 'network' service provided by 'network-scripts' (initscripts)
# which deprecated in recent releases but os-net-config doesn't support yet
# NetworkManager. Until it happens, we need to ensure that network is started
# at boot, as it'll take care of restarting the network interfaces managed by
# OVS. Note that OVS unit service is already configure to start before
# network.service.
tripleo_bootstrap_legacy_network_packages: "{{ _tripleo_bootstrap_legacy_network_packages | default([]) }}"

@ -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-bootstrap
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: []

@ -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"]

@ -0,0 +1,68 @@
---
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') }}"
command: /sbin/init
tmpfs:
- /run
- /tmp
capabilities:
- ALL # CENT7 requires all due to the age of the software
volumes:
- /run/udev:/run/udev:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- name: fedora28
hostname: fedora28
image: fedora:28
dockerfile: Dockerfile
pkg_extras: python*-setuptools
environment:
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
command: /sbin/init
privileged: true
tmpfs:
- /run
- /tmp
capabilities:
- SYS_ADMIN
volumes:
- /run/udev:/run/udev:ro
- /sys/fs/cgroup:/sys/fs/cgroup:ro
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

@ -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-bootstrap"

@ -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

@ -0,0 +1,32 @@
# 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 testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_package_installed(host):
assert host.package("puppet-tripleo").is_installed
def test_iptables_exists(host):
assert host.file("/etc/sysconfig/iptables").exists
assert host.file("/etc/sysconfig/ip6tables").exists

@ -0,0 +1,15 @@
---
# 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.

@ -0,0 +1,117 @@
---
# 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-bootstrap" will search for and load any operating system variable file
# found within the "vars/" path. If no OS files are found the task will skip.
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:
- skip: true
files:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
- "{{ ansible_os_family | lower }}.yml"
tags:
- always
- name: Deploy required packages to bootstrap TripleO
become: true
package:
name: "{{ tripleo_bootstrap_packages_bootstrap }}"
state: present
- name: Create /var/lib/heat-config/tripleo-config-download directory for deployment data
become: true
file:
path: /var/lib/heat-config/tripleo-config-download
state: directory
- name: Deploy and enable network service
become: true
when:
- (tripleo_bootstrap_legacy_network_packages | length) > 0
block:
- name: Deploy network-scripts required for deprecated network service
package:
name: "{{ tripleo_bootstrap_legacy_network_packages }}"
state: present
- name: Ensure network service is enabled
systemd:
name: network
enabled: true
- name: Find all installed puppet modules under /usr/share/openstack-puppet/modules
find:
paths:
- /usr/share/openstack-puppet/modules
file_type: directory
register: find_openstack_puppet_modules
- name: Symlink puppet modules under /etc/puppet/modules
become: true
file:
state: link
src: "{{ item.path }}"
path: "/etc/puppet/modules/{{ item.path | basename }}"
loop: "{{ find_openstack_puppet_modules.files }}"
loop_control:
label: "/etc/puppet/modules/{{ item.path | basename }} -> {{ item.path }}"
- name: Create empty ruleset in /etc/sysconfig/iptables and /etc/sysconfig/ip6tables
become: true
ignore_errors: "{{ (((ansible_os_family | lower) ~ '-' ~ ansible_distribution_major_version) == 'redhat-7') | bool }}"
copy:
dest: "{{ item }}"
content: "# empty ruleset created by deployed-server bootstrap"
loop:
- /etc/sysconfig/iptables
- /etc/sysconfig/ip6tables
- name: Check if /usr/bin/ansible-playbook exists
stat:
path: /usr/bin/ansible-playbook
register: stat_ansible_playbook
- name: Check if /usr/bin/ansible-playbook-3 exists
stat:
path: /usr/bin/ansible-playbook-3
register: stat_ansible_playbook_3
- name: Symlink /usr/local/bin/ansible-playbook to /usr/bin/ansible-playbook-3
become: true
file:
state: link
src: /usr/bin/ansible-playbook-3
path: /usr/local/bin/ansible-playbook
when:
- not stat_ansible_playbook.stat.exists
- stat_ansible_playbook_3.stat.exists
- name: Symlink /usr/local/bin/ansible-playbook-3 to /usr/bin/ansible-playbook
become: true
file:
state: link
src: /usr/bin/ansible-playbook
path: /usr/local/bin/ansible-playbook-3
when:
- stat_ansible_playbook.stat.exists
- not stat_ansible_playbook_3.stat.exists

@ -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.
_tripleo_bootstrap_packages_bootstrap:
- openstack-heat-agents
- jq
- puppet-tripleo
- os-net-config
- openvswitch
- openstack-selinux
- libselinux-python
_tripleo_bootstrap_legacy_network_packages:
- initscripts

@ -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.
_tripleo_bootstrap_packages_bootstrap:
- openstack-heat-agents
- jq
- puppet-tripleo
- os-net-config
- openvswitch
- openstack-selinux
- libselinux-python
_tripleo_bootstrap_legacy_network_packages:
- network-scripts

@ -0,0 +1,25 @@
---
# 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_bootstrap_packages_bootstrap:
- jq
- os-net-config
- openstack-heat-agents
- openstack-selinux
- openvswitch
- puppet-tripleo
- libselinux-python

@ -5,6 +5,7 @@
- tripleo-ansible-centos-7-molecule-aide
- tripleo-ansible-centos-7-molecule-test_deps
- tripleo-ansible-centos-7-molecule-test_package_action
- tripleo-ansible-centos-7-molecule-tripleo-bootstrap
- tripleo-ansible-centos-7-molecule-tuned
- tripleo-ansible-centos-7-role-addition
gate:
@ -12,6 +13,7 @@
- tripleo-ansible-centos-7-molecule-aide
- tripleo-ansible-centos-7-molecule-test_deps
- tripleo-ansible-centos-7-molecule-test_package_action
- tripleo-ansible-centos-7-molecule-tripleo-bootstrap
- tripleo-ansible-centos-7-molecule-tuned
- tripleo-ansible-centos-7-role-addition
name: tripleo-ansible-molecule-jobs
@ -37,6 +39,14 @@
parent: tripleo-ansible-centos
vars:
tox_envlist: mol-test_package_action
- job:
files:
- ^tripleo_ansible/roles/tripleo-bootstrap/.*
name: tripleo-ansible-centos-7-molecule-tripleo-bootstrap
parent: tripleo-ansible-centos
timeout: 1800
vars:
tox_envlist: mol-tripleo-bootstrap
- job:
files:
- ^roles/tuned/.*

Loading…
Cancel
Save