Skip to content

Instantly share code, notes, and snippets.

@lae
Created March 24, 2017 23:09
Show Gist options
  • Save lae/c53e09d9c3aac15e94b542d2cf692a0a to your computer and use it in GitHub Desktop.
Save lae/c53e09d9c3aac15e94b542d2cf692a0a to your computer and use it in GitHub Desktop.
127.0.0.1 localhost
127.0.1.1 host-one.example.invalid host-one
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
# BEGIN ANSIBLE MANAGED: Proxmox Cluster Hosts
10.100.100.101 host-one.example.invalid host-one
10.100.100.102 host-three.example.invalid host-two
10.100.100.103 host-three.example.invalid host-three
# END ANSIBLE MANAGED: Proxmox Cluster Hosts
- name: Enumerate all cluster hosts within the hosts file
blockinfile:
dest: /etc/hosts
marker: "# {mark} ANSIBLE MANAGED: Proxmox Cluster Hosts"
content: |
{% for host in groups[pve_group] %}
{{ hostvars[host].ansible_default_ipv4.address }} {{ hostvars[host].ansible_fqdn }} {{ hostvars[host].ansible_hostname }}{% if ansible_fqdn == hostvars[host].ansible_fqdn %} pvelocalhost{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment