Open
Description
Add a default variable to let users set other hosts.
Currently, I am using the below code.
- name: Add hostname to /etc/hosts
become: true
lineinfile:
dest: /etc/hosts
regexp: "127[.]0[.]0[.]1.*"
line: "127.0.0.1 localhost.localdomain localhost {{ ansible_hostname }} # added by ansible"
state: present
backup: yes
- name: Add Ansible inventory mappings to /etc/hosts
become: true
blockinfile:
path: /etc/hosts
block: |
{% for host in groups['all'] %}
{{ hostvars[host].ansible_host }} {{ host }}
{% endfor %}
I am thinking of switching over to this role and would be great if this part can be handled in this role itself.
FYI, I understand that you guys use 127.0.1.1 for hostname. I'm fine with that approach too. Just need space for peer hosts.
Metadata
Metadata
Assignees
Labels
No labels