Add role to cover ansible config generation
Adds tripleo-config-generate-ansible role to run the command to generate the default ansible config. Change-Id: I2367ac443d1d7b370f7c0744539a20031c598f7d
This commit is contained in:
parent
103fc86d72
commit
446cede057
|
@ -0,0 +1,46 @@
|
|||
tripleo-config-generate-ansible
|
||||
===============================
|
||||
|
||||
A role to generate the default ansible.cfg for a deployment.
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
None.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
|
||||
* `tripleo_config_generate_ansible_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false
|
||||
* `tripleo_config_generate_ansible_deployment_user`: (String) Deployment user to use. Default: "{{ ansible_user }}"
|
||||
* `tripleo_config_generate_ansible_os_cloud`: (String) OS_CLOUD value to use when running the command. If tripleo_os_cloud is defined, it will be the default. Otherwise the default is ''. This variable takes precedence over `tripleo_config_generate_ansible_rc_file`.
|
||||
* `tripleo_config_generate_ansible_output_dir`: (String) Directory to output ansible.cfg and ansible.log files. Default: "{{ ansible_env.HOME }}"
|
||||
* `tripleo_config_generate_ansible_rc_file`: (String) Path to the credential file to use. If tripleo_rc_file is defined, it will be the default. Default: "{{ ansible_env.HOME }}/overcloudrc"
|
||||
|
||||
Output Variables
|
||||
----------------
|
||||
|
||||
* `tripleo_config_generate_ansible_result`: Ansible shell execution results
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
None.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
Example install execution playbook
|
||||
|
||||
- hosts: undercloud
|
||||
gather_facts: true
|
||||
tasks:
|
||||
- name: Generate default ansible config
|
||||
import_role:
|
||||
name: tripleo-config-generate-ansible
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Apache-2.0
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
# defaults file for tripleo-config-generate-ansible
|
||||
tripleo_config_generate_ansible_debug: false
|
||||
tripleo_config_generate_ansible_deployment_user: "{{ ansible_user }}"
|
||||
tripleo_config_generate_ansible_os_cloud: "{{ tripleo_os_cloud | default('') }}"
|
||||
tripleo_config_generate_ansible_output_dir: "{{ ansible_env.HOME }}"
|
||||
tripleo_config_generate_ansible_rc_file: "{{ tripleo_rc_file | default(ansible_env.HOME ~ '/overcloudrc') }}"
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
# 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 Operator Role -- tripleo-config-generate-ansible
|
||||
company: Red Hat
|
||||
license: Apache-2.0
|
||||
min_ansible_version: 2.8
|
||||
#
|
||||
# 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: CentOS
|
||||
versions:
|
||||
- 7
|
||||
- 8
|
||||
|
||||
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,22 @@
|
|||
---
|
||||
- name: Setup config generate ansible facts
|
||||
set_fact:
|
||||
_generate_cmd: >-
|
||||
{{ tripleo_config_generate_ansible_os_cloud | ternary('', "source " ~ tripleo_config_generate_ansible_rc_file ~ "; ") }}
|
||||
openstack tripleo config generate ansible
|
||||
{{ tripleo_config_generate_ansible_deployment_user | ternary("--deployment_user " ~ tripleo_config_generate_ansible_deployment_user, '') }}
|
||||
{{ tripleo_config_generate_ansible_output_dir | ternary("--output-dir " ~ tripleo_config_generate_ansible_output_dir, '') }}
|
||||
|
||||
- name: Show the config generate ansible command
|
||||
debug:
|
||||
var: _generate_cmd
|
||||
when: tripleo_config_generate_ansible_debug|bool
|
||||
|
||||
- name: tripleo config generate ansible
|
||||
shell: "{{ _generate_cmd }}" # noqa 305
|
||||
args:
|
||||
warn: false
|
||||
environment:
|
||||
OS_CLOUD: "{{ tripleo_config_generate_ansible_os_cloud }}"
|
||||
register: tripleo_config_generate_ansible_result
|
||||
changed_when: true
|
|
@ -0,0 +1 @@
|
|||
localhost
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- tripleo-config-generate-ansible
|
Loading…
Reference in New Issue