An Ansible role to set static information about self and other hosts in
/etc/hosts
.
- Ansible 2.10
Self describing information:
system_hostname: '{{ ansible_hostname }}'
system_domain: example.com
Whether to manage self with a local IP entry:
system_hosts_manage_self: yes
This would create an entry like that:
127.0.1.1 {{ system_hostname }}
Additional hosts for /etc/hosts
, grouped in sections:
system_hosts_sections:
- name: database servers
entries:
- name: mars.example.com
address: 192.168.1.1
aliases: [mars]
- name: venus.example.com
address: 192.168.1.2
aliases: [venus]
- name: web servers
entries:
- name: jupiter.example.com
address: 192.168.2.1
aliases: [jupiter]
- name: saturn.example.com
address: 192.168.2.2
aliases: [saturn]
Add to requirements.yml
:
roles:
- name: idiv_biodiversity.hosts
src: https://github.com/idiv-biodiversity/ansible-role-hosts
version: vX.Y.Z
Write a top-level playbook:
---
- name: head server
hosts: head
roles:
- role: idiv_biodiversity.hosts
tags:
- hosts
...
Define the role dependency in meta/main.yml
:
---
dependencies:
- role: idiv_biodiversity.hosts
tags:
- hosts
...
MIT
This role was created in 2021 by Christian Krause aka wookietreiber at GitHub, HPC cluster systems administrator at the German Centre for Integrative Biodiversity Research (iDiv).