From 9cc9cf7b5fdbc8eed4dd6a3080f5cbc2030da4e1 Mon Sep 17 00:00:00 2001 From: Jack Ivanov Date: Mon, 6 Mar 2017 00:55:54 +0300 Subject: [PATCH] local inventory #30 --- roles/local/tasks/main.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 }}"