replica-omnisciente/docs/guides/cli/ansible.md

2.4 KiB

ansible (Ansible CLI)

What it is

Agentless configuration management over SSH: ansible for ad-hoc commands, ansible-playbook for playbooks. Ideal for keeping the Proxmox nodes and CTs consistent.

Install

Via pipx (current stable, isolated env — preferred over the lagging distro package):

sudo apt install pipx
pipx install --include-deps ansible-core
pipx ensurepath        # re-login so ~/.local/bin is on PATH

Or the distro package if you don't need recent versions: sudo apt install ansible. Extra collections (e.g. community.general) via ansible-galaxy collection install <name>.

Authenticate

Auth = SSH. Use your existing key:

ssh-copy-id root@192.168.0.38      # asus
ssh-copy-id root@192.168.0.104     # gigabyte
ssh-copy-id root@192.168.0.40      # lattepanda

Vault-stored secrets (sudo passwords, API tokens) go in Vaultwarden (https://vault.portugalfuturista.org); for playbook-level secrets use ansible-vault encrypt_string.

Configure for this environment

Inventory ~/.ansible/inventory/proxmox.ini:

[proxmox]
asus       ansible_host=192.168.0.38
gigabyte   ansible_host=192.168.0.104
lattepanda ansible_host=192.168.0.40

[proxmox:vars]
ansible_user=root
ansible_python_interpreter=/usr/bin/python3

Ad-hoc check:

ansible -i ~/.ansible/inventory/proxmox.ini proxmox -m ping
ansible -i ~/.ansible/inventory/proxmox.ini proxmox -a "pveversion"

Self-hosted equivalent

Ansible is inherently self-hosted — controller on the laptop, targets on the LAN. No cloud service involved; the closest "managed" analogue (AWX/Tower) is overkill for three nodes.

Aurélio integration

The cli-devops skill uses ansible for fleet maintenance tasks against the Proxmox nodes. Connector registry id: ansible.

Verify

ansible --version
# ansible [core 2.x.y] ...
ansible -i ~/.ansible/inventory/proxmox.ini asus -m ping
# asus | SUCCESS => { "ping": "pong" }

Troubleshooting

  • UNREACHABLE — SSH key not installed on the node, or you're not on the LAN/VPN; test with plain ssh root@<ip>.
  • /usr/bin/python: not found — minimal Debian CTs ship only python3; set ansible_python_interpreter=/usr/bin/python3 (as above).
  • Privilege escalation prompts — add -b --ask-become-pass or configure passwordless sudo on managed CTs.
  • Slow runs — enable SSH pipelining and forks = 20 in ~/.ansible.cfg.