From dd7b6d9b99a28ced3ad0071d0be04e7ca6629928 Mon Sep 17 00:00:00 2001 From: Francis Kayiwa Date: Tue, 12 Nov 2024 09:50:06 -0500 Subject: [PATCH] update molecule docker driver we use `molecule-plugin[docker]` to install the docker driver used by molecule 5.0 and an example directory with the meta and files needed by molecule to run related to #45 Co-authored-by: Beck Davis Co-authored-by: Vickie Karasic --- requirements.txt | 2 +- roles/example/.ansible-lint | 14 +++++++++++++ roles/example/.yamllint | 14 +++++++++++++ roles/example/meta/main.yml | 17 ++++++++++++++++ roles/example/molecule/default/converge.yml | 15 ++++++++++++++ roles/example/molecule/default/molecule.yml | 22 +++++++++++++++++++++ roles/example/molecule/default/verify.yml | 20 +++++++++++++++++++ 7 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 roles/example/.ansible-lint create mode 100644 roles/example/.yamllint create mode 100644 roles/example/meta/main.yml create mode 100644 roles/example/molecule/default/converge.yml create mode 100644 roles/example/molecule/default/molecule.yml create mode 100644 roles/example/molecule/default/verify.yml diff --git a/requirements.txt b/requirements.txt index 470b1fe2..49a448df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ ansible>=6.7 -molecule[docker] +molecule-plugins[docker] ansible-lint passlib wheel diff --git a/roles/example/.ansible-lint b/roles/example/.ansible-lint new file mode 100644 index 00000000..2fa23367 --- /dev/null +++ b/roles/example/.ansible-lint @@ -0,0 +1,14 @@ +--- +skip_list: + - ANSIBLE0002 + - ANSIBLE0006 + - ANSIBLE0010 + - ANSIBLE0016 + - '303' + - '305' + - '306' + - '403' + - '503' + - '204' +use_default_rules: true +verbosity: 1 diff --git a/roles/example/.yamllint b/roles/example/.yamllint new file mode 100644 index 00000000..8bb60ab5 --- /dev/null +++ b/roles/example/.yamllint @@ -0,0 +1,14 @@ +--- +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + # NOTE(retr0h): Templates no longer fail this lint rule. + # Uncomment if running old Molecule templates. + # truthy: disable diff --git a/roles/example/meta/main.yml b/roles/example/meta/main.yml new file mode 100644 index 00000000..82248f81 --- /dev/null +++ b/roles/example/meta/main.yml @@ -0,0 +1,17 @@ +--- +galaxy_info: + role_name: + company: Princeton University Library + description: + author: pulibrary + + license: MIT + + min_ansible_version: 2.2 + + platforms: + - name: Ubuntu + versions: + - jammy +dependencies: + - role: "" diff --git a/roles/example/molecule/default/converge.yml b/roles/example/molecule/default/converge.yml new file mode 100644 index 00000000..470bb54f --- /dev/null +++ b/roles/example/molecule/default/converge.yml @@ -0,0 +1,15 @@ +--- +- name: Converge + hosts: all + vars: + - running_on_server: false + become: true + pre_tasks: + - name: Update cache + ansible.builtin.apt: + update_cache: true + cache_valid_time: 600 + tasks: + - name: "Include example" + ansible.builtin.include_role: + name: example diff --git a/roles/example/molecule/default/molecule.yml b/roles/example/molecule/default/molecule.yml new file mode 100644 index 00000000..fc1de4ae --- /dev/null +++ b/roles/example/molecule/default/molecule.yml @@ -0,0 +1,22 @@ +--- +scenario: + name: default +driver: + name: docker +lint: | + set -e + yamllint . + ansible-lint +platforms: + - name: instance + image: "ghcr.io/pulibrary/pul_containers:jammy_multi" + command: "sleep infinity" + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup:ro + privileged: true + pre_build_image: true +provisioner: + name: ansible + log: true +verifier: + name: ansible diff --git a/roles/example/molecule/default/verify.yml b/roles/example/molecule/default/verify.yml new file mode 100644 index 00000000..6972c173 --- /dev/null +++ b/roles/example/molecule/default/verify.yml @@ -0,0 +1,20 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - name: Check ruby package status + ansible.builtin.package: + name: "{{ item }}" + state: present + check_mode: true + register: pkg_status + loop: + - ruby-switch + - ruby2.6-dev + - ruby2.6 + + - name: Test for ruby packages + ansible.builtin.assert: + that: + - not pkg_status.changed