aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/lint-ansible.yaml
blob: 8795947c655333e6d01966a7fe1493f93d1e734a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Lint Ansible play books

on:
  workflow_call:

jobs:
  lint-ansible:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          submodules: recursive
          sparse-checkout: |
            ansible
            pyproject.toml
            uv.lock

      - name: Install uv
        uses: astral-sh/setup-uv@v6
        with:
          enable-cache: true
          cache-dependency-glob: "uv.lock"
          activate-environment: true

      - name: Install dependencies
        run: uv sync --frozen --only-group ansible

      - name: Cache Ansible dependencies
        id: cache-ansible
        uses: actions/cache@v4
        with:
          path: ansible/.ansible
          key: ansible-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'uv.lock', 'ansible/roles/requirements.yml') }}

      - name: Install Ansible Galaxy dependencies
        run: cd ansible && ansible-galaxy install -r roles/requirements.yml

      - name: Run ansible lint
        run: |
          cd ansible
          # Remove any Vaulted files and Vault configuration
          grep -R '$ANSIBLE_VAULT;' --files-with-matches . | xargs rm
          sed --in-place '/vault_password_file/d' ansible.cfg
          ansible-lint --exclude .ansible