diff --git a/playbooks/create_lxc.yml b/playbooks/create_lxc.yml index c564f10..85ae559 100644 --- a/playbooks/create_lxc.yml +++ b/playbooks/create_lxc.yml @@ -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'] }}" \ No newline at end of file + 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 \ No newline at end of file