Merge pull request 'Add an Gitea Action for Deploying Ansible Playbooks' (#1) from ansible-deploy-action into main
All checks were successful
Ansible Deploy / deploy (Ansible/cloudflare-dns.yml) (push) Successful in 1m5s
Ansible Deploy / deploy (Ansible/debian.yml) (push) Successful in 1m12s
Ansible Deploy / deploy (Ansible/heartbeat.yml) (push) Successful in 1m0s
Ansible Deploy / deploy (Ansible/openssh.yml) (push) Successful in 1m19s
Ansible Lint / build (push) Successful in 1m10s

Reviewed-on: #1
This commit is contained in:
Benjamin Hays 2024-10-13 01:42:00 +00:00
commit 8784058874
6 changed files with 34 additions and 12 deletions

View File

@ -3,6 +3,9 @@ on: [push]
jobs:
deploy:
runs-on: ubuntu-latest
env:
RUNNER_TOOL_CACHE: /toolcache
ANSIBLE_VERSION: "8.7.0"
strategy:
matrix:
playbook:
@ -11,7 +14,29 @@ jobs:
- Ansible/heartbeat.yml
- Ansible/debian.yml
steps:
- uses: actions/checkout@v3
- name: Copy SSH Key
run: |
mkdir ~/.ssh/
echo "Host *" > ~/.ssh/config
echo " StrictHostKeyChecking no" >> ~/.ssh/config
echo '${{secrets.SSH_PRIVATE_KEY}}' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- uses: actions/checkout@v3
with:
submodules: recursive
- name: "Cache python packages"
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ env.ANSIBLE_VERSION }}
- name: Install Ansible
run: |
apt update -y
apt install python3-pip -y
python3 -m pip install ansible==${{ env.ANSIBLE_VERSION }}
#- name: Install Ansible Galaxy requirements
# run: |
@ -20,17 +45,13 @@ jobs:
- name: Run playbook
uses: dawidd6/action-ansible-playbook@v2
with:
# Required, playbook filepath
playbook: ${{ matrix.playbook }}
# Optional, directory where playbooks live
directory: ./
# Optional, SSH private key
key: ${{secrets.SSH_PRIVATE_KEY}}
vault_password: ${{secrets.VAULT_PASSWORD}}
# Optional, galaxy requirements filepath
# requirements: requirements.yaml
options: |
--inventory Ansible/inventory.ini
--inventory Ansible/inventory.ini
--extra-vars "@Ansible/homelab-vault/secrets.yml"

View File

@ -4,4 +4,4 @@ host_key_checking = False
inventory = ./inventory.ini
[privilege_escalation]
become_ask_pass = True
#become_ask_pass = True

@ -1 +1 @@
Subproject commit 6b8679decc51b10d3a028993d11892be763e0eb7
Subproject commit e95c8ff2aef2e919e5bf0fc8133aaec69ea8dc08

View File

@ -31,7 +31,7 @@
ansible.builtin.copy:
owner: bhays
mode: "0600"
src: ~/.ssh/authorized_keys
src: ../Configs/authorized_keys
dest: /home/bhays/.ssh/authorized_keys
- name: Copy secure login banner
ansible.builtin.copy:

1
Configs/authorized_keys Normal file
View File

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQClhOkA+6Wj+HmJb32wqDXAksOr7mhRovSQAt/6PNem/q0R+JA4qyYpStPAkLTHmUJhUPYlyeVPJyaGxRyE96SSrLxy2tGvfch1D2XkrYTZoyEYc0QNg2PfgCkAZofDSPrErzcAzT9XBJ+/9rga8IBZ3F8Nm1gl401y0Ckchdne/i+npVurimpSMJbIwjIsg7ij1gWLL4idIftW7IDloWedI1O2XdBW9VDpA/zq46tBwt3Jeelv5oDCup6g9wLQwBpmegWXYS+p47vGzIYp2qBI2D/opOZCUaBNT81G80E9H0fsNDi8xCBfVj7zgBQHzviqGFqeKjU39FbLZlkeISMX rsa-key-20231020

View File

@ -4,4 +4,4 @@ host_key_checking = False
inventory = ./Ansible/inventory.ini
[privilege_escalation]
become_ask_pass = True
#become_ask_pass = True