Skip to content

GitHub Action to run SOPS-enabled Ansible with inventory directory.

License

Notifications You must be signed in to change notification settings

dmitriysafronov/run-ansible-inventory

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

run-ansible-inventory

GitHub Action to run SOPS-enabled Ansible with inventory directory.

Example:

name: Ansible

"on":
  pull_request:
    branches: [main]
    paths:
      - "inventory/**/*"
  push:
    branches: [main]
    paths:
      - "inventory/**/*"

jobs:

  find-out-changed-inventories:
    name: Find out changed inventories
    runs-on: ubuntu-latest
    outputs:
      directories: ${{ steps.changed-files.outputs.directories }}
    steps:
      - name: Get Ansible changed inventories directories
        uses: dmitriysafronov/get-ansible-changed-inventories@v1.0.2
        id: changed-files

  run-ansible-on-changed-inventories:
    name: Ansible
    runs-on: ubuntu-latest
    strategy:
      matrix:
        directory: ${{ fromJson(needs.find-out-changed-inventories.outputs.directories) }}
    needs:
      - find-out-changed-inventories
    steps:
      - name: Run SOPS-enabled Ansible with inventory directory
        uses: dmitriysafronov/run-ansible-inventory@v1.0.2
        with:
          directory: ${{ matrix.directory }}
          ssh-private-key: ${{ secrets.ANSIBLE_SSH_PRIVATE_KEY }}
          sops-age-private-key: ${{ secrets.ANSIBLE_SOPS_AGE_KEY }}