diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/INSTALL.rst b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/INSTALL.rst deleted file mode 100644 index 1b38d09..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/INSTALL.rst +++ /dev/null @@ -1,15 +0,0 @@ -*********************************** -Delegated driver installation guide -*********************************** - -Requirements -============ - -This driver is delegated to the developer. Up to the developer to implement -requirements. - -Install -======= - -This driver is delegated to the developer. Up to the developer to implement -requirements. diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/converge.yml b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/converge.yml deleted file mode 100644 index 526f120..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/converge.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- name: Converge - hosts: all - gather_facts: true - connection: community.okd.oc - tasks: - - name: "Include backup_file" - ansible.builtin.include_role: - name: "backup_file" diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/create.yml b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/create.yml deleted file mode 100644 index 05333ed..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/create.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - tasks: - - - name: Create molecule instance as containers - community.okd.k8s: - kubeconfig: "{{ lookup('ansible.builtin.env', 'HOME') }}/.kube/config" - state: present - definition: "{{ lookup('template', 'templates/deployment.yml') | from_yaml }}" - wait: true - register: server - with_items: "{{ molecule_yml.platforms }}" - - - name: Debug molecule creations - ansible.builtin.debug: - var: server - - - name: Store container information # noqa: no-handler - when: server.changed | default(false) | bool - block: - - - name: Populate instance config dict - ansible.builtin.set_fact: - instance_conf_dict: { - 'instance': "{{ item.result.status.containerStatuses[0].name }}", - } - with_items: "{{ server.results }}" - register: instance_config_dict - - - name: Convert instance config dict to a list - ansible.builtin.set_fact: - instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}" - - - name: Dump instance config - ansible.builtin.copy: - content: | - # Molecule managed - - {{ instance_conf | to_json | from_json | to_yaml }} - dest: "{{ molecule_instance_config }}" - mode: 0600 diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/destroy.yml b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/destroy.yml deleted file mode 100644 index 2445e2a..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/destroy.yml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- name: Destroy - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - tasks: - # Developer must implement. - - - name: Destroy molecule containers - community.okd.k8s: - kubeconfig: "{{ lookup('ansible.builtin.env', 'HOME') }}/.kube/config" - state: absent - definition: "{{ lookup('template', 'templates/deployment.yml') | from_yaml }}" - wait: true - register: server - with_items: "{{ molecule_yml.platforms }}" - - # Mandatory configuration for Molecule to function. - - - name: Populate instance config - ansible.builtin.set_fact: - instance_conf: {} - - - name: Dump instance config # noqa: no-handler - ansible.builtin.copy: - content: | - # Molecule managed - - {{ instance_conf | to_json | from_json | to_yaml }} - dest: "{{ molecule_instance_config }}" - mode: 0600 - when: server.changed | default(false) | bool diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/molecule.yml b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/molecule.yml deleted file mode 100644 index 5bcd212..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/molecule.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -dependency: - name: galaxy -driver: - name: default - options: - managed: true - ansible_connection_options: - connection: local -platforms: - - name: molecule-ubi8-init-1 - image: registry.access.redhat.com/ubi8/ubi-init@sha256:75cb1eb60b9636f8daa584c231db552c1de94006778e7224643804a696f04fad - workingDir: '/tmp' -provisioner: - name: ansible - # Failing to write the ansible into /.ansible/tmp - config_options: - defaults: - remote_tmp: '/tmp' - # This just says go back a directory and thats your roles path - # You can also provide this via pipeline with something like this - # ANSIBLE_ROLES_PATH: $COLLECTION_ROLES - - # COLLECTIONS_PATH: ${PROJECT_SOURCE} - # ANSIBLE_ROLES_PATH: ${PROJECT_SOURCE}/${backup_file_molecule_namespace} - inventory: - group_vars: - all: - backup_file_molecule_namespace: ${DEVWORKSPACE_NAMESPACE} - backup_file_molecule_pip_dependencies: - - kubernetes -verifier: - name: ansible -scenario: - name: default - test_sequence: - - syntax - - create - - converge - - idempotence - - verify diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/prepare.yml b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/prepare.yml deleted file mode 100644 index 7c0e9bc..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/prepare.yml +++ /dev/null @@ -1,36 +0,0 @@ ---- -- name: Create - hosts: localhost - connection: local - gather_facts: false - no_log: "{{ molecule_no_log }}" - tasks: - - - name: Store user ENVs - ansible.builtin.set_fact: - molecule_user_home_dir: "{{ lookup('ansible.builtin.env', 'HOME') }}" - molecule_user_path: "{{ lookup('ansible.builtin.env', 'PATH') }}" - - - name: Create local bin directory - ansible.builtin.file: - path: "{{ molecule_user_home_dir }}/bin" - state: directory - mode: 0770 - - - name: Download oc binary from OCP downloads svc endpoint - ansible.builtin.get_url: - url: http://downloads.openshift-console.svc.cluster.local/amd64/linux/oc - dest: "{{ molecule_user_home_dir }}/bin/oc" - mode: '0770' - - - name: Add another bin dir to system-wide $PATH. - ansible.builtin.lineinfile: - path: "{{ molecule_user_home_dir }}/.bashrc" - line: 'PATH=$PATH:{{ molecule_user_home_dir }}/bin' - state: present - - - name: Ensure python dependencies are installed - ansible.builtin.pip: - name: "{{ backup_file_molecule_pip_dependencies }}" - state: present - when: backup_file_molecule_pip_dependencies is defined diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/templates/deployment.yml b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/templates/deployment.yml deleted file mode 100644 index f2a5cbc..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/templates/deployment.yml +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ item.name }}" - namespace: "{{ backup_file_molecule_namespace }}" - labels: - app: "molecule-test-container" -spec: - containers: - - name: molecule - image: "{{ item.image }}" - workingDir: "{{ item.workingDir }}" - tmpfs: - - /run - - /tmp - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - capabilities: - - SYS_ADMIN - command: - - "/usr/sbin/init" - pre_build_image: true diff --git a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/verify.yml b/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/verify.yml deleted file mode 100644 index 0d0c17d..0000000 --- a/collections/ansible_collections/sample_namespace/sample_collection/roles/backup_file/molecule/default/verify.yml +++ /dev/null @@ -1,126 +0,0 @@ ---- -# This is an example playbook to execute Ansible tests. - -- name: Verify - hosts: all - gather_facts: false - connection: community.okd.oc - # vars: - # __backup_file_base: "{{ backup_file_source | basename }}" - # __backup_file_base_suffix: "{{ backup_file_base }}{{ backup_file_dest_suffix }}" - # __backup_file_destination_path: "{{ backup_file_dest_folder }}/{{ backup_file_dest_suffix }}" - tasks: - - - name: Verifier | include default role vars - ansible.builtin.include_vars: - dir: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') }}/defaults/" - extensions: - - 'yml' - - - name: Verifier | Check if the backup destination directory exists - vars: - fail_msg: "FAIL - backup destination directory doesn't exist" - block: - - - name: Verifier Backup Created | Check if backup destination directory exists - ansible.builtin.stat: - path: "{{ backup_file_dest_folder }}" - register: __backup_file_dest_dir_stat - - - name: Verifier Backup Created | Assert backup file directory exists - ansible.builtin.assert: - that: - - __backup_file_dest_dir_stat is defined - - __backup_file_dest_dir_stat.stat.exists - - __backup_file_dest_dir_stat.stat.isdir - rescue: - - - name: Verifier Backup Created | Store failure message - ansible.builtin.set_fact: - backup_file_verifier_fail: "{{ backup_file_verifier_fail | default([]) + [fail_msg] }}" - - - name: Verifier | Check if the backup destination directory is writable - vars: - fail_msg: "FAIL - backup destination directory isn't writable at" - block: - - - name: Verifier Backup Created | Assert backup file directory is writable - ansible.builtin.assert: - that: - - __backup_file_dest_dir_stat is defined - - __backup_file_dest_dir_stat.stat.exists - - __backup_file_dest_dir_stat.stat.isdir - - __backup_file_dest_dir_stat.stat.writeable - rescue: - - - name: Verifier Backup Created | Store failure message - ansible.builtin.set_fact: - backup_file_verifier_fail: "{{ backup_file_verifier_fail | default([]) + [fail_msg] }}" - - - name: Verifier | Check if the backup created - vars: - fail_msg: "FAIL - backup file doesn't exist or is a link" - block: - - - name: Verifier Backup Created | Check if backup file was created - ansible.builtin.stat: - path: "{{ backup_file_dest_folder }}/{{ backup_file_source | basename }}{{ backup_file_dest_suffix }}" - register: __backup_file_dest_stat - - - name: Verifier Backup Created | Assert backup file exists and isn't a link - ansible.builtin.assert: - that: - - __backup_file_dest_stat is defined - - __backup_file_dest_stat.stat.exists - - not __backup_file_dest_stat.stat.islnk - rescue: - - - name: Verifier Backup Created | Store failure message - ansible.builtin.set_fact: - backup_file_verifier_fail: "{{ backup_file_verifier_fail | default([]) + [fail_msg] }}" - - - name: Verifier | Check that backup matches source - vars: - fail_msg: "FAIL - backup file doesn't match source" - block: - - - name: Verifier Backup Created | Fail immediately if backup file doesn't exist - ansible.builtin.fail: - when: - - __backup_file_dest_stat is not defined - - not __backup_file_dest_stat.stat.exists - - - name: Verifier Backup Created | Store information about source - ansible.builtin.stat: - path: "{{ backup_file_source }}" - register: __backup_file_source_stat - - - name: Verifier Backup Created | Assert source and backup file have matching checksums - ansible.builtin.assert: - that: - - __backup_file_dest_stat is defined - - __backup_file_dest_stat.stat.checksum is defined - - __backup_file_source_stat is defined - - __backup_file_source_stat.stat.checksum is defined - - __backup_file_source_stat.stat.checksum == __backup_file_source_stat.stat.checksum - - rescue: - - - name: Verifier Backup Created | Store failure message - ansible.builtin.set_fact: - backup_file_verifier_fail: "{{ backup_file_verifier_fail | default([]) + [fail_msg] }}" - - - name: Verifier | Fail if any tests failed - when: - - backup_file_verifier_fail is defined - block: - - - name: Verifier | Show failures - ansible.builtin.debug: - msg: - - "Role failed with the following messages" - - "{{ backup_file_verifier_fail }}" - - - name: Verifier | Fail test - ansible.builtin.fail: - msg: "{{ backup_file_verifier_fail }}"