Skip to content

idiv-biodiversity/ansible-role-hosts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Role: Static Host Configuration

An Ansible role to set static information about self and other hosts in /etc/hosts.

Table of Contents

Requirements

  • Ansible 2.10

Role Variables

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]

Dependencies

Add to requirements.yml:

roles:

  - name: idiv_biodiversity.hosts
    src: https://github.com/idiv-biodiversity/ansible-role-hosts
    version: vX.Y.Z

Example Playbook

Top-Level Playbook

Write a top-level playbook:

---

- name: head server
  hosts: head

  roles:
    - role: idiv_biodiversity.hosts
      tags:
        - hosts

...

Role Dependency

Define the role dependency in meta/main.yml:

---

dependencies:

  - role: idiv_biodiversity.hosts
    tags:
      - hosts

...

License

MIT

Author Information

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).