Add tripleo_ceph_deploy role

Adds tripleo_ceph_deploy role to deploy Ceph on
overcloud nodes before deploying the overcloud.

Change-Id: I562322d0caf380a30c11d2179eb26efbec20f757
This commit is contained in:
John Fulton 2022-03-15 18:58:56 +00:00
parent 253618d006
commit fbcd961404
8 changed files with 353 additions and 0 deletions

View File

@ -0,0 +1,91 @@
tripleo_ceph_deploy
=====================
A role to deploy Ceph on overcloud nodes before deploying the overcloud.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_ceph_deploy_become`: (Boolean) Execute command with escalated privileges. Default: false
* `tripleo_ceph_deploy_crush_hierarchy`: (String) Path to an existing crush hierarchy spec file.
* `tripleo_ceph_deploy_debug`: (Boolean) Flag to print out the command that is run. Default: false
* `tripleo_ceph_deploy_deployed_baremetal`: (String) Path to the environment file output from "openstack overcloud node provision". This argument may be excluded only if tripleo_ceph_deploy_standalone is True.
* `tripleo_ceph_deploy_spec`: (String) Path to an existing Ceph spec file. If not provided a spec will be generated automatically based on `tripleo_ceph_deploy_roles_file` and `tripleo_ceph_deploy_deployed_baremetal`. The `tripleo_ceph_deploy_deployed_baremetal` parameter is optional only if `tripleo_ceph_deploy_spec` is used.
* `tripleo_ceph_user_ssh_user`: (String) Name of the SSH user used by cephadm. Warning: if this option is used, it must be used consistently for every 'openstack overcloud ceph' call. Defaults to 'ceph-admin'. (default=Env: CEPHADM_SSH_USER)
* `tripleo_ceph_deploy_generate_scripts_only`: (Boolean) Do not run the actual command - to be used in conjunction with `tripleo_ceph_deploy_generate_scripts`. By default uses the value of `tripleo_generate_scripts_only` or False if `tripleo_generate_scripts_only` is not defined.
* `tripleo_ceph_deploy_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_deploy_mon_ip`: (String) IP address of the first Ceph monitor. If not set, an IP from the Ceph public_network of a server with the mon label from the Ceph spec is used. IP must already be active on server. Only supported if tripleo_ceph_deploy_standalone is True.
* `tripleo_ceph_deploy_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_deploy_overwrite`: (Boolean) Flag to skip yes/no prompts about overwriting the deployed_ceph.yaml from a previous run. Default: false
* `tripleo_ceph_deploy_poll`: (Integer) Number of seconds to wait between each checks to see if the deployment command has completed. Default: 10
* `tripleo_ceph_deploy_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 and `tripleo_ceph_deploy_deployed_baremetal`.
* `tripleo_ceph_deploy_stack`: Name or ID of heat stack. Used to find the working directory. If unset `openenstack overcloud ceph deploy` will default this value to 'overcloud'.
* `tripleo_ceph_deploy_standalone`: (Boolean) Use single host Ansible inventory. Used only for development or testing environments. Used for single server development or testing environments. Default: false
* `tripleo_ceph_deploy_timeout_arg`: (Integer) Number in minutes for the deployment to run. Default: 90
* `tripleo_ceph_deploy_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_deploy_timeout_arg` value. Default: 5700
* `tripleo_ceph_deploy_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>"
* `tripleo_ceph_deploy_output:`: (String) The path to the output environment file describing the Ceph deployment to pass to the overcloud deployment.
* `tripleo_ceph_deploy_skip_user_create`: (Boolean) Do not create the cephadm SSH user. This user is necessary to deploy but may be created in a separate step via 'openstack overcloud ceph user enable'. Default: false
* `tripleo_ceph_deploy_skip_hosts_config`: (Boolean) Do not update /etc/hosts on deployed servers. By default this is configured so overcloud nodes can reach each other and the undercloud by name. Default: false
* `tripleo_ceph_deploy_skip_container_registry_config`: (Boolean) Do not update /etc/containers/registries.conf on deployed servers. By default this is configured so overcloud nodes can pull containers from the undercloud registry. Default: false
* `tripleo_ceph_deploy_network_data`: (String) Path to an alternative network_data.yaml. Used to define Ceph public_network and cluster_network. This file is searched for networks with name_lower values of storage and storage_mgmt. If none found, then search repeats but with service_net_map_replace in place of name_lower. Use `tripleo_ceph_deploy_public_network_name` or `tripleo_ceph_deploy_cluster_network_name` options to override name of the searched for network from storage or storage_mgmt to a customized name. If network_data has no storage networks, both default to ctlplane. If found network has >1 subnet, they are all combined (for routed traffic). If a network has ipv6 true, then the ipv6_subnet is retrieved instead of the ip_subnet, and the Ceph global ms_bind_ipv4 is set false and the ms_bind_ipv6 is set true. Use `tripleo_ceph_deploy_config` to override these defaults if desired.
* `tripleo_ceph_deploy_public_network_name`: (String) Name of the network defined in `tripleo_ceph_deploy_network_data` which should be used for the Ceph public_network. If undefined the client defaults this value to 'storage'.
* `tripleo_ceph_deploy_cluster_network_name`: (String) Name of the network defined in `tripleo_ceph_deploy_network_data` which should be used for the Ceph cluster_network. If undefined the client defaults this value to 'storage_mgmt'.
* `tripleo_ceph_deploy_config`: (String) Path to an existing ceph.conf with settings to be assimilated by the new cluster via 'cephadm bootstrap --config'
* `tripleo_ceph_deploy_cephadm_extra_args`: (String) String of extra parameters to pass cephadm. E.g. if this parameter is set to '--log-to-file --skip-prepare-host', then cephadm boostrap will use those options. Warning: requires `tripleo_ceph_deploy_force` to be true as not all possible options ensure a functional deployment.
* `tripleo_ceph_deploy_force`: (Boolean) Run command regardless of consequences. Default: false
* `tripleo_ceph_deploy_ceph_vip`: (String) Path to an existing Ceph services/network mapping file.
* `tripleo_ceph_deploy_daemons`: (String) Path to an existing Ceph daemon options definition.
* `tripleo_ceph_deploy_single_host_defaults`: (Boolean) Adjust configuration defaults to suit a single-host Ceph cluster. Default: false
* `tripleo_ceph_deploy_container_image_prepare`: (String) Path to an alternative container_image_prepare_defaults.yaml. Used to control which Ceph container is pulled by cephadm via the ceph_namespace, ceph_image, and ceph_tag variables in addition to registry authentication via ContainerImageRegistryCredentials.
* `tripleo_ceph_deploy_container_cephadm_default`: (Boolean) Use the default continer defined in cephadm instead of container_image_prepare_defaults.yaml. If this is used, 'cephadm bootstrap' is not passed the --image parameter. Default: false
* `tripleo_ceph_deploy_container_namespace`: (String) Override the namespace value set via `tripleo_ceph_deploy_continer_image_prepare`. E.g. quay.io/ceph.
* `tripleo_ceph_deploy_container_image`: (String) Override the image value set via `tripleo_ceph_deploy_continer_image_prepare`. E.g. ceph.
* `tripleo_ceph_deploy_container_tag`: (String) Override the tag value set via `tripleo_ceph_deploy_continer_image_prepare`. E.g. latest.
* `tripleo_ceph_deploy_container_registry_url`: (String) Override the registry URL value set via `tripleo_ceph_deploy_continer_image_prepare`.
* `tripleo_ceph_deploy_container_registry_username`: (String) Override the registry username value set via `tripleo_ceph_deploy_continer_image_prepare`.
* `tripleo_ceph_deploy_container_registry_password`: (String) Override the registry password value set via `tripleo_ceph_deploy_continer_image_prepare`.
Output Variables
----------------
* `tripleo_ceph_deploy_output`: (String) The command standard output.
* `tripleo_ceph_deploy_result`: (String) Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example ceph spec playbook
```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: Deploy Ceph using 'openstack overcloud node provision' output
include_role:
name: tripleo_ceph_deploy
vars:
tripleo_ceph_deploy_debug: True
tripleo_ceph_deploy_generate_scripts: True
tripleo_ceph_deploy_overwrite: True
tripleo_ceph_deploy_stack: overcloud
tripleo_ceph_deploy_roles_file: /home/stack/custom_roles.yaml
tripleo_ceph_deploy_deployed_baremetal: /home/stack/overcloud-baremetal-deployed.yaml
```
License
-------
Apache-2.0

View File

@ -0,0 +1,41 @@
---
openstack_bin: openstack
tripleo_ceph_deploy_become: false
tripleo_ceph_deploy_crush_hierarchy:
tripleo_ceph_deploy_debug: false
tripleo_ceph_deploy_deployed_baremetal:
tripleo_ceph_deploy_spec:
tripleo_ceph_deploy_generate_scripts: "{{ tripleo_generate_scripts | default(False) }}"
tripleo_ceph_deploy_generate_scripts_only: "{{ tripleo_generate_scripts_only | default(False) }}"
tripleo_ceph_deploy_mon_ip:
tripleo_ceph_deploy_osd_spec:
tripleo_ceph_deploy_overwrite: false
tripleo_ceph_deploy_poll: 10
tripleo_ceph_deploy_roles_file:
tripleo_ceph_user_ssh_user: ceph-admin
tripleo_ceph_deploy_stack:
tripleo_ceph_deploy_standalone: false
tripleo_ceph_deploy_timeout: 5700
tripleo_ceph_deploy_timeout_arg: 90
tripleo_ceph_deploy_working_dir:
tripleo_ceph_deploy_output:
tripleo_ceph_deploy_skip_user_create: false
tripleo_ceph_deploy_skip_hosts_config: false
tripleo_ceph_deploy_skip_container_registry_config: false
tripleo_ceph_deploy_network_data:
tripleo_ceph_deploy_public_network_name:
tripleo_ceph_deploy_cluster_network_name:
tripleo_ceph_deploy_config:
tripleo_ceph_deploy_cephadm_extra_args:
tripleo_ceph_deploy_force: false
tripleo_ceph_deploy_ceph_vip:
tripleo_ceph_deploy_daemons:
tripleo_ceph_deploy_single_host_defaults: false
tripleo_ceph_deploy_container_cephadm_default: false
tripleo_ceph_deploy_container_image_prepare:
tripleo_ceph_deploy_container_namespace:
tripleo_ceph_deploy_container_image:
tripleo_ceph_deploy_container_tag:
tripleo_ceph_deploy_container_registry_url:
tripleo_ceph_deploy_container_registry_username:
tripleo_ceph_deploy_container_registry_password:

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_deploy
namespace: openstack
author: OpenStack
description: TripleO Operator Role -- tripleo_ceph_deploy
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,30 @@
---
- name: Converge
hosts: all
collections:
- tripleo.operator
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_ceph_deploy_run_debug: true
tasks:
- name: Call tripleo_ceph_deploy role for standlone
include_role:
name: "tripleo_ceph_deploy"
vars:
tripleo_ceph_deploy_standalone: true
tripleo_ceph_deploy_mon_ip: 192.168.122.42
tripleo_ceph_deploy_spec: /home/zuul/ceph_spec.yaml
tripleo_ceph_deploy_stack: standalone
tripleo_ceph_deploy_output: /home/zuul/deployed_ceph.yaml
- name: Show result tripleo_ceph_deploy_result
debug:
msg: "{{ tripleo_ceph_deploy_result }}"
- name: Assert tripleo_ceph_deploy command for standalone
assert:
that:
- tripleo_ceph_deploy_result.stdout ==
"overcloud ceph deploy --output /home/zuul/deployed_ceph.yaml --standalone --mon-ip 192.168.122.42 --ceph-spec /home/zuul/ceph_spec.yaml --stack standalone --cephadm-ssh-user ceph-admin"

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,102 @@
---
- name: Setup ceph deploy facts
set_fact:
_deploy_cmd: >-
{{ openstack_bin }} overcloud ceph deploy
{{ tripleo_ceph_deploy_deployed_baremetal }}
{{ tripleo_ceph_deploy_output | ternary('--output $DEPLOYED_CEPH', '') }}
{{ tripleo_ceph_deploy_overwrite | ternary('--yes', '') }}
{{ tripleo_ceph_deploy_standalone | ternary('--standalone', '') }}
{{ tripleo_ceph_deploy_mon_ip | ternary('--mon-ip $CEPH_MON_IP', '') }}
{{ tripleo_ceph_deploy_spec | ternary('--ceph-spec $CEPH_SPEC', '') }}
{{ tripleo_ceph_deploy_stack | ternary('--stack $DEPLOY_STACK', '') }}
{{ tripleo_ceph_deploy_working_dir | ternary('--working-dir $DEPLOY_WORKING_DIR', '') }}
{{ tripleo_ceph_deploy_roles_file | ternary('--roles $DEPLOY_ROLES_FILE', '') }}
{{ tripleo_ceph_deploy_osd_spec | ternary('--osd-spec $CEPH_OSD_SPEC', '') }}
{{ tripleo_ceph_deploy_crush_hierarchy | ternary('--crush-hierarchy $CEPH_CRUSH_HIERARCHY', '') }}
{{ tripleo_ceph_user_ssh_user | ternary('--cephadm-ssh-user $CEPHADM_SSH_USER', '') }}
{{ tripleo_ceph_deploy_skip_user_create | ternary('--skip-user-create', '') }}
{{ tripleo_ceph_deploy_skip_hosts_config | ternary('--skip-hosts-config', '') }}
{{ tripleo_ceph_deploy_skip_container_registry_config | ternary('--skip-container-registry-config', '') }}
{{ tripleo_ceph_deploy_force | ternary('--force', '') }}
{{ tripleo_ceph_deploy_single_host_defaults | ternary('--single-host-defaults', '') }}
{{ tripleo_ceph_deploy_network_data | ternary('--network-data $NETWORK_DATA', '') }}
{{ tripleo_ceph_deploy_public_network_name | ternary('--public-network-name $PUBLIC_NETWORK_NAME', '') }}
{{ tripleo_ceph_deploy_cluster_network_name | ternary('--cluster-network-name $CLUSTER_NETWORK_NAME', '') }}
{{ tripleo_ceph_deploy_config | ternary('--config $CONFIG', '') }}
{{ tripleo_ceph_deploy_cephadm_extra_args | ternary('--cephadm-extra-args "$CEPHADM_EXTRA_ARGS"', '') }}
{{ tripleo_ceph_deploy_ceph_vip | ternary('--ceph-vip $CEPH_VIP', '') }}
{{ tripleo_ceph_deploy_daemons | ternary('--daemons $DAEMONS', '') }}
{{ tripleo_ceph_deploy_container_cephadm_default | ternary('--cephadm-default-container', '') }}
{{ tripleo_ceph_deploy_container_image_prepare | ternary('--container-image-prepare $CONTAINER_IMAGE_PREPARE', '') }}
{{ tripleo_ceph_deploy_container_namespace | ternary('--container-namespace $CONTAINER_NAMESPACE', '') }}
{{ tripleo_ceph_deploy_container_image | ternary('--container-image $CONTAINER_IMAGE', '') }}
{{ tripleo_ceph_deploy_container_tag | ternary('--container-tag $CONTAINER_TAG', '') }}
{{ tripleo_ceph_deploy_container_registry_url | ternary('--registry-url $REGISTRY_URL', '') }}
{{ tripleo_ceph_deploy_container_registry_username | ternary('--registry-username $REGISTRY_USERNAME', '') }}
{{ tripleo_ceph_deploy_container_registry_password | ternary('--registry-password $REGISTRY_PASSWORD', '') }}
_deploy_env:
DEPLOYED_CEPH: "{{ tripleo_ceph_deploy_output }}"
DEPLOY_STACK: "{{ tripleo_ceph_deploy_stack }}"
DEPLOY_WORKING_DIR: "{{ tripleo_ceph_deploy_working_dir }}"
DEPLOY_ROLES_FILE: "{{ tripleo_ceph_deploy_roles_file }}"
CEPH_SPEC: "{{ tripleo_ceph_deploy_spec }}"
CEPH_MON_IP: "{{ tripleo_ceph_deploy_mon_ip }}"
CEPH_OSD_SPEC: "{{ tripleo_ceph_deploy_osd_spec }}"
CEPH_CRUSH_HIERARCHY: "{{ tripleo_ceph_deploy_crush_hierarchy }}"
CEPHADM_SSH_USER: "{{ tripleo_ceph_user_ssh_user }}"
NETWORK_DATA: "{{ tripleo_ceph_deploy_network_data }}"
PUBLIC_NETWORK_NAME: "{{ tripleo_ceph_deploy_public_network_name }}"
CLUSTER_NETWORK_NAME: "{{ tripleo_ceph_deploy_cluster_network_name }}"
CONFIG: "{{ tripleo_ceph_deploy_config }}"
CEPHADM_EXTRA_ARGS: "{{ tripleo_ceph_deploy_cephadm_extra_args }}"
CEPH_VIP: "{{ tripleo_ceph_deploy_ceph_vip }}"
DAEMONS: "{{ tripleo_ceph_deploy_daemons }}"
CONTAINER_IMAGE_PREPARE: "{{ tripleo_ceph_deploy_container_image_prepare }}"
CONTAINER_NAMESPACE: "{{ tripleo_ceph_deploy_container_namespace }}"
CONTAINER_IMAGE: "{{ tripleo_ceph_deploy_container_image }}"
CONTAINER_TAG: "{{ tripleo_ceph_deploy_container_tag }}"
REGISTRY_URL: "{{ tripleo_ceph_deploy_container_registry_url }}"
REGISTRY_USERNAME: "{{ tripleo_ceph_deploy_container_registry_username }}"
REGISTRY_PASSWORD: "{{ tripleo_ceph_deploy_container_registry_password }}"
- name: Show debug information
when:
tripleo_ceph_deploy_debug|bool
block:
- name: Show openstack overcloud ceph deploy command
debug:
var: _deploy_cmd
- name: Show the openstack overcloud ceph deploy environment
debug:
var: _deploy_env
- name: Write reproducer script
tripleo_shell_script:
dest: "{{ ansible_env.HOME }}/openstack_overcloud_ceph_deploy.sh"
shell_command: "{{ _deploy_cmd }}"
shell_environment: "{{ _deploy_env }}"
when: tripleo_ceph_deploy_generate_scripts|bool
- name: Run Ceph Deploy
shell: "{{ _deploy_cmd }}" # noqa 305
environment: "{{ _deploy_env }}"
args:
executable: /bin/bash
chdir: "{{ ansible_env.HOME }}"
warn: false
become: "{{ tripleo_ceph_deploy_become }}"
register: tripleo_ceph_deploy_result
async: "{{ tripleo_ceph_deploy_timeout }}"
poll: "{{ tripleo_ceph_deploy_poll }}"
changed_when: false
when:
- not ansible_check_mode|bool
- not tripleo_ceph_deploy_generate_scripts_only|bool
- name: Set output fact
when:
- tripleo_ceph_deploy_result.stdout is defined
set_fact:
tripleo_ceph_deploy_output: "{{ tripleo_ceph_deploy_result.stdout }}"

View File

@ -3,6 +3,7 @@
check:
jobs:
- tripleo-operator-molecule-test_molecule_prep
- tripleo-operator-molecule-tripleo_ceph_deploy
- tripleo-operator-molecule-tripleo_ceph_spec
- tripleo-operator-molecule-tripleo_ceph_user
- tripleo-operator-molecule-tripleo_config_generate_ansible
@ -76,6 +77,7 @@
gate:
jobs:
- tripleo-operator-molecule-test_molecule_prep
- tripleo-operator-molecule-tripleo_ceph_deploy
- tripleo-operator-molecule-tripleo_ceph_spec
- tripleo-operator-molecule-tripleo_ceph_user
- tripleo-operator-molecule-tripleo_config_generate_ansible
@ -1165,3 +1167,18 @@
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_ceph_user
- job:
files:
- ^roles/tripleo_ceph_deploy/.*
- ^bindep.txt
- ^galaxy.yml
- ^requirements.txt
- ^setup.cfg
- ^test-requirements.txt
- ^tox.ini
name: tripleo-operator-molecule-tripleo_ceph_deploy
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_ceph_deploy