diff --git a/roles/local/tasks/main.yml b/roles/local/tasks/main.yml index d2deff6..9b34d7c 100644 --- a/roles/local/tasks/main.yml +++ b/roles/local/tasks/main.yml @@ -19,3 +19,17 @@ - set_fact: cloud_instance_ip: "{{ server_ip }}" + +- name: Ensure the group local exists in the dynamic inventory file + lineinfile: + state: present + dest: configs/inventory.dynamic + line: '[local]' + +- name: Populate the dynamic inventory + lineinfile: + state: present + dest: configs/inventory.dynamic + insertafter: '\[local\]' + regexp: "^{{ server_ip }}.*" + line: "{{ server_ip }}"