diff --git a/roles/test_molecule_prep/README.md b/roles/test_molecule_prep/README.md new file mode 100644 index 0000000..f7288aa --- /dev/null +++ b/roles/test_molecule_prep/README.md @@ -0,0 +1,44 @@ +test_molecule_prep +================== + +A role to do collection install for molecule testing. The role assumes it's being +run from a molecule path. + +Requirements +------------ + +None. + +Role Variables +-------------- + +* `test_module_prep_collections_build_root`: (String) Path a directory to output the collection build to. Default: "{{ ansible_env.HOME }}/collection-buildroot" +* `test_module_prep_execution_root`: (String) Path to the directory where the build action should run in. Default: '../../../..' + +Output Variables +---------------- + +None. + +Dependencies +------------ + +None. + +Example Playbook +---------------- + +Example install execution playbook + +```yaml +- hosts: localhost + tasks: + - name: Do molecule prep actions + import_role: + name: test_molecule_prep +``` + +License +------- + +Apache-2.0 diff --git a/roles/test_molecule_prep/defaults/main.yml b/roles/test_molecule_prep/defaults/main.yml new file mode 100644 index 0000000..2e2b4ce --- /dev/null +++ b/roles/test_molecule_prep/defaults/main.yml @@ -0,0 +1,4 @@ +--- +# defaults file for test_molecule_prep +test_molecule_prep_collections_build_root: "{{ ansible_env.HOME }}/collection-buildroot" +test_molecule_prep_execution_root: "../../../.." diff --git a/roles/test_molecule_prep/meta/main.yml b/roles/test_molecule_prep/meta/main.yml new file mode 100644 index 0000000..e53ae85 --- /dev/null +++ b/roles/test_molecule_prep/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 -- test_molecule_prep + 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/test_molecule_prep/molecule/default/molecule.yml b/roles/test_molecule_prep/molecule/default/molecule.yml new file mode 100644 index 0000000..d2d5bd5 --- /dev/null +++ b/roles/test_molecule_prep/molecule/default/molecule.yml @@ -0,0 +1,21 @@ +--- +driver: + name: delegated + options: + managed: false + ansible_connection_options: + ansible_connection: local +log: true +lint: + name: yamllint + enabled: false +platforms: + - name: instance +provisioner: + name: ansible +scenario: + name: default + test_sequence: + - syntax + - converge + - verify diff --git a/roles/test_molecule_prep/molecule/default/playbook.yml b/roles/test_molecule_prep/molecule/default/playbook.yml new file mode 100644 index 0000000..f247ba4 --- /dev/null +++ b/roles/test_molecule_prep/molecule/default/playbook.yml @@ -0,0 +1,17 @@ +--- +- name: Converge + hosts: all + tasks: + + - name: "Include test_molecule_prep" + include_role: + name: "test_molecule_prep" + + - name: Test known collection filter + set_fact: + test_var: "{{ 'test' | tripleo.operator.shell_arg_list(parameter='--test') }}" + + - name: Assert value + assert: + that: + - test_var == "--test test" diff --git a/roles/test_molecule_prep/tasks/main.yml b/roles/test_molecule_prep/tasks/main.yml new file mode 100644 index 0000000..f243a40 --- /dev/null +++ b/roles/test_molecule_prep/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: Build collection + shell: >- + pwd && ansible-galaxy collection build --force --output-path {{ test_molecule_prep_collections_build_root }} + args: + chdir: "{{ test_molecule_prep_execution_root }}" + changed_when: true + +- name: Install collection + shell: >- + ansible-galaxy collection install --force {{ test_molecule_prep_collections_build_root }}/tripleo-operator* + changed_when: true diff --git a/roles/test_molecule_prep/tests/inventory b/roles/test_molecule_prep/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/roles/test_molecule_prep/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/roles/test_molecule_prep/tests/test.yml b/roles/test_molecule_prep/tests/test.yml new file mode 100644 index 0000000..9c75cf5 --- /dev/null +++ b/roles/test_molecule_prep/tests/test.yml @@ -0,0 +1,4 @@ +--- +- hosts: localhost + roles: + - test_molecule_prep diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index 4236b08..4054cab 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -2,6 +2,7 @@ name: tripleo-operator-molecule-jobs check: jobs: + - tripleo-operator-molecule-test_molecule_prep - tripleo-operator-molecule-tripleo_container_image_delete - tripleo-operator-molecule-tripleo_container_image_list - tripleo-operator-molecule-tripleo_container_image_push @@ -14,6 +15,7 @@ gate: jobs: + - tripleo-operator-molecule-test_molecule_prep - tripleo-operator-molecule-tripleo_container_image_delete - tripleo-operator-molecule-tripleo_container_image_list - tripleo-operator-molecule-tripleo_container_image_push @@ -24,6 +26,15 @@ - tripleo-operator-molecule-tripleo_overcloud_node_configure - tripleo-operator-molecule-tripleo_overcloud_node_clean +- job: + files: + - ^roles/test_molecule_prep/.* + - ^plugins/.* + name: tripleo-operator-molecule-test_molecule_prep + parent: tripleo-operator-molecule-base + vars: + tox_extra_args: test_molecule_prep + - job: name: tripleo-operator-molecule-base abstract: true