Merge "Add tripleo_ceph_spec role"

This commit is contained in:
Zuul 2022-03-15 00:55:54 +00:00 committed by Gerrit Code Review
commit ec5cb37622
8 changed files with 278 additions and 0 deletions

View File

@ -0,0 +1,79 @@
tripleo_ceph_spec
=====================
A role to generate Ceph spec files.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_ceph_spec_become`: (Boolean) Execute command with escalated privileges. Default: false
* `tripleo_ceph_spec_crush_hierarchy`: (String) Path to an existing crush hierarchy spec file.
* `tripleo_ceph_spec_debug`: (Boolean) Flag to print out the command that is run. Default: false
* `tripleo_ceph_spec_deployed_baremetal`: (String) Path to the environment file output from "openstack overcloud node provision". This argument may be excluded only if tripleo_ceph_spec_standalone is True.
* `tripleo_ceph_spec_file`: "{{ ansible_env.HOME }}/ceph_spec.yaml"
* `tripleo_ceph_spec_generate_scripts_only`: (Boolean) Do not run the actual command - to be used in conjunction with `tripleo_ceph_spec_generate_scripts`. By default uses the value of `tripleo_generate_scripts_only` or False if `tripleo_generate_scripts_only` is not defined.
* `tripleo_ceph_spec_generate_scripts`: (Boolean) Write out a shell script that can be used to reproduce the command being executed. By default uses the value of `tripleo_generate_scripts` or False if `tripleo_generate_scripts` is not defined.
* `tripleo_ceph_spec_mon_ip`: (String) IP address of the first Ceph monitor. Only supported if tripleo_ceph_spec_standalone is True.
* `tripleo_ceph_spec_osd_spec`: (String) Path to an existing OSD spec file. When the Ceph spec file is generated its OSD spec defaults to {data_devices: {all: true}} for all service_type osd. Use this parameter to override the data_devices value inside the Ceph spec file.
* `tripleo_ceph_spec_overwrite`: (Boolean) Flag to skip yes/no prompts about overwriting the tripleo_ceph_spec_file from a previous run. Default: false
* `tripleo_ceph_spec_poll`: (Integer) Number of seconds to wait between each checks to see if the deployment command has completed. Default: 10
* `tripleo_ceph_spec_roles_file`: (String) Path to an alternative roles_data.yaml. Used to decide which node gets which Ceph mon, mgr, or osd service based on the node's role tripleo_ceph_spec_deployed_baremetal.
* `tripleo_ceph_spec_stack`: Name or ID of heat stack. Used to find the working directory.
* `tripleo_ceph_spec_standalone`: (Boolean) Create a spec file for a standalone deployment. Used for single server development or testing environments.
* `tripleo_ceph_spec_timeout_arg`: (Integer) Number in minutes for the deployment to run. Default: 90
* `tripleo_ceph_spec_timeout`: (Integer) Number in seconds to wait for the ansible execution of the deployment command to finish. This should be larger than the `tripleo_ceph_spec_timeout_arg` value. Default: 5700
* `tripleo_ceph_spec_working_dir`: (String) The working directory for the deployment where all input, output, and generated files will be stored. Defaults to "$HOME/overcloud-deploy/<stack>"
Output Variables
----------------
* `tripleo_ceph_spec_output`: (String) The command standard output.
* `tripleo_ceph_spec_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example ceph spec playbook
```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: Create Ceph Spec for Standalone
include_role:
name: tripleo_ceph_spec
vars:
tripleo_ceph_spec_standalone: True
tripleo_ceph_spec_mon_ip: 192.168.122.42
tripleo_ceph_spec_file: /home/stack/ceph_spec.yaml
tripleo_ceph_spec_overwrite: True
- name: Create Ceph Spec from 'openstack overcloud node provision' output
include_role:
name: tripleo_ceph_spec
vars:
tripleo_ceph_spec_debug: True
tripleo_ceph_spec_generate_scripts: True
tripleo_ceph_spec_overwrite: True
tripleo_ceph_spec_stack: overcloud
tripleo_ceph_spec_roles_file: /home/stack/custom_roles.yaml
tripleo_ceph_spec_file: /home/stack/ceph_spec.yaml
tripleo_ceph_spec_deployed_baremetal: /home/stack/overcloud-baremetal-deployed.yaml
```
License
-------
Apache-2.0

View File

@ -0,0 +1,19 @@
---
openstack_bin: openstack
tripleo_ceph_spec_become: false
tripleo_ceph_spec_crush_hierarchy:
tripleo_ceph_spec_debug: false
tripleo_ceph_spec_deployed_baremetal:
tripleo_ceph_spec_file: "{{ ansible_env.HOME }}/ceph_spec.yaml"
tripleo_ceph_spec_generate_scripts: "{{ tripleo_generate_scripts | default(False) }}"
tripleo_ceph_spec_generate_scripts_only: "{{ tripleo_generate_scripts_only | default(False) }}"
tripleo_ceph_spec_mon_ip:
tripleo_ceph_spec_osd_spec:
tripleo_ceph_spec_overwrite: false
tripleo_ceph_spec_poll: 10
tripleo_ceph_spec_roles_file:
tripleo_ceph_spec_stack:
tripleo_ceph_spec_standalone: false
tripleo_ceph_spec_timeout: 5700
tripleo_ceph_spec_timeout_arg: 90
tripleo_ceph_spec_working_dir:

View File

@ -0,0 +1,45 @@
---
# Copyright 2022 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:
role_name: tripleo_ceph_spec
namespace: openstack
author: OpenStack
description: TripleO Operator Role -- tripleo_ceph_spec
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
- 9
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,28 @@
---
- name: Converge
hosts: all
collections:
- tripleo.operator
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_ceph_spec_run_debug: true
tasks:
- name: Call tripleo_ceph_spec role for standlone
include_role:
name: "tripleo_ceph_spec"
vars:
tripleo_ceph_spec_standalone: true
tripleo_ceph_spec_mon_ip: 192.168.122.42
tripleo_ceph_spec_file: /home/zuul/ceph_spec.yaml
- name: Show result tripleo_ceph_spec_result
debug:
msg: "{{ tripleo_ceph_spec_result }}"
- name: Assert tripleo_ceph_spec command for standalone
assert:
that:
- tripleo_ceph_spec_result.stdout ==
"overcloud ceph spec --standalone --mon-ip 192.168.122.42 --output /home/zuul/ceph_spec.yaml"

View File

@ -0,0 +1,19 @@
---
driver:
name: delegated
options:
managed: false
ansible_connection_options:
ansible_connection: local
log: true
platforms:
- name: instance
provisioner:
name: ansible
scenario:
name: default
test_sequence:
- prepare
- syntax
- converge
- verify

View File

@ -0,0 +1,8 @@
---
- name: Prepare
hosts: all
tasks:
- name: Include molecule prep
include_role:
name: test_molecule_prep

View File

@ -0,0 +1,64 @@
---
- name: Setup ceph spec facts
set_fact:
_deploy_cmd: >-
{{ openstack_bin }} overcloud ceph spec
{{ tripleo_ceph_spec_deployed_baremetal }}
{{ tripleo_ceph_spec_standalone | ternary('--standalone', '') }}
{{ tripleo_ceph_spec_mon_ip | ternary('--mon-ip $CEPH_MON_IP', '') }}
{{ tripleo_ceph_spec_overwrite | ternary('--yes', '') }}
{{ tripleo_ceph_spec_file | ternary('--output $CEPH_SPEC', '') }}
{{ tripleo_ceph_spec_stack | ternary('--stack $DEPLOY_STACK', '') }}
{{ tripleo_ceph_spec_working_dir | ternary('--working-dir $DEPLOY_WORKING_DIR', '') }}
{{ tripleo_ceph_spec_roles_file | ternary('--roles $DEPLOY_ROLES_FILE', '') }}
{{ tripleo_ceph_spec_osd_spec | ternary('--osd-spec $CEPH_OSD_SPEC', '') }}
{{ tripleo_ceph_spec_crush_hierarchy | ternary('--crush-hierarchy $CEPH_CRUSH_HIERARCHY', '') }}
_deploy_env:
DEPLOY_STACK: "{{ tripleo_ceph_spec_stack }}"
DEPLOY_WORKING_DIR: "{{ tripleo_ceph_spec_working_dir }}"
DEPLOY_ROLES_FILE: "{{ tripleo_ceph_spec_roles_file }}"
CEPH_SPEC: "{{ tripleo_ceph_spec_file }}"
CEPH_MON_IP: "{{ tripleo_ceph_spec_mon_ip }}"
CEPH_OSD_SPEC: "{{ tripleo_ceph_spec_osd_spec }}"
CEPH_CRUSH_HIERARCHY: "{{ tripleo_ceph_spec_crush_hierarchy }}"
- name: Show debug information
when:
tripleo_ceph_spec_debug|bool
block:
- name: Show openstack overcloud ceph spec command
debug:
var: _deploy_cmd
- name: Show the openstack overcloud ceph spec environment
debug:
var: _deploy_env
- name: Write reproducer script
tripleo_shell_script:
dest: "{{ ansible_env.HOME }}/openstack_overcloud_ceph_spec.sh"
shell_command: "{{ _deploy_cmd }}"
shell_environment: "{{ _deploy_env }}"
when: tripleo_ceph_spec_generate_scripts|bool
- name: Generate Ceph Spec
shell: "{{ _deploy_cmd }}" # noqa 305
environment: "{{ _deploy_env }}"
args:
executable: /bin/bash
chdir: "{{ ansible_env.HOME }}"
warn: false
become: "{{ tripleo_ceph_spec_become }}"
register: tripleo_ceph_spec_result
async: "{{ tripleo_ceph_spec_timeout }}"
poll: "{{ tripleo_ceph_spec_poll }}"
changed_when: false
when:
- not ansible_check_mode|bool
- not tripleo_ceph_spec_generate_scripts_only|bool
- name: Set output fact
when:
- tripleo_ceph_spec_result.stdout is defined
set_fact:
tripleo_ceph_spec_output: "{{ tripleo_ceph_spec_result.stdout }}"

View File

@ -3,6 +3,7 @@
check:
jobs:
- tripleo-operator-molecule-test_molecule_prep
- tripleo-operator-molecule-tripleo_ceph_spec
- tripleo-operator-molecule-tripleo_config_generate_ansible
- tripleo-operator-molecule-tripleo_container_image_build
- tripleo-operator-molecule-tripleo_container_image_delete
@ -74,6 +75,7 @@
gate:
jobs:
- tripleo-operator-molecule-test_molecule_prep
- tripleo-operator-molecule-tripleo_ceph_spec
- tripleo-operator-molecule-tripleo_config_generate_ansible
- tripleo-operator-molecule-tripleo_container_image_build
- tripleo-operator-molecule-tripleo_container_image_delete
@ -1133,3 +1135,17 @@
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_validator_show_parameter
- job:
files:
- ^roles/tripleo_ceph_spec/.*
- ^bindep.txt
- ^galaxy.yml
- ^requirements.txt
- ^setup.cfg
- ^test-requirements.txt
- ^tox.ini
name: tripleo-operator-molecule-tripleo_ceph_spec
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_ceph_spec