-
-
Notifications
You must be signed in to change notification settings - Fork 1
Upgrades packages and adds Molecule CI testing #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a3ec8eb
388a1f4
16d5922
6feab9a
b213602
75f2ed2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "ref": "refs/heads/main", | ||
| "before": "0000000000000000000000000000000000000000", | ||
| "after": "0000000000000000000000000000000000000001", | ||
| "forced": false, | ||
| "repository": { | ||
| "name": "prepare_linux_desktop", | ||
| "full_name": "ansible102/prepare_linux_desktop", | ||
| "private": false, | ||
| "default_branch": "main" | ||
| }, | ||
| "pusher": { | ||
| "name": "mbojko", | ||
| "email": "marcinbojko.pl@gmail.com" | ||
| }, | ||
| "head_commit": { | ||
| "id": "0000000000000000000000000000000000000001", | ||
| "message": "test push", | ||
| "author": { | ||
| "name": "mbojko", | ||
| "email": "marcinbojko.pl@gmail.com" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| extends: default | ||
|
|
||
| rules: | ||
| line-length: | ||
| max: 160 | ||
| level: warning | ||
| document-start: disable | ||
| brackets: | ||
| min-spaces-inside: 0 | ||
| max-spaces-inside: 0 | ||
| braces: | ||
| min-spaces-inside: 0 | ||
| max-spaces-inside: 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,51 +1,30 @@ | ||
| name: Super-Linter | ||
|
|
||
| # Run this workflow every time a new commit pushed to your repository | ||
| on: | ||
| push: | ||
| branches: [main, master, test, develop] | ||
| pull_request: | ||
| branches: [main, master] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| packages: write | ||
| actions: read | ||
| deployments: read | ||
| id-token: write | ||
| issues: write | ||
| discussions: read | ||
| pages: read | ||
| repository-projects: read | ||
| security-events: read | ||
| attestations: read # Added this | ||
| checks: write # Added this | ||
| statuses: write # Added | ||
| contents: read | ||
| statuses: write | ||
|
|
||
| jobs: | ||
| # Set the job key. The key is displayed as the job name | ||
| # when a job name is not provided | ||
| super-lint: | ||
| # Name the Job | ||
| name: Lint code base | ||
| # Set the type of machine to run on | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| # Checks out a copy of your repository on the ubuntu-latest machine | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # Runs the Super-Linter action | ||
| - name: Run Super-Linter | ||
| # workaround for superlinter issues | ||
| uses: github/super-linter@main | ||
| uses: super-linter/super-linter@9e863354e3ff62e0727d37183162c4a88873df41 # v8.6.0 | ||
| env: | ||
| DEFAULT_BRANCH: ${{ github.ref_name }} | ||
| DEFAULT_BRANCH: ${{ github.event.pull_request.base.ref || github.event.repository.default_branch || 'main' }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| VALIDATE_ALL_CODEBASE: ${{ github.event_name != 'pull_request' }} | ||
| VALIDATE_JSCPD: false | ||
| # VALIDATE_ANSIBLE: false | ||
| VALIDATE_NATURAL_LANGUAGE: false | ||
| # VALIDATE_DOCKERFILE_HADOLINT: false | ||
| VALIDATE_ALL_CODEBASE: false | ||
| VALIDATE_YAML: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| --- | ||
| name: Syntax Check | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| branches: [main, master] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| syntax-check: | ||
| name: Ansible syntax check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install dependencies | ||
| run: pip install -r molecule/requirements.txt | ||
|
|
||
| - name: Install collections | ||
| run: ansible-galaxy collection install -r requirements.yml | ||
|
|
||
| - name: Run molecule syntax | ||
| run: molecule syntax | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| - name: Converge | ||
| hosts: all | ||
| gather_facts: true | ||
| roles: | ||
| - role: pld | ||
| vars: | ||
| pld_active_user: "{{ ansible_user_id | default('ci') }}" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||
| --- | ||||||
| dependency: | ||||||
| name: galaxy | ||||||
| options: | ||||||
| requirements-file: requirements.yml | ||||||
| ignore-certs: true | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check if the file exists and examine its content
if [ -f "molecule/default/molecule.yml" ]; then
echo "=== File found ==="
wc -l molecule/default/molecule.yml
echo -e "\n=== Full content with line numbers ==="
cat -n molecule/default/molecule.yml
else
echo "File not found"
find . -name "molecule.yml" -type f 2>/dev/null
fiRepository: marcinbojko/pld Length of output: 791 🏁 Script executed: # Check repository metadata and docs
ls -la | head -20
echo -e "\n=== Checking for README or docs ==="
find . -maxdepth 2 -name "README*" -o -name "CONTRIBUTING*" | head -5
echo -e "\n=== Checking git status ==="
git log --oneline -5 2>/dev/null || echo "No git history available"
echo -e "\n=== Checking if this is a CI/CD file or test file ==="
find . -name ".github" -o -name ".gitlab-ci.yml" -o -name ".travis.yml" -o -name "tox.ini" 2>/dev/null | head -5Repository: marcinbojko/pld Length of output: 1381 🏁 Script executed: # Check README for project context (first 100 lines)
echo "=== README.md (first 100 lines) ==="
head -100 README.md
echo -e "\n=== .gitlab-ci.yml ==="
cat .gitlab-ci.ymlRepository: marcinbojko/pld Length of output: 6170 🏁 Script executed: # Check if there's any documentation about why ignore-certs is needed
echo "=== Checking requirements.yml ==="
cat requirements.yml
echo -e "\n=== Checking for any comments or docs about molecule setup ==="
find molecule -type f | head -20
cat molecule/default/molecule.yml
echo -e "\n=== Check git history for ignore-certs introduction ==="
git log --oneline --all -- molecule/default/molecule.yml | head -10
git log -p --follow -- molecule/default/molecule.yml | head -50Repository: marcinbojko/pld Length of output: 1019 Disable TLS certificate verification bypass in Molecule test configuration. The Suggested change- ignore-certs: true
+ ignore-certs: falseRef: https://docs.ansible.com/ansible/latest/cli/ansible-galaxy.html 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| ignore-errors: true | ||||||
|
|
||||||
| driver: | ||||||
| name: default | ||||||
|
|
||||||
| platforms: | ||||||
| - name: instance | ||||||
|
|
||||||
| provisioner: | ||||||
| name: ansible | ||||||
| env: | ||||||
| ANSIBLE_ROLES_PATH: "${MOLECULE_PROJECT_DIRECTORY}/roles" | ||||||
| config_options: | ||||||
| defaults: | ||||||
| interpreter_python: auto_silent | ||||||
| any_errors_fatal: false | ||||||
| playbooks: | ||||||
| converge: converge.yml | ||||||
|
|
||||||
| verifier: | ||||||
| name: ansible | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||
| --- | ||||||
| - name: Create Proxmox snapshots before converge | ||||||
| hosts: localhost | ||||||
| gather_facts: false | ||||||
| vars: | ||||||
| snapshot_name: "molecule-before" | ||||||
| proxmox_api: &proxmox_api | ||||||
| api_host: "{{ lookup('env', 'PROXMOX_HOST') }}" | ||||||
| api_port: "{{ lookup('env', 'PROXMOX_PORT') | int }}" | ||||||
| api_user: "{{ lookup('env', 'PROXMOX_API_USER') }}" | ||||||
| api_token_id: "{{ lookup('env', 'PROXMOX_TOKEN_ID') }}" | ||||||
| api_token_secret: "{{ lookup('env', 'PROXMOX_TOKEN_SECRET') }}" | ||||||
| validate_certs: false | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: fd -type f -name "create.yml" | grep proxmoxRepository: marcinbojko/pld Length of output: 230 🏁 Script executed: fd -type f -name "destroy.yml" | grep proxmoxRepository: marcinbojko/pld Length of output: 230 🏁 Script executed: git ls-files | grep -E "proxmox.*\.yml"Repository: marcinbojko/pld Length of output: 146 🏁 Script executed: cat -n molecule/proxmox/create.ymlRepository: marcinbojko/pld Length of output: 1341 🏁 Script executed: cat -n molecule/proxmox/destroy.ymlRepository: marcinbojko/pld Length of output: 1223 Enable Proxmox API certificate verification by default. Both Suggested changes: molecule/proxmox/create.yml- validate_certs: false
+ validate_certs: "{{ lookup('env', 'PROXMOX_VALIDATE_CERTS') | default('true') | bool }}"molecule/proxmox/destroy.yml- validate_certs: false
+ validate_certs: "{{ lookup('env', 'PROXMOX_VALIDATE_CERTS') | default('true') | bool }}"Ref: https://docs.ansible.com/ansible/latest/collections/community/proxmox/proxmox_snap_module.html 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| tasks: | ||||||
| - name: Remove stale molecule snapshot if present | ||||||
| community.proxmox.proxmox_snap: | ||||||
| <<: *proxmox_api | ||||||
| vmid: "{{ item }}" | ||||||
| snapname: "{{ snapshot_name }}" | ||||||
| state: absent | ||||||
| loop: [153, 167] | ||||||
| ignore_errors: true | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "create.yml" -path "*/proxmox/*" | head -20Repository: marcinbojko/pld Length of output: 89 🏁 Script executed: cat -n ./molecule/proxmox/create.ymlRepository: marcinbojko/pld Length of output: 1341 🏁 Script executed: # Check if there are other similar Ansible patterns in the repo to understand error handling practices
rg "ignore_errors" --type yaml | head -20Repository: marcinbojko/pld Length of output: 1287 🏁 Script executed: # Check for failed_when patterns in similar contexts
rg "failed_when" --type yaml -A 1 -B 1 | head -40Repository: marcinbojko/pld Length of output: 2173 Handle only the "snapshot missing" error case explicitly instead of suppressing all errors. The failed_when: falseor with specific error checking: register: snapshot_result
failed_when: snapshot_result.failed and "snapshot does not exist" not in snapshot_result.msg | default("")🤖 Prompt for AI Agents |
||||||
|
|
||||||
| - name: Create snapshot | ||||||
| community.proxmox.proxmox_snap: | ||||||
| <<: *proxmox_api | ||||||
| vmid: "{{ item }}" | ||||||
| snapname: "{{ snapshot_name }}" | ||||||
| description: "Created by molecule before converge" | ||||||
| state: present | ||||||
| timeout: 120 | ||||||
| loop: [153, 167] | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| - name: Rollback Proxmox snapshots after converge | ||
| hosts: localhost | ||
| gather_facts: false | ||
| vars: | ||
| snapshot_name: "molecule-before" | ||
| proxmox_api: &proxmox_api | ||
| api_host: "{{ lookup('env', 'PROXMOX_HOST') }}" | ||
| api_port: "{{ lookup('env', 'PROXMOX_PORT') | int }}" | ||
| api_user: "{{ lookup('env', 'PROXMOX_API_USER') }}" | ||
| api_token_id: "{{ lookup('env', 'PROXMOX_TOKEN_ID') }}" | ||
| api_token_secret: "{{ lookup('env', 'PROXMOX_TOKEN_SECRET') }}" | ||
| validate_certs: false | ||
|
|
||
| tasks: | ||
| - name: Rollback to snapshot | ||
| community.proxmox.proxmox_snap: | ||
| <<: *proxmox_api | ||
| vmid: "{{ item }}" | ||
| snapname: "{{ snapshot_name }}" | ||
| state: rollback | ||
| timeout: 120 | ||
| loop: [153, 167] | ||
|
|
||
| - name: Delete snapshot | ||
| community.proxmox.proxmox_snap: | ||
| <<: *proxmox_api | ||
| vmid: "{{ item }}" | ||
| snapname: "{{ snapshot_name }}" | ||
| state: absent | ||
| loop: [153, 167] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| --- | ||
| dependency: | ||
| name: galaxy | ||
| options: | ||
| requirements-file: requirements.yml | ||
| ignore-certs: true | ||
| ignore-errors: true | ||
|
|
||
| driver: | ||
| name: default | ||
|
|
||
| platforms: | ||
| - name: mint22-0 | ||
| - name: mint22-2 | ||
|
|
||
| provisioner: | ||
| name: ansible | ||
| env: | ||
| ANSIBLE_ROLES_PATH: "${MOLECULE_PROJECT_DIRECTORY}/roles" | ||
| config_options: | ||
| defaults: | ||
| interpreter_python: auto_silent | ||
| any_errors_fatal: false | ||
| host_key_checking: false | ||
| connection_options: | ||
| ansible_user: "${PROXMOX_VM_USER}" | ||
| ansible_password: "${PROXMOX_VM_PASSWORD}" | ||
| ansible_become: true | ||
| ansible_become_password: "${PROXMOX_VM_PASSWORD}" | ||
| inventory: | ||
| hosts: | ||
| all: | ||
| hosts: | ||
| mint22-0: | ||
| ansible_host: "${PROXMOX_VM_167_HOST}" | ||
| proxmox_vmid: 167 | ||
| mint22-2: | ||
| ansible_host: "${PROXMOX_VM_153_HOST}" | ||
| proxmox_vmid: 153 | ||
| playbooks: | ||
| create: create.yml | ||
| destroy: destroy.yml | ||
| converge: ../default/converge.yml | ||
|
|
||
| verifier: | ||
| name: ansible |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| ansible-core>=2.19 | ||
| molecule>=25.7 | ||
| molecule-plugins>=25.8 | ||
| ansible-lint>=25.12 | ||
| yamllint>=1.37 | ||
| proxmoxer>=2.0 | ||
| requests>=2.31 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,4 @@ collections: | |
| - name: ansible.posix | ||
| - name: community.general | ||
| - name: community.crypto | ||
| - name: community.proxmox | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: marcinbojko/pld
Length of output: 119
🏁 Script executed:
Repository: marcinbojko/pld
Length of output: 119
🏁 Script executed:
Repository: marcinbojko/pld
Length of output: 69
🏁 Script executed:
# Read the workflow file to see current state cat -n .github/workflows/02_syntax_check.ymlRepository: marcinbojko/pld
Length of output: 955
🏁 Script executed:
Repository: marcinbojko/pld
Length of output: 41
🏁 Script executed:
# Check the default scenario configuration head -30 molecule/default/molecule.ymlRepository: marcinbojko/pld
Length of output: 510
🏁 Script executed:
# Check the proxmox scenario configuration head -30 molecule/proxmox/molecule.ymlRepository: marcinbojko/pld
Length of output: 693
🏁 Script executed:
Repository: marcinbojko/pld
Length of output: 41
🌐 Web query:
Molecule syntax command scenario behavior default💡 Result:
Molecule is an Ansible testing framework where scenarios define testing configurations in directories under molecule/, with the default scenario named "default". If no scenario is specified with -s/--scenario-name, Molecule targets the "default" scenario. Scenario syntax in molecule.yml: scenario: name: default # Optional; defaults to directory name if omitted test_sequence: - dependency - cleanup - destroy - syntax - create - prepare - converge - idempotence - side_effect - verify - cleanup - destroy # Similar for create_sequence, converge_sequence, etc. Commands like molecule test execute the defined sequence for the targeted scenario. molecule syntax runs syntax checks. Default behavior starts fresh by destroying existing instances unless overridden (e.g., --destroy=never). Scenarios are independent unless shared_state: true is configured. CLI example: molecule test # Runs default scenario's test_sequence molecule test -s my_scenario # Targets my_scenario molecule converge # Runs converge_sequence on default
Citations:
🌐 Web query:
molecule syntax all scenarios or single scenario💡 Result:
In Ansible Molecule, Molecule commands (such as test, syntax, converge, destroy, etc.) can target either a single scenario or all scenarios, using specific command-line syntax. Single scenario: Use the -s or --scenario-name option followed by the scenario name (defaults to 'default' if omitted). Examples: molecule test -s default molecule test -s tls molecule syntax --scenario-name clustered All scenarios: Use the --all flag (primarily documented for test, but applicable to other actions like destroy). Example: molecule test --all This runs the full test sequence across all discovered scenarios sequentially. Each scenario executes independently with its own lifecycle (destroy -> create -> ... -> destroy per test_sequence). Note: --all loops through each scenario, executing the command/sequence for one at a time. For destroy, some commands support destroy --all directly. Scenarios are directories under molecule/ (e.g., molecule/default, molecule/centos), each with its own molecule.yml configuring driver, platforms, sequences, etc. Official docs confirm --scenario-name targets specific/nested scenarios (with / or wildcards), while --all runs everything.
Citations:
Syntax check should explicitly cover both Molecule scenarios.
molecule syntaxwithout flags targets only the default scenario; the proxmox scenario syntax remains unchecked. Both scenarios must be validated. Use--scenario-nameto explicitly run syntax for each scenario, or use--allto run for all discovered scenarios.Suggested change
- name: Run molecule syntax run: molecule syntax + - name: Run molecule syntax (all scenarios) + run: | + molecule syntax --scenario-name default + molecule syntax --scenario-name proxmoxRef: https://molecule.readthedocs.io/usage/
📝 Committable suggestion
🤖 Prompt for AI Agents