# Generated by tools/hardened.py from ../t1. Edit t1 or the script; this file is regenerated. # # Copy to .github/workflows/ in the repository that contains this folder, and set # FOLDER below if it lives somewhere else. Commit inventory.ini beside # site.yml. # # On a pull request that touches the folder: ansible-lint on the production # profile, the rules in policy/ against settings.yml, and a syntax check. # Every day: a check-mode run against every machine. Anything it would change # was changed by hand; the job fails and opens an issue. name: guard ssh-hardening windows on: pull_request: paths: - "outcomes/ssh-hardening/windows/t1/**" - "outcomes/ssh-hardening/windows/t2/**" schedule: - cron: "23 6 * * *" workflow_dispatch: permissions: contents: read issues: write concurrency: group: guard-ssh-hardening-windows cancel-in-progress: false jobs: guard: runs-on: ubuntu-latest timeout-minutes: 60 env: FOLDER: outcomes/ssh-hardening/windows/t2 ANSIBLE_FORCE_COLOR: "0" steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version: "3.12" - uses: open-policy-agent/setup-opa@b2b258e089860efaadaaf71bf6e3aecb4a3eeff1 # v2.4.0 with: version: 1.21.0 - name: install run: | pip install ansible-core==2.21.4 ansible-lint==26.9.0 pywinrm cd "$FOLDER" ansible-galaxy collection install -r ../t1/requirements.yml - name: lint, rules, and syntax run: | cd "$FOLDER" ansible-lint opa eval --fail-defined --format pretty -d policy -i settings.yml 'data.iac.deny[msg]' ansible-playbook -i inventory.ini site.yml --syntax-check # WinRM. inventory.ini sets ansible_user and reads the password with # ansible_password="{{ lookup('env', 'ANSIBLE_WINRM_PASSWORD') }}". - name: credentials run: echo "ANSIBLE_WINRM_PASSWORD=${{ secrets.ANSIBLE_WINRM_PASSWORD }}" >> "$GITHUB_ENV" - name: drift if: github.event_name != 'pull_request' env: GH_TOKEN: ${{ github.token }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | cd "$FOLDER" ansible-playbook -i inventory.ini site.yml --check --diff | tee run.log if grep -Eq 'changed=[1-9]' run.log; then gh issue create --repo "$GITHUB_REPOSITORY" \ --title "Drift: $FOLDER no longer matches its machines" \ --body "A check-mode run found settings changed outside Ansible. Run: $RUN_URL" exit 1 fi