---
- name: WSL - Add Maven plugin in asdf
shell: "bash -lic 'source {{ wsl_bashrc_path }} && asdf plugin add maven'"
become: true
become_user: "{{ ansible_env.SUDO_USER }}"
become_method: su
retries: 5
delay: 10
register: result
until: result is success
failed_when: result.rc != 0 and result.rc != 2
- name: WSL - Install Maven
shell: "bash -lic 'source {{ wsl_bashrc_path }} && asdf install maven {{ maven_version }}'"
become: true
become_user: "{{ ansible_env.SUDO_USER }}"
become_method: su
retries: 5
delay: 10
register: result
until: result is success
- name: WSL - Set global maven version
shell: "bash -lic 'source {{ wsl_bashrc_path }} && asdf global maven {{ maven_version }}'"
become: true
become_user: "{{ ansible_env.SUDO_USER }}"
become_method: su
- name: WSL - Copy Maven settings.xml file
copy:
src: settings.xml
dest: "{{ maven_wsl_settings_path }}"
mode: "644"
become: true
become_user: "{{ ansible_env.SUDO_USER }}"
become_method: su
Molecule Script for Maven Role
I have a defined a maven role under roles folder at the root of the project.
Below is the directory structure for the molecule code
-Below are the code blocks i am Attaching as Reference for all the yml files which i had mentioned in the directory structure
Even Attaching the Github Workflow File as Reference
Code for test_default.py
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
def test_maven(host):
# Check if Maven is installed
cmd = host.run("mvn --version")
assert "Apache Maven" in cmd.stdout
# Check if Maven's settings.xml file exists
f = host.file('/usr/share/maven/conf/settings.xml')
assert f.exists
assert f.user == 'root'
assert f.group == 'root'
While running the workflow below is the error message
TASK [Create molecule instance(s)] *********************************************
changed: [localhost] => (item=instance)
TASK [Wait for instance(s) creation to complete] *******************************
failed: [localhost] (item={'failed': 0, 'started': 1, 'finished': 0, 'ansible_job_id': 'j5861[197](https://github.com/principalinformationservices-emu/pfg-engineer-workstation-setup/actions/runs/9745717261/job/26894343520#step:6:202)84582.3634', 'results_file': '/home/runner/.ansible_async/j586119784582.3634', 'changed': True, 'item': {'command': '/sbin/init', 'image': 'ubuntu-16.04', 'name': 'instance', 'pre_build_image': True, 'privileged': True, 'volumes': ['/sys/fs/cgroup:/sys/fs/cgroup:ro']}, 'ansible_loop_var': 'item'}) => {"ansible_job_id": "j586119784582.3634", "ansible_loop_var": "item", "attempts": 2, "changed": false, "finished": 1, "item": {"ansible_job_id": "j586119784582.3634", "ansible_loop_var": "item", "changed": true, "failed": 0, "finished": 0, "item": {"command": "/sbin/init", "image": "ubuntu-16.04", "name": "instance", "pre_build_image": true, "privileged": true, "volumes": ["/sys/fs/cgroup:/sys/fs/cgroup:ro"]}, "results_file": "/home/runner/.ansible_async/j586119784582.3634", "started": 1}, "msg": "Error pulling image ubuntu-16.04:latest - 404 Client Error for http+docker://localhost/v1.46/images/create?tag=latest&fromImage=ubuntu-16.04: Not Found (\"pull access denied for ubuntu-16.04, repository does not exist or may require 'docker login': denied: requested access to the resource is denied\")", "results_file": "/home/runner/.ansible_async/j586119784582.3634", "started": 1, "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
FAILED - RETRYING: [localhost]: Wait for instance(s) creation to complete (300 retries left).
Requirement
We are planning to have some testing for role level using molecule for the Windows, WSL, Macos using Github Actions
Using Molecule how can we have the script at role level. need script for that would be more helpful
Ask / Help
I had tried to keep this as reference but i am facing some issue while running workflow file.
If that is possible need some script how to do at each role and Need to define Github Actions Workflow to include all the roles for testing the workflow
Please kindly help on this and quick support is much Appreciated 👍
Description
Scripting
Actually i am trying to implement for one of the sample role
maven
and below are the code blocks for ReferenceFor Windows
name: Windows - Install Maven command: "{{ powershell_path }} {{ windows_environment_variables }} choco upgrade {{ item.name }} --version {{ item.version }} --no-progress --allow-downgrade -y" retries: 5 delay: 10 register: result until: result is success loop:
name: Windows - Copy Maven settings.xml file copy: src: settings.xml dest: "{{ maven_windows_settings_path }}" mode: "644"
For WSL
Molecule Script for Maven Role
I have a defined a
maven
role underroles
folder at the root of the project.Below is the directory structure for the molecule code -Below are the code blocks i am Attaching as Reference for all the yml files which i had mentioned in the directory structure
Even Attaching the Github Workflow File as Reference
Code for test_default.py
Code for Converge.yml
Code for Verify.yml
Code for Molecule.yml
Github Workflow Script
Error Message
While running the workflow below is the error message
Requirement
Ask / Help
workflow
file.Please kindly help on this and quick support is much Appreciated 👍