add hosts file management
This commit is contained in:
parent
4481b8277d
commit
f8cffd3b03
@ -111,3 +111,8 @@ privatekeytodeploy: []
|
||||
# keyfile: /root/.ssh/id_rsa
|
||||
# privatekey: {{ vault_privatekey }}
|
||||
|
||||
# Custom hosts entries to be added
|
||||
hosts_entries: []
|
||||
|
||||
# Custom host file snippets to be added
|
||||
hosts_file_snippets: []
|
||||
|
8
tasks/hosts.yml
Normal file
8
tasks/hosts.yml
Normal file
@ -0,0 +1,8 @@
|
||||
- name: Install custom hosts file
|
||||
become: true
|
||||
template:
|
||||
src: etc_hosts.j2
|
||||
dest: "{{ hosts_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
@ -1,4 +1,5 @@
|
||||
#- include_tasks: hostname.yml
|
||||
- include_tasks: hosts.yml
|
||||
- include_tasks: hostname.yml
|
||||
- include_tasks: locales.yml
|
||||
- include_tasks: time.yml
|
||||
|
19
templates/etc_hosts.j2
Normal file
19
templates/etc_hosts.j2
Normal file
@ -0,0 +1,19 @@
|
||||
# Hosts file -- Don't edit manually!
|
||||
#
|
||||
# {{ ansible_managed }}
|
||||
{% if hosts_entries|length != 0 %}
|
||||
|
||||
# Custom entries
|
||||
{% for host in hosts_entries %}
|
||||
{{ host.ip }} {{ host.name }} {{ host.aliases | default('') | join(' ') }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if hosts_file_snippets %}
|
||||
|
||||
#
|
||||
# Hosts file snippets
|
||||
#
|
||||
|
||||
{{ hosts_file_snippets }}
|
||||
|
||||
{% endif %}
|
@ -0,0 +1,2 @@
|
||||
---
|
||||
hosts_file: "/etc/hosts"
|
Loading…
Reference in New Issue
Block a user