Skip to content

Commit

Permalink
Create local setup-ansible action
Browse files Browse the repository at this point in the history
  • Loading branch information
claha committed Jul 30, 2023
1 parent ea19f6a commit 546f5f4
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 165 deletions.
18 changes: 18 additions & 0 deletions .github/actions/setup-ansible/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: Setup ansible
descriptions: Install ansible and required roles/collections

runs:
using: composite
steps:
- uses: actions/[email protected]
with:
python-version: 3.x
- name: Install ansible and required roles/collections
shell: bash
run: |
pip install ansible
ansible-galaxy install --role-file requirements.yaml
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
10 changes: 1 addition & 9 deletions .github/workflows/autorestic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags autorestic \
--extra-vars "b2_account_id=ci b2_account_key=ci \
backblaze_homeassistant_key=ci \
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/dashdot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags dashdot
docker ps --filter name=dashdot | grep --quiet dashdot
10 changes: 1 addition & 9 deletions .github/workflows/diun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags diun \
--extra-vars "telegram_token=ci telegram_chatids=ci"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/dozzle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
docker network create --driver bridge proxy
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags dozzle \
--extra-vars "domain=ci"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/duckdns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags duckdns \
--extra-vars "duckdns_domain=ci duckdns_token=ci"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/gatus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags gatus \
--extra-vars "telegram_token=ci telegram_chatids=ci"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/glances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags glances
docker ps --filter name=glances | grep --quiet glances
10 changes: 1 addition & 9 deletions .github/workflows/healthchecks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags healthchecks
docker ps --filter name=healthchecks | grep --quiet healthchecks
13 changes: 3 additions & 10 deletions .github/workflows/homeassistant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags homeassistant \
--extra-vars "domain=ci b2_account_id=ci b2_account_key=ci \
backblaze_homeassistant_key=ci backblaze_zigbee2mqtt_key=ci"
backblaze_homeassistant_key=ci backblaze_zigbee2mqtt_key=ci \
healthchecks_backup_homeassistant_url=ci"
docker ps --filter name=homeassistant | grep --quiet homeassistant
docker exec homeassistant hass --config /config --script check_config
10 changes: 1 addition & 9 deletions .github/workflows/homepage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
docker network create --driver bridge proxy
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags homepage \
--extra-vars "domain=ci"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/mosquitto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags mosquitto
docker ps --filter name=mosquitto | grep --quiet mosquitto
10 changes: 1 addition & 9 deletions .github/workflows/piper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags piper
docker ps --filter name=piper | grep --quiet piper
10 changes: 1 addition & 9 deletions .github/workflows/speedtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
docker network create --driver bridge proxy
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags speedtest \
--extra-vars "domain=ci"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/tailscale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags tailscale
docker ps --filter name=tailscale | grep --quiet tailscale
10 changes: 1 addition & 9 deletions .github/workflows/traefik.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags traefik \
--extra-vars "domain=ci duckdns_token=ci \
traefik_username=ci traefik_password=ci \
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/uptimekuma.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags uptimekuma
docker ps --filter name=uptimekuma | grep --quiet uptimekuma
10 changes: 1 addition & 9 deletions .github/workflows/whisper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags whisper
docker ps --filter name=whisper | grep --quiet whisper
13 changes: 3 additions & 10 deletions .github/workflows/zigbee2mqtt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
python-version: 3.x

- uses: ./.github/actions/setup-ansible
- run: |
sed -i '/vars_files/I,+1 d' main.yaml
sed -i '/vault_password_file/d' ansible.cfg
sed -i '/devices/I,+1 d' roles/zigbee2mqtt/files/compose.yaml
sed -i '/platform/d' roles/zigbee2mqtt/files/compose.yaml
pip install ansible
ansible-galaxy install --role-file requirements.yaml
ansible-playbook main.yaml --limit localhost --tags zigbee2mqtt \
--extra-vars "mqtt_server=ci b2_account_id=ci b2_account_key=ci \
backblaze_homeassistant_key=ci backblaze_zigbee2mqtt_key=ci"
backblaze_homeassistant_key=ci backblaze_zigbee2mqtt_key=ci \
healthchecks_backup_homeassistant_url=ci"
docker ps --filter name=zigbee2mqtt | grep --quiet zigbee2mqtt
2 changes: 1 addition & 1 deletion roles/autorestic/templates/autorestic_backup.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ Description=Backup {{ autorestic_location }} using autorestic

[Service]
Type=simple
User={{ ansible_ssh_user }}
User={{ ansible_ssh_user | default(ansible_user_id) }}
WorkingDirectory={{ service_path }}
ExecStart=docker compose run autorestic bash -c "apk add curl && autorestic backup --verbose --location {{ autorestic_location }}"

0 comments on commit 546f5f4

Please sign in to comment.