From 1610554eeae81a94ebc23b2caf1ac1950d6f8c1e Mon Sep 17 00:00:00 2001 From: Mike Kell Date: Tue, 29 Apr 2025 15:59:40 +0000 Subject: [PATCH] updated directory and f iles for molecule troubleshooting --- .github/workflows/ci.yml | 63 ++++++++++++++++++++++++++++++++++ check_molecule_structure.sh | 68 +++++++++++++++++++++++++++++++++++++ molecule.yml | 11 ++++++ 3 files changed, 142 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100755 check_molecule_structure.sh create mode 100644 molecule.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..92e09fa --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: OpenCMMC Stack CI Pipeline + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + terraform-validate: + name: Terraform Validate + runs-on: ubuntu-latest + defaults: + run: + working-directory: terraform/ + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: 1.6.6 # <- Pin version you're using + + - name: Initialize Terraform + run: terraform init -backend=false + + - name: Validate Terraform + run: terraform validate + + ansible-molecule: + name: Ansible Molecule Test + runs-on: ubuntu-latest + strategy: + matrix: + role: + - secure_ubuntu + - podman_services + - identity + - monitoring + - file_storage + defaults: + run: + working-directory: ansible/roles/${{ matrix.role }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install Ansible + Molecule + Drivers + run: | + python -m pip install --upgrade pip + pip install ansible ansible-lint molecule molecule-plugins[docker] docker + + - name: Run Molecule Tests + run: | + molecule test diff --git a/check_molecule_structure.sh b/check_molecule_structure.sh new file mode 100755 index 0000000..dd063f7 --- /dev/null +++ b/check_molecule_structure.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +echo "🔍 Checking Molecule structure under ansible/roles/..." + +# Define your role list +roles=( secure_ubuntu podman_services identity file_storage monitoring preflight ) + +exit_code=0 + +for role in "${roles[@]}" +do + echo "-------------------------------------------------" + echo "🔎 Checking role: $role" + + role_path="ansible/roles/$role/molecule/default" + + # Check if molecule/default/ exists + if [ ! -d "$role_path" ]; then + echo "❌ ERROR: Missing $role_path directory" + exit_code=1 + continue + fi + + # Check if molecule.yml exists + if [ ! -f "$role_path/molecule.yml" ]; then + echo "❌ ERROR: Missing molecule.yml in $role_path" + exit_code=1 + else + echo "✅ molecule.yml found." + fi + + # Check if scenario.yml exists + if [ ! -f "$role_path/scenario.yml" ]; then + echo "❌ ERROR: Missing scenario.yml in $role_path" + exit_code=1 + else + echo "✅ scenario.yml found." + fi + + # Optional: check create/converge/destroy/verify + for file in create.yml converge.yml destroy.yml verify.yml + do + if [ ! -f "$role_path/$file" ]; then + echo "⚠️ WARNING: Missing $file in $role_path (not critical but needed)" + else + echo "✅ $file present." + fi + done + + # Check if molecule.yml has valid YAML header + if ! grep -qE '^---' "$role_path/molecule.yml"; then + echo "❌ ERROR: molecule.yml does not start with valid YAML (---)" + exit_code=1 + else + echo "✅ molecule.yml starts with valid YAML header." + fi + +done + +echo "-------------------------------------------------" + +if [ "$exit_code" -eq 0 ]; then + echo "🎉 All Molecule role structures look good!" +else + echo "⚠️ There are some problems. Please fix them." +fi + +exit $exit_code diff --git a/molecule.yml b/molecule.yml new file mode 100644 index 0000000..7caca47 --- /dev/null +++ b/molecule.yml @@ -0,0 +1,11 @@ +--- +dependency: + name: galaxy +driver: + name: docker +platforms: + - name: instance +provisioner: + name: ansible +scenario: + name: default