From 64740f6083ef8cf388ea3570fb6dab8188da75eb Mon Sep 17 00:00:00 2001 From: Jedrzej Nowak Date: Tue, 18 Aug 2015 19:43:37 +0200 Subject: [PATCH] Added hosts_file resource --- resources/hosts_file/actions/run.yml | 11 +++++++++++ resources/hosts_file/meta.yaml | 20 ++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 resources/hosts_file/actions/run.yml create mode 100644 resources/hosts_file/meta.yaml diff --git a/resources/hosts_file/actions/run.yml b/resources/hosts_file/actions/run.yml new file mode 100644 index 00000000..abb3b5b8 --- /dev/null +++ b/resources/hosts_file/actions/run.yml @@ -0,0 +1,11 @@ +- hosts: {{ip}} + sudo: yes + tasks: + {% for ip, host in zip(hosts_ips.value, hosts_names.value) %} + - name: Create hosts entries for {{host['value']}} => {{ip['value']}} + lineinfile: + dest: /etc/hosts + regexp: '.*{{host["value"]}}$' + line: '{{ip["value"]}} {{host["value"]}}' + state: present + {% endfor %} diff --git a/resources/hosts_file/meta.yaml b/resources/hosts_file/meta.yaml new file mode 100644 index 00000000..096d1b13 --- /dev/null +++ b/resources/hosts_file/meta.yaml @@ -0,0 +1,20 @@ +id: hosts_file +handler: ansible +version: 1.0.0 + +input: + ip: + schema: str! + value: + ssh_key: + schema: str! + value: + ssh_user: + schema: str! + value: + hosts_names: + schema: [{value: str!}] + value: [] + hosts_ips: + schema: [{value: str!}] + value: []