Initial Ansible inventory and playbooks

This commit is contained in:
vrubelroman 2026-06-01 23:09:25 +03:00
commit c642a36406
5 changed files with 49 additions and 0 deletions

6
.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
# local/private files
.env
.vault_pass
*.retry
keys/id_*
keys/*.pem

15
add-ssh-key.yml Normal file
View file

@ -0,0 +1,15 @@
---
- name: Add SSH public key to VM user
hosts: proxmox_vms
gather_facts: false
vars:
target_user: vrubel
key_file: "{{ lookup('env', 'HOME') }}/.ssh/id_ed25519.pub"
tasks:
- name: Add public key to authorized_keys
ansible.posix.authorized_key:
user: "{{ target_user }}"
state: present
key: "{{ lookup('file', key_file) }}"

4
ansible.cfg Normal file
View file

@ -0,0 +1,4 @@
[defaults]
inventory = inventory.ini
interpreter_python = auto_silent
host_key_checking = True

16
facts.yml Normal file
View file

@ -0,0 +1,16 @@
---
- name: Show VM facts
hosts: proxmox_vms
gather_facts: true
tasks:
- name: Print important facts
ansible.builtin.debug:
msg:
- "Host: {{ inventory_hostname }}"
- "Hostname: {{ ansible_facts[\"hostname\"] }}"
- "OS family: {{ ansible_facts[\"os_family\"] }}"
- "Distribution: {{ ansible_facts[\"distribution\"] }}"
- "Distribution version: {{ ansible_facts[\"distribution_version\"] }}"
- "Package manager: {{ ansible_facts[\"pkg_mgr\"] }}"
- "Python: {{ ansible_facts[\"python\"][\"executable\"] }}"

8
inventory.ini Normal file
View file

@ -0,0 +1,8 @@
[proxmox_vms]
nginx ansible_host=192.168.8.170 ansible_user=vrubel
docker-prod ansible_host=192.168.8.171 ansible_user=vrubel
fedoraXfce ansible_host=192.168.8.172 ansible_user=vrubel
hermes ansible_host=192.168.8.173 ansible_user=vrubel
docker-test ansible_host=192.168.8.174 ansible_user=vrubel
cicd ansible_host=192.168.8.175 ansible_user=vrubel
monitoring ansible_host=192.168.8.176 ansible_user=vrubel