diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 63ff747..7e646a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.1.0 + rev: v2.4.0 hooks: - id: end-of-file-fixer - id: trailing-whitespace @@ -18,24 +18,23 @@ repos: - id: check-yaml files: .*\.(yaml|yml)$ - repo: https://github.com/adrienverge/yamllint.git - rev: v1.15.0 + rev: v1.20.0 hooks: - id: yamllint files: \.(yaml|yml)$ types: [file, yaml] entry: yamllint --strict -f parsable - repo: https://github.com/ansible/ansible-lint - rev: v4.1.1a2 + rev: v4.2.0 hooks: - id: ansible-lint - files: \.(yaml|yml)$ - entry: >- - ansible-lint --force-color -v -x "ANSIBLE0006,ANSIBLE0007,ANSIBLE0010,ANSIBLE0012,ANSIBLE0013,ANSIBLE0016,204" - # TODO(cloudnull): These codes were added to pass the lint check. - # Things found within roles.galaxy are external - # and not something maintained here. - # NOTE(mwhahaha): ignore 204 because collections make you include - # namespaces in filters so lines get REALLY long + always_run: true + pass_filenames: false + # do not add file filters here as ansible-lint does not give reliable + # results when called with individual files. + # https://github.com/ansible/ansible-lint/issues/611 + verbose: true + entry: env ANSIBLE_LIBRARY=./plugins ansible-lint --force-color -p -v - repo: https://github.com/openstack-dev/bashate.git rev: 0.6.0 hooks: diff --git a/plugins/README.md b/plugins/README.md index 6541cf7..0685726 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -28,4 +28,4 @@ Here is an example directory of the majority of plugins currently supported by A └── vars ``` -A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html). \ No newline at end of file +A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible/2.9/plugins/plugins.html). diff --git a/roles/tripleo-undercloud-backup/README.md b/roles/tripleo-undercloud-backup/README.md new file mode 100644 index 0000000..e27cd2a --- /dev/null +++ b/roles/tripleo-undercloud-backup/README.md @@ -0,0 +1,46 @@ +tripleo-undercloud-backup +========================= + +A role to run backup of a TripleO undercloud. + +Requirements +------------ + +None. + +Role Variables +-------------- + + +* `tripleo_undercloud_backup_add_path`: (List) List of additional filesystem paths to backup. Default: [] +* `tripleo_undercloud_backup_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false +* `tripleo_undercloud_backup_exclude_path`: (List) List of filesystems path to skip backing up. Default: [] +* `tripleo_undercloud_backup_home_dir`: (String) Home directory for the undercloud user. Default: "{{ ansible_env.HOME }}" +* `tripleo_undercloud_backup_log_combine`: (Boolean) Flag to combine stdout and stderr in the logfile. Default: true +* `tripleo_undercloud_backup_log_output`: (Boolean) Flag to log the output to a file rather than show it in the ansible output. Default: true +* `tripleo_undercloud_backup_timeout`: (Number) Timeout for the backup command. Default: 7200 +* `tripleo_undercloud_backup_log`: (String) Backup log file path. Default: "{{ tripleo_undercloud_backup_home_dir }}/undercloud_backup.log" + +Dependencies +------------ + +None. + +Example Playbook +---------------- + +Example backup execution playbook + + - hosts: undercloud + gather_facts: true + tasks: + - name: Backup undercloud + import_role: + name: tripleo-undercloud-backup + vars: + tripleo_undercloud_backup_debug: true + +License +------- + +Apache-2.0 diff --git a/roles/tripleo-undercloud-backup/defaults/main.yml b/roles/tripleo-undercloud-backup/defaults/main.yml new file mode 100644 index 0000000..2004eaf --- /dev/null +++ b/roles/tripleo-undercloud-backup/defaults/main.yml @@ -0,0 +1,10 @@ +--- +# defaults file for tripleo-undercloud-backup +tripleo_undercloud_backup_add_path: [] +tripleo_undercloud_backup_debug: false +tripleo_undercloud_backup_exclude_path: [] +tripleo_undercloud_backup_home_dir: "{{ ansible_env.HOME }}" +tripleo_undercloud_backup_log_combine: true +tripleo_undercloud_backup_log_output: true +tripleo_undercloud_backup_timeout: 7200 +tripleo_undercloud_backup_log: "{{ tripleo_undercloud_backup_home_dir }}/undercloud_backup.log" diff --git a/roles/tripleo-undercloud-backup/meta/main.yml b/roles/tripleo-undercloud-backup/meta/main.yml new file mode 100644 index 0000000..9890039 --- /dev/null +++ b/roles/tripleo-undercloud-backup/meta/main.yml @@ -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-undercloud-backup + 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: [] diff --git a/roles/tripleo-undercloud-backup/tasks/main.yml b/roles/tripleo-undercloud-backup/tasks/main.yml new file mode 100644 index 0000000..6bae468 --- /dev/null +++ b/roles/tripleo-undercloud-backup/tasks/main.yml @@ -0,0 +1,27 @@ +--- +- name: Setup undercloud backup facts + set_fact: + _backup_cmd: >- + openstack undercloud backup + {{ tripleo_undercloud_backup_add_path | tripleo.operator.shell_arg_list(parameter='--add-path') }} + {{ tripleo_undercloud_backup_exclude_path | tripleo.operator.shell_arg_list(parameter='--exclude-path') }} + {{ tripleo_undercloud_backup_log_output | ternary((">" ~ tripleo_undercloud_backup_log), '') }} + {{ tripleo_undercloud_backup_log_combine | ternary("2>&1", '') }} + +- name: Preserve existing log file if exists + timestamp_file: + path: "{{ tripleo_undercloud_backup_log }}" + +- name: Show the underclound backup command + debug: + var: _backup_cmd + when: tripleo_undercloud_backup_debug|bool + +- name: undercloud backup + shell: "{{ _backup_cmd }}" # noqa 305 + args: + chdir: "{{ tripleo_undercloud_backup_home_dir }}" + warn: false + async: "{{ tripleo_undercloud_backup_timeout }}" + poll: 10 + changed_when: true diff --git a/roles/tripleo-undercloud-backup/tests/inventory b/roles/tripleo-undercloud-backup/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/roles/tripleo-undercloud-backup/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/roles/tripleo-undercloud-backup/tests/test.yml b/roles/tripleo-undercloud-backup/tests/test.yml new file mode 100644 index 0000000..b73e1de --- /dev/null +++ b/roles/tripleo-undercloud-backup/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - tripleo-undercloud-backup diff --git a/roles/tripleo-undercloud-install/README.md b/roles/tripleo-undercloud-install/README.md new file mode 100644 index 0000000..58ea9bd --- /dev/null +++ b/roles/tripleo-undercloud-install/README.md @@ -0,0 +1,49 @@ +tripleo-undercloud-install +========================== + +A role to run the install of a TripleO undercloud. + +Requirements +------------ + +None. + +Role Variables +-------------- + + +* `tripleo_undercloud_install_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false +* `tripleo_undercloud_install_dry_run`: (Boolean) Flag to add --dry-run to the install. Default: false +* `tripleo_undercloud_install_force_stack_update`: (Boolean) Flag to add --force-stack-update to the install. Default: false +* `tripleo_undercloud_install_home_dir`: (String) Home directory for the undercloud user. Default: "{{ ansible_env.HOME }}" +* `tripleo_undercloud_install_inflight_validations`: (Boolean) Flag to add --inflight-validations to the install. Default: false +* `tripleo_undercloud_install_log_combine`: (Boolean) Flag to combine stdout and stderr in the logfile. Default: true +* `tripleo_undercloud_install_log_output`: (Boolean) Flag to log the output to a file rather than show it in the ansible output. Default: true +* `tripleo_undercloud_install_no_validations`: (Boolean) Flag to add --no-validations to the install. Default: false +* `tripleo_undercloud_install_timeout`: (Number) Timeout for the install command. Default: 7200 +* `tripleo_undercloud_install_yes`: (Boolean) Flag to add --yes to the install. Default: false +* `tripleo_undercloud_install_log`: (String) Install log file path. Default: "{{ tripleo_undercloud_install_home_dir }}/undercloud_install.log" + +Dependencies +------------ + +None. + +Example Playbook +---------------- + +Example install execution playbook + + - hosts: undercloud + gather_facts: true + tasks: + - name: Install undercloud + import_role: + name: tripleo-undercloud-install + vars: + tripleo_undercloud_install_debug: true + +License +------- + +Apache-2.0 diff --git a/roles/tripleo-undercloud-install/defaults/main.yml b/roles/tripleo-undercloud-install/defaults/main.yml new file mode 100644 index 0000000..ba45695 --- /dev/null +++ b/roles/tripleo-undercloud-install/defaults/main.yml @@ -0,0 +1,13 @@ +--- +# defaults file for tripleo-undercloud-install +tripleo_undercloud_install_debug: false +tripleo_undercloud_install_dry_run: false +tripleo_undercloud_install_force_stack_update: false +tripleo_undercloud_install_home_dir: "{{ ansible_env.HOME }}" +tripleo_undercloud_install_inflight_validations: false +tripleo_undercloud_install_log_combine: true +tripleo_undercloud_install_log_output: true +tripleo_undercloud_install_no_validations: false +tripleo_undercloud_install_timeout: 7200 +tripleo_undercloud_install_yes: false +tripleo_undercloud_install_log: "{{ tripleo_undercloud_install_home_dir }}/undercloud_install.log" diff --git a/roles/tripleo-undercloud-install/meta/main.yml b/roles/tripleo-undercloud-install/meta/main.yml new file mode 100644 index 0000000..2427bd1 --- /dev/null +++ b/roles/tripleo-undercloud-install/meta/main.yml @@ -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-undercloud-install + 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: [] diff --git a/roles/tripleo-undercloud-install/tasks/main.yml b/roles/tripleo-undercloud-install/tasks/main.yml new file mode 100644 index 0000000..74d9ca9 --- /dev/null +++ b/roles/tripleo-undercloud-install/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: Setup undercloud install facts + set_fact: + _install_cmd: >- + openstack undercloud install + {{ tripleo_undercloud_install_force_stack_update | ternary("--force-stack-update", '') }} + {{ tripleo_undercloud_install_no_validations | ternary("--no-validations", '') }} + {{ tripleo_undercloud_install_inflight_validations | ternary("--inflight-validations", '') }} + {{ tripleo_undercloud_install_dry_run | ternary("--dry-run", '') }} + {{ tripleo_undercloud_install_yes | ternary("--yes", '') }} + {{ tripleo_undercloud_install_log_output | ternary((">" ~ tripleo_undercloud_install_log), '') }} + {{ tripleo_undercloud_install_log_combine | ternary("2>&1", '') }} + +- name: Preserve existing log file if exists + timestamp_file: + path: "{{ tripleo_undercloud_install_log }}" + +- name: Show the underclound install command + debug: + var: _install_cmd + when: tripleo_undercloud_install_debug|bool + +- name: undercloud install + shell: "{{ _install_cmd }}" # noqa 305 + args: + chdir: "{{ tripleo_undercloud_install_home_dir }}" + warn: false + async: "{{ tripleo_undercloud_install_timeout }}" + poll: 10 + changed_when: true diff --git a/roles/tripleo-undercloud-install/tests/inventory b/roles/tripleo-undercloud-install/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/roles/tripleo-undercloud-install/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/roles/tripleo-undercloud-install/tests/test.yml b/roles/tripleo-undercloud-install/tests/test.yml new file mode 100644 index 0000000..2cf25a1 --- /dev/null +++ b/roles/tripleo-undercloud-install/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - tripleo-undercloud-install diff --git a/roles/tripleo-undercloud-upgrade/README.md b/roles/tripleo-undercloud-upgrade/README.md new file mode 100644 index 0000000..63d593f --- /dev/null +++ b/roles/tripleo-undercloud-upgrade/README.md @@ -0,0 +1,49 @@ +tripleo-undercloud-upgrade +========================== + +A role to run the upgrade of a TripleO undercloud. + +Requirements +------------ + +None. + +Role Variables +-------------- + + +* `tripleo_undercloud_upgrade_debug`: (Boolean) Flag used to enable the debug version of commands. Default: false +* `tripleo_undercloud_upgrade_dry_run`: (Boolean) Flag to add --dry-run to the upgrade command. Default: false +* `tripleo_undercloud_upgrade_force_stack_update`: (Boolean) Flag to add --force-stack-update to the upgrade command. Default: false +* `tripleo_undercloud_upgrade_home_dir`: (String) Home directory for the undercloud user. Default: "{{ ansible_env.HOME }}" +* `tripleo_undercloud_upgrade_inflight_validations`: (Boolean) Flag to add --inflight-validations to the upgrade. Default: false +* `tripleo_undercloud_upgrade_log_combine`: (Boolean) Flag to combine stdout and stderr in the logfile. Default: true +* `tripleo_undercloud_upgrade_log_output`: (Boolean) Flag to log the output to a file rather than show it in the ansible output. Default: true +* `tripleo_undercloud_upgrade_no_validations`: (Boolean) Flag to add --no-validations to the upgrade. Default: false +* `tripleo_undercloud_upgrade_timeout`: (Number) Timeout for the upgrade command. Default: 7200 +* `tripleo_undercloud_upgrade_yes`: (Boolean) Flag to add --yes to the upgrade. Default: false +* `tripleo_undercloud_upgrade_log`: (String) Upgrade log file path. Default: "{{ tripleo_undercloud_upgrade_home_dir }}/undercloud_upgrade.log" + +Dependencies +------------ + +None. + +Example Playbook +---------------- + +Example upgrade execution playbook + + - hosts: undercloud + gather_facts: true + tasks: + - name: Upgrade undercloud + import_role: + name: tripleo-undercloud-upgrade + vars: + tripleo_undercloud_upgrade_debug: true + +License +------- + +Apache-2.0 diff --git a/roles/tripleo-undercloud-upgrade/defaults/main.yml b/roles/tripleo-undercloud-upgrade/defaults/main.yml new file mode 100644 index 0000000..c6ff9fe --- /dev/null +++ b/roles/tripleo-undercloud-upgrade/defaults/main.yml @@ -0,0 +1,13 @@ +--- +# defaults file for tripleo-undercloud +tripleo_undercloud_upgrade_debug: false +tripleo_undercloud_upgrade_dry_run: false +tripleo_undercloud_upgrade_force_stack_update: false +tripleo_undercloud_upgrade_home_dir: "{{ ansible_env.HOME }}" +tripleo_undercloud_upgrade_inflight_validations: false +tripleo_undercloud_upgrade_log_combine: true +tripleo_undercloud_upgrade_log_output: true +tripleo_undercloud_upgrade_no_validations: false +tripleo_undercloud_upgrade_timeout: 7200 +tripleo_undercloud_upgrade_yes: false +tripleo_undercloud_upgrade_log: "{{ tripleo_undercloud_upgrade_home_dir }}/undercloud_upgrade.log" diff --git a/roles/tripleo-undercloud-upgrade/meta/main.yml b/roles/tripleo-undercloud-upgrade/meta/main.yml new file mode 100644 index 0000000..8dd5fa3 --- /dev/null +++ b/roles/tripleo-undercloud-upgrade/meta/main.yml @@ -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-undercloud-upgrade + 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: [] diff --git a/roles/tripleo-undercloud-upgrade/tasks/main.yml b/roles/tripleo-undercloud-upgrade/tasks/main.yml new file mode 100644 index 0000000..e79e66c --- /dev/null +++ b/roles/tripleo-undercloud-upgrade/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: Setup undercloud upgrade facts + set_fact: + _upgrade_cmd: >- + openstack undercloud upgrade + {{ tripleo_undercloud_upgrade_force_stack_update | ternary("--force-stack-update", '') }} + {{ tripleo_undercloud_upgrade_no_validations | ternary("--no-validations", '') }} + {{ tripleo_undercloud_upgrade_inflight_validations | ternary("--inflight-validations", '') }} + {{ tripleo_undercloud_upgrade_dry_run | ternary("--dry-run", '') }} + {{ tripleo_undercloud_upgrade_yes | ternary("--yes", '') }} + {{ tripleo_undercloud_upgrade_log_output | ternary((">" ~ tripleo_undercloud_upgrade_log), '') }} + {{ tripleo_undercloud_upgrade_log_combine | ternary("2>&1", '') }} + +- name: Preserve existing log file if exists + timestamp_file: + path: "{{ tripleo_undercloud_upgrade_log }}" + +- name: Show the underclound upgrade command + debug: + var: _upgrade_cmd + when: tripleo_undercloud_upgrade_debug|bool + +- name: undercloud upgrade + shell: "{{ _upgrade_cmd }}" # noqa 305 + args: + chdir: "{{ tripleo_undercloud_upgrade_home_dir }}" + warn: false + async: "{{ tripleo_undercloud_upgrade_timeout }}" + poll: 10 + changed_when: true diff --git a/roles/tripleo-undercloud-upgrade/tests/inventory b/roles/tripleo-undercloud-upgrade/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/roles/tripleo-undercloud-upgrade/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/roles/tripleo-undercloud-upgrade/tests/test.yml b/roles/tripleo-undercloud-upgrade/tests/test.yml new file mode 100644 index 0000000..67624cb --- /dev/null +++ b/roles/tripleo-undercloud-upgrade/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - tripleo-undercloud-upgrade diff --git a/tox.ini b/tox.ini index 5827c76..df5d9c6 100644 --- a/tox.ini +++ b/tox.ini @@ -119,4 +119,3 @@ basepython = python3 deps = -r{toxinidir}/ansible-requirements.txt commands = ansible-galaxy collection build --force --output-path {toxinidir}/build/ . -