Introduce tripleo-config role
This basic role will provide an interface to TripleO so we can consume the ansible-config_template action plugin to generate configuration files. Change-Id: I4e28be86e28dd227a682362af56833fe97035a88 Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
c1e098de6d
commit
96b9fc6540
@ -1,9 +1,9 @@
|
||||
export TRIPLEO_ANSIBLE_WORKPATH="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
|
||||
export ANSIBLE_STDOUT_CALLBACK=debug
|
||||
export ANSIBLE_ACTION_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/action"
|
||||
export ANSIBLE_ACTION_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/roles.galaxy/config_template/action:${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/action"
|
||||
export ANSIBLE_CALLBACK_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/callback"
|
||||
export ANSIBLE_FILTER_PLUGINS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/filter"
|
||||
export ANSIBLE_LIBRARY="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/modules"
|
||||
export ANSIBLE_LIBRARY="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/roles.galaxy/config_template/library:${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/modules"
|
||||
export ANSIBLE_MODULE_UTILS="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/ansible_plugins/module_utils"
|
||||
export ANSIBLE_ROLES_PATH="${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/roles.galaxy:${TRIPLEO_ANSIBLE_WORKPATH}/tripleo_ansible/roles"
|
||||
export ANSIBLE_INVENTORY="${TRIPLEO_ANSIBLE_WORKPATH}/tests/hosts.ini"
|
||||
|
6
doc/source/roles/role-tripleo-config.rst
Normal file
6
doc/source/roles/role-tripleo-config.rst
Normal file
@ -0,0 +1,6 @@
|
||||
=====================
|
||||
Role - tripleo-config
|
||||
=====================
|
||||
|
||||
.. ansibleautoplugin::
|
||||
:role: tripleo_ansible/roles/tripleo-config
|
4
tox.ini
4
tox.ini
@ -9,10 +9,10 @@ install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/
|
||||
passenv = *
|
||||
setenv =
|
||||
VIRTUAL_ENV={envdir}
|
||||
ANSIBLE_ACTION_PLUGINS={toxinidir}/tripleo_ansible/ansible_plugins/action
|
||||
ANSIBLE_ACTION_PLUGINS={toxinidir}/tripleo_ansible/roles.galaxy/config_template/action:{toxinidir}/tripleo_ansible/ansible_plugins/action
|
||||
ANSIBLE_CALLBACK_PLUGINS={toxinidir}/tripleo_ansible/ansible_plugins/callback
|
||||
ANSIBLE_FILTER_PLUGINS={toxinidir}/tripleo_ansible/ansible_plugins/filter
|
||||
ANSIBLE_LIBRARY={toxinidir}/tripleo_ansible/ansible_plugins/modules
|
||||
ANSIBLE_LIBRARY={toxinidir}/tripleo_ansible/roles.galaxy/config_template/library:{toxinidir}/tripleo_ansible/ansible_plugins/modules
|
||||
ANSIBLE_MODULE_UTILS={toxinidir}/tripleo_ansible/ansible_plugins/module_utils
|
||||
ANSIBLE_ROLES_PATH={toxinidir}/tripleo_ansible/roles.galaxy:{toxinidir}/tripleo_ansible/roles
|
||||
ANSIBLE_INVENTORY={toxinidir}/tests/hosts.ini
|
||||
|
@ -16,6 +16,13 @@
|
||||
|
||||
- name: openstack-operations
|
||||
scm: git
|
||||
src: https://github.com/openstack/ansible-role-openstack-operations
|
||||
src: https://opendev.org/openstack/ansible-role-openstack-operations
|
||||
version: master
|
||||
trackbranch: master
|
||||
|
||||
# ansible-config_template action plugin
|
||||
- name: config_template
|
||||
scm: git
|
||||
src: https://opendev.org/openstack/ansible-config_template
|
||||
version: master
|
||||
trackbranch: master
|
||||
|
25
tripleo_ansible/roles/tripleo-config/defaults/main.yml
Normal file
25
tripleo_ansible/roles/tripleo-config/defaults/main.yml
Normal file
@ -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.
|
||||
|
||||
|
||||
# All variables intended for modification should place placed in this file.
|
||||
|
||||
# All variables within this role should have a prefix of "tripleo-config"
|
||||
tripleo_config_type: ini
|
||||
tripleo_config_owner: root
|
||||
tripleo_config_group: root
|
||||
tripleo_config_mode: 0644
|
||||
tripleo_config_overrides: {}
|
44
tripleo_ansible/roles/tripleo-config/meta/main.yml
Normal file
44
tripleo_ansible/roles/tripleo-config/meta/main.yml
Normal 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-config
|
||||
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,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
|
@ -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.
|
||||
|
||||
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: "tripleo-config"
|
||||
tripleo_config_dest: /tmp/test.ini
|
||||
|
||||
- role: "tripleo-config"
|
||||
tripleo_config_dest: /tmp/test2.ini
|
||||
tripleo_config_overrides:
|
||||
testSection:
|
||||
test_option: var1
|
@ -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
|
32
tripleo_ansible/roles/tripleo-config/tasks/main.yml
Normal file
32
tripleo_ansible/roles/tripleo-config/tasks/main.yml
Normal file
@ -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.
|
||||
|
||||
- name: Check for a configured destination
|
||||
fail:
|
||||
msg: >-
|
||||
The option `tripleo_config_dest` is undefined. Check your settings.
|
||||
when:
|
||||
- tripleo_config_dest is undefined
|
||||
|
||||
- name: "Generate {{ tripleo_config_dest }} config"
|
||||
config_template:
|
||||
src: "{{ tripleo_config_type }}-config.j2"
|
||||
dest: "{{ tripleo_config_dest }}"
|
||||
owner: "{{ tripleo_config_owner }}"
|
||||
group: "{{ tripleo_config_group }}"
|
||||
mode: "{{ tripleo_config_mode }}"
|
||||
config_overrides: "{{ tripleo_config_overrides }}"
|
||||
config_type: "{{ tripleo_config_type }}"
|
@ -0,0 +1 @@
|
||||
# {{ ansible_managed }}
|
@ -21,6 +21,7 @@
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-ceph-run-ansible
|
||||
- tripleo-ansible-centos-7-molecule-login-defs
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-time
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-config
|
||||
gate:
|
||||
jobs:
|
||||
- tripleo-ansible-centos-7-molecule-aide
|
||||
@ -42,6 +43,7 @@
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-ceph-run-ansible
|
||||
- tripleo-ansible-centos-7-molecule-login-defs
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-time
|
||||
- tripleo-ansible-centos-7-molecule-tripleo-config
|
||||
name: tripleo-ansible-molecule-jobs
|
||||
- job:
|
||||
files:
|
||||
@ -182,3 +184,10 @@
|
||||
parent: tripleo-ansible-centos-7-base
|
||||
vars:
|
||||
tripleo_role_name: tripleo-time
|
||||
- job:
|
||||
files:
|
||||
- ^tripleo_ansible/roles/tripleo-config/.*
|
||||
name: tripleo-ansible-centos-7-molecule-tripleo-config
|
||||
parent: tripleo-ansible-centos-7-base
|
||||
vars:
|
||||
tripleo_role_name: tripleo-config
|
||||
|
@ -2,6 +2,18 @@
|
||||
|
||||
- hosts: all
|
||||
pre_tasks:
|
||||
- name: Set project path fact
|
||||
set_fact:
|
||||
tripleo_ansible_project_path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||
|
||||
- name: Set action plugin path fact
|
||||
set_fact:
|
||||
tripleo_action_plugins_paths:
|
||||
- "{{ tripleo_ansible_project_path }}/tripleo_ansible/roles.galaxy/config_template/action"
|
||||
- "{{ tripleo_ansible_project_path }}/tripleo_ansible/ansible_plugins/action"
|
||||
- "/usr/share/ansible/plugins/action"
|
||||
- "/usr/share/ansible/tripleo-plugins/action"
|
||||
|
||||
- name: Ensure output dirs
|
||||
file:
|
||||
path: "{{ ansible_user_dir }}/zuul-output/logs"
|
||||
@ -16,13 +28,21 @@
|
||||
- name: Run bindep
|
||||
shell: |-
|
||||
. {{ ansible_user_dir }}/test-python/bin/activate
|
||||
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/scripts/bindep-install
|
||||
{{ tripleo_ansible_project_path }}/scripts/bindep-install
|
||||
become: true
|
||||
|
||||
- name: Setup test-python
|
||||
pip:
|
||||
requirements: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/molecule-requirements.txt"
|
||||
requirements: "{{ tripleo_ansible_project_path }}/molecule-requirements.txt"
|
||||
virtualenv: "{{ ansible_user_dir }}/test-python"
|
||||
virtualenv_site_packages: true
|
||||
tasks:
|
||||
- name: Get Ansible Galaxy roles
|
||||
command: >-
|
||||
{{ ansible_user_dir }}/test-python/bin/ansible-galaxy install
|
||||
-fr
|
||||
{{ tripleo_ansible_project_path }}/tripleo_ansible/ansible-role-requirements.yml
|
||||
environment:
|
||||
ANSIBLE_ROLES_PATH: "{{ tripleo_ansible_project_path }}/tripleo_ansible/roles.galaxy"
|
||||
roles:
|
||||
- role: install-docker
|
||||
|
@ -3,17 +3,31 @@
|
||||
- hosts: all
|
||||
environment:
|
||||
ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/zuul-output/logs/ansible-execution.log"
|
||||
pre_tasks:
|
||||
- name: Set project path fact
|
||||
set_fact:
|
||||
tripleo_ansible_project_path: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
|
||||
|
||||
- name: Set action plugin path fact
|
||||
set_fact:
|
||||
tripleo_action_plugins_paths:
|
||||
- "{{ tripleo_ansible_project_path }}/tripleo_ansible/roles.galaxy/config_template/action"
|
||||
- "{{ tripleo_ansible_project_path }}/tripleo_ansible/ansible_plugins/action"
|
||||
- "/usr/share/ansible/plugins/action"
|
||||
- "/usr/share/ansible/tripleo-plugins/action"
|
||||
tasks:
|
||||
- name: Run role test job
|
||||
shell: |-
|
||||
. {{ ansible_user_dir }}/test-python/bin/activate
|
||||
. {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/ansible-test-env.rc
|
||||
. {{ tripleo_ansible_project_path }}/ansible-test-env.rc
|
||||
pytest --color=no \
|
||||
--html={{ ansible_user_dir }}/zuul-output/logs/reports.html \
|
||||
--self-contained-html \
|
||||
-s \
|
||||
--ansible-args='{{ tripleo_job_ansible_args | default("-v") }}' \
|
||||
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/test_molecule.py
|
||||
{{ tripleo_ansible_project_path }}/tests/test_molecule.py
|
||||
args:
|
||||
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tripleo_ansible/roles/{{ tripleo_role_name }}"
|
||||
chdir: "{{ tripleo_ansible_project_path }}/tripleo_ansible/roles/{{ tripleo_role_name }}"
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
ANSIBLE_ACTION_PLUGINS: "{{ tripleo_action_plugins_paths | join(':') }}"
|
||||
|
Loading…
Reference in New Issue
Block a user