Feature: Add Ansible foundation and connectivity check #2
No files matched your search
@@ -0,0 +1,18 @@
|
||||
name: Check Connectivity
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-connectivity:
|
||||
name: Check Connectivity
|
||||
runs-on: ansible
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Show Ansible Version
|
||||
run: ansible-playbook --version
|
||||
|
||||
- name: Run Connectivity Playbook
|
||||
run: ansible-playbook playbooks/check-connectivity.yml
|
||||
@@ -9,7 +9,7 @@ Ansible automation for a Proxmox homelab. It deploys Docker stacks and single sc
|
||||
|
||||
## Layout (planned)
|
||||
|
||||
`inventory/hosts.yml`, `group_vars/`, `roles/{docker_stack,script,lxc_base}`, `stacks/<service>/{docker-compose.yml,env.j2}`, `scripts/`, `playbooks/`, `.gitea/workflows/`.
|
||||
`inventory/{hosts.yml,group_vars/}`, `roles/{docker_stack,script,lxc_base}`, `stacks/<service>/{docker-compose.yml,env.j2}`, `scripts/`, `playbooks/`, `.gitea/workflows/`.
|
||||
|
||||
## Deployment flow
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
[defaults]
|
||||
inventory = inventory/hosts.yml
|
||||
roles_path = roles
|
||||
host_key_checking = True
|
||||
interpreter_python = auto_silent
|
||||
retry_files_enabled = False
|
||||
|
||||
[ssh_connection]
|
||||
pipelining = True
|
||||
@@ -0,0 +1,3 @@
|
||||
---
|
||||
# Compose derives each project name from its folder, so these paths must not change.
|
||||
homelab_stacks_root: /home/pi/docker
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
# On the ansible LXC, ~/.ssh/config maps "docker" to its real address, user and key.
|
||||
all:
|
||||
children:
|
||||
control:
|
||||
hosts:
|
||||
ansible:
|
||||
ansible_connection: local
|
||||
docker_hosts:
|
||||
hosts:
|
||||
docker:
|
||||
@@ -0,0 +1,35 @@
|
||||
---
|
||||
# Read-only: proves Ansible can reach each host. It changes nothing.
|
||||
- name: Check that every host responds
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Ping host
|
||||
ansible.builtin.ping:
|
||||
|
||||
- name: Check the Docker host
|
||||
hosts: docker_hosts
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Read Docker Compose version
|
||||
ansible.builtin.command: docker compose version
|
||||
register: check_connectivity_compose
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
|
||||
- name: Show Docker Compose version
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ check_connectivity_compose.stdout }}"
|
||||
|
||||
- name: Read stacks root
|
||||
ansible.builtin.stat:
|
||||
path: "{{ homelab_stacks_root }}"
|
||||
register: check_connectivity_stacks_root
|
||||
|
||||
- name: Require stacks root
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- check_connectivity_stacks_root.stat.isdir is defined
|
||||
- check_connectivity_stacks_root.stat.isdir
|
||||
fail_msg: "{{ homelab_stacks_root }} is missing or is not a directory"
|
||||
quiet: true
|
||||
@@ -0,0 +1,4 @@
|
||||
---
|
||||
# Template only. The real file is /etc/homelab-ansible/vault.yml on the ansible LXC,
|
||||
# encrypted with ansible-vault and never committed.
|
||||
vault_example_secret: CHANGE_ME
|
||||
Reference in new issue
Block a user