feat: automatically commit and push new host inventory changes to Git

This commit is contained in:
2026-01-04 13:05:28 +01:00
parent deefc70056
commit 1720a781b7

View File

@@ -155,4 +155,16 @@
{{ hostvars[item]['inventory_hostname'] }} ansible_host={{ hostvars[item]['ansible_host'] }}
insertafter: "^\\[lxc\\]"
marker: "# {mark} ANSIBLE MANAGED BLOCK FOR HOST {{ hostvars[item]['inventory_hostname'] }}"
loop: "{{ groups['new'] }}"
loop: "{{ groups['new'] }}"
- name: Commit and Push Inventory Changes to Git
ansible.builtin.shell: |
git config --global user.email "ansible@homelab.local"
git config --global user.name "Ansible Automation"
git add inventory/hosts.ini
git commit -m "Ansible: Added host {{ hostvars[item]['inventory_hostname'] }} to inventory"
git push
args:
chdir: "{{ playbook_dir }}/../"
loop: "{{ groups['new'] }}"
ignore_errors: yes