Add overcloud raid create

Adds tripleo_overcloud_raid_create to handle raid creation on nodes.

Change-Id: Ibd71e23e9ee1f7bfe0589a21979de63d94ce056f
This commit is contained in:
Alex Schultz 2020-03-17 17:04:04 -06:00
parent 3cd841192e
commit 7df7c520d8
10 changed files with 258 additions and 0 deletions

View File

@ -0,0 +1,60 @@
tripleo_overcloud_raid_create
=============================
A role to perform raid on given nodes.
Requirements
------------
None.
Role Variables
--------------
* `tripleo_overcloud_raid_create_configuration`: (String) REQUIRED. Path to file containing raid configuration.
* `tripleo_overcloud_raid_create_debug`: (Boolean) Flag to print out the delete command. Default: False
* `tripleo_overcloud_raid_create_home_dir`: (String) Home directory to where the command is run from. Default: "{{ ansible_env.HOME }}"
* `tripleo_overcloud_raid_create_log_combine`: (Boolean) Flag to enable captching stderr with stdout. Default: true
* `tripleo_overcloud_raid_create_log_output`: (Boolean) Flag to enable logging to a file. Since the output of this command can be large, it is not recommended to disable this. Default: true
* `tripleo_overcloud_raid_create_log`: (String) Path to a log file for the command output. Default: "{{ tripleo_overcloud_raid_create_home_dir }}/overcloud_raid_create.log"
* `tripleo_overcloud_raid_create_nodes`: (List) REQUIRED. Nodes to create RAID on. Default: []
* `tripleo_overcloud_raid_create_os_cloud`: (String) (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_overcloud_raid_create_rc_file`.
* `tripleo_overcloud_raid_create_poll`: (Integer) Number of seconds to wait between each checks to see if the command has completed. Default: 10
* `tripleo_overcloud_raid_create_rc_file`: (String) (String) Path to the credential file to use. If `tripleo_rc_file` is defined, it will be the default. Default: "{{ ansible_env.HOME }}/stackrc"
* `tripleo_overcloud_raid_create_timeout`: (Integer) Number in seconds to wait for the ansible execution of the command to finish. Default: 3600
Output Variables
----------------
* `tripleo_overcloud_raid_create_output`: (String) The command standard output.
* `tripleo_overcloud_raid_create_result`: Ansible shell execution results
Dependencies
------------
None.
Example Playbook
----------------
Example raid create
```yaml
- hosts: undercloud
gather_facts: true
tasks:
- name: Run overcloud raid create
import_role:
name: tripleo_overcloud_raid_create
var:
tripleo_overcloud_raid_create_debug: true
tripleo_overcloud_raid_create_configuration: /home/stack/raid.yaml
tripleo_overcloud_raid_create_nodes:
- node1
- node2
```
License
-------
Apache-2.0

View File

@ -0,0 +1,14 @@
---
# defaults file for tripleo_overcloud_raid_create
openstack_bin: openstack
tripleo_overcloud_raid_create_configuration:
tripleo_overcloud_raid_create_debug: false
tripleo_overcloud_raid_create_home_dir: "{{ ansible_env.HOME }}"
tripleo_overcloud_raid_create_log: "{{ tripleo_overcloud_raid_create_home_dir }}/CHANGEME.log"
tripleo_overcloud_raid_create_log_combine: true
tripleo_overcloud_raid_create_log_output: true
tripleo_overcloud_raid_create_nodes: []
tripleo_overcloud_raid_create_os_cloud: "{{ tripleo_os_cloud | default('') }}"
tripleo_overcloud_raid_create_poll: 10
tripleo_overcloud_raid_create_rc_file: "{{ tripleo_rc_file | default(ansible_env.HOME ~ '/stackrc') }}"
tripleo_overcloud_raid_create_timeout: 3600

View File

@ -0,0 +1,42 @@
---
# Copyright 2020 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_overcloud_raid_create
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: []

View File

@ -0,0 +1,47 @@
---
- name: Converge
hosts: all
collections:
- tripleo.operator
vars:
openstack_bin: echo
tripleo_os_cloud: undercloud
tripleo_overcloud_raid_create_log_output: false
tripleo_overcloud_raid_create_poll: 1
tripleo_overcloud_raid_create_debug: true
tasks:
- name: "Include tripleo_overcloud_raid_create"
include_role:
name: "tripleo_overcloud_raid_create"
- name: Check role
assert:
that:
- tripleo_overcloud_raid_create_output == "overcloud raid create"
- name: Assert "tripleo_overcloud_raid_create_nodes"
include_role:
name: "tripleo_overcloud_raid_create"
vars:
tripleo_overcloud_raid_create_nodes:
- node1
- node2
- name: Validate tripleo_overcloud_raid_create_nodes
assert:
that:
- tripleo_overcloud_raid_create_output ==
"overcloud raid create --node node1 --node node2"
- name: Assert "tripleo_overcloud_raid_create_configuration"
include_role:
name: "tripleo_overcloud_raid_create"
vars:
tripleo_overcloud_raid_create_configuration: foo.yaml
- name: Validate tripleo_overcloud_raid_create_configuration
assert:
that:
- tripleo_overcloud_raid_create_output ==
"overcloud raid create foo.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,46 @@
---
# tasks file for tripleo_overcloud_raid_create
- name: Set overcloud raid create facts
set_fact:
_raid_cmd: >-
{{ tripleo_overcloud_raid_create_os_cloud | ternary('', "source " ~ tripleo_overcloud_raid_create_rc_file ~ "; ") }}
{{ openstack_bin }} overcloud raid create
{{ tripleo_overcloud_raid_create_nodes | tripleo.operator.shell_arg_list('--node') }}
{{ tripleo_overcloud_raid_create_configuration }}
{{ tripleo_overcloud_raid_create_log_output | ternary((">" ~ tripleo_overcloud_raid_create_log), '') }}
{{ tripleo_overcloud_raid_create_log_combine | ternary("2>&1", '') }}
_raid_env:
OS_CLOUD: "{{ tripleo_overcloud_raid_create_os_cloud }}"
- name: Preserve existing log file if exists
timestamp_file:
path: "{{ tripleo_overcloud_raid_create_log }}"
when: tripleo_overcloud_raid_create_log_output|bool
- name: Show debug information
when: tripleo_overcloud_raid_create_debug|bool
block:
- name: Show the command
debug:
var: _raid_cmd
- name: Show the environment
debug:
var: _raid_env
- name: overcloud raid create
shell: "{{ _raid_cmd }}" # noqa 305
environment: "{{ _raid_env }}"
args:
executable: /bin/bash
chdir: "{{ tripleo_overcloud_raid_create_home_dir }}"
warn: false
register: tripleo_overcloud_raid_create_result
async: "{{ tripleo_overcloud_raid_create_timeout }}"
poll: "{{ tripleo_overcloud_raid_create_poll }}"
changed_when: false
when: not ansible_check_mode|bool
- name: Set output fact
set_fact:
tripleo_overcloud_raid_create_output: "{{ tripleo_overcloud_raid_create_result.stdout }}"

View File

@ -0,0 +1 @@
localhost

View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- tripleo_overcloud_raid_create

View File

@ -35,6 +35,7 @@
- tripleo-operator-molecule-tripleo_overcloud_node_provide
- tripleo-operator-molecule-tripleo_overcloud_node_provision
- tripleo-operator-molecule-tripleo_overcloud_node_unprovision
- tripleo-operator-molecule-tripleo_overcloud_raid_create
- tripleo-operator-molecule-tripleo_overcloud_update_converge
- tripleo-operator-molecule-tripleo_overcloud_update_prepare
- tripleo-operator-molecule-tripleo_overcloud_update_run
@ -81,6 +82,7 @@
- tripleo-operator-molecule-tripleo_overcloud_node_provide
- tripleo-operator-molecule-tripleo_overcloud_node_provision
- tripleo-operator-molecule-tripleo_overcloud_node_unprovision
- tripleo-operator-molecule-tripleo_overcloud_raid_create
- tripleo-operator-molecule-tripleo_overcloud_update_converge
- tripleo-operator-molecule-tripleo_overcloud_update_prepare
- tripleo-operator-molecule-tripleo_overcloud_update_run
@ -461,6 +463,20 @@
vars:
tox_extra_args: tripleo_overcloud_node_unprovision
- job:
files:
- ^roles/tripleo_overcloud_raid_create/.*
- ^bindep.txt
- ^galaxy.yml
- ^requirements.txt
- ^setup.cfg
- ^test-requirements.txt
- ^tox.ini
name: tripleo-operator-molecule-tripleo_overcloud_raid_create
parent: tripleo-operator-molecule-base
vars:
tox_extra_args: tripleo_overcloud_raid_create
- job:
files:
- ^roles/tripleo_overcloud_node_configure/.*