Manage localhost and default_ipv4 line in /etc/hosts.
This commit is contained in:
commit
72dbcd241f
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
## v1.0
|
||||||
|
|
||||||
|
### Features
|
||||||
|
* Manage localhost line in /etc/hosts.
|
||||||
|
* Manage ipv4 line in /etc/hosts.
|
|
@ -0,0 +1,63 @@
|
||||||
|
# Basics
|
||||||
|
|
||||||
|
1. [Overview](#overview)
|
||||||
|
2. [Role Variables](#role-variables)
|
||||||
|
3. [Example Playbook](#example-playbook)
|
||||||
|
4. [Configuration](#configuration)
|
||||||
|
* [Hosts](#hosts)
|
||||||
|
5. [Development](#development)
|
||||||
|
6. [License](#license)
|
||||||
|
7. [Author Information](#author-information)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Manage some basics configuration for IPR's servers.
|
||||||
|
|
||||||
|
## Role Variables
|
||||||
|
|
||||||
|
* **basics__domain** : Domain to use [default : `{{ ansible_domain }}`].
|
||||||
|
* **basics__hosts_localhost_manage** : If the localhost (127.0.0.1) line should be managed [default : `false`].
|
||||||
|
* **basics__hosts_localhost_content** : Content of the localhost (127.0.0.1) line [default : `{{ ansible_hostname }}.{{ basics__domain }} {{ ansible_hostname }} localhost.localdomain localhost`].
|
||||||
|
* **basics__hosts_ipv4_manage** : If the ipv4 (lan) line should be managed [default : `false`].
|
||||||
|
* **basics__hosts_ipv4_content** : Content of the ipv4 (lan) line [default : `{{ ansible_hostname }}.{{ basics__domain }} {{ ansible_hostname }}`].
|
||||||
|
|
||||||
|
## Example Playbook
|
||||||
|
|
||||||
|
* Use defaults vars :
|
||||||
|
|
||||||
|
``` yml
|
||||||
|
- hosts: serverXYZ
|
||||||
|
roles:
|
||||||
|
- role: ipr-cnrs.basics
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
### Hosts
|
||||||
|
- Ensure to have the correct fqdn and hostname in /etc/hosts.
|
||||||
|
- You can define the domain if it's not correct on the remote host.
|
||||||
|
- You can choose to define the localhost (127.0.0.1) line or/and the ipv4 (lan) line.
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
This source code comes from our [Gogs instance][basics source] and the [Github repo][basics github] exist just to be able to send the role to Ansible Galaxy…
|
||||||
|
|
||||||
|
But feel free to send issue/PR here :)
|
||||||
|
|
||||||
|
Thanks to this [hook][gogs to github hook], Github automatically got updates from our [Gogs instance][basics source] :)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[WTFPL][wtfpl website]
|
||||||
|
|
||||||
|
## Author Information
|
||||||
|
|
||||||
|
Jérémy Gardais
|
||||||
|
* Source : [on IPR's Gogs][basics source]
|
||||||
|
* [IPR][ipr website] (Institut de Physique de Rennes)
|
||||||
|
|
||||||
|
[gogs to github hook]: https://stackoverflow.com/a/21998477
|
||||||
|
[basics source]: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.basics
|
||||||
|
[basics github]: https://github.com/ipr-cnrs/basics
|
||||||
|
[wtfpl website]: http://www.wtfpl.net/about/
|
||||||
|
[ipr website]: https://ipr.univ-rennes1.fr/
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
# defaults file for basics
|
||||||
|
|
||||||
|
# Domain
|
||||||
|
basics__domain: "{{ ansible_domain }}"
|
||||||
|
|
||||||
|
# Manage /etc/hosts
|
||||||
|
basics__hosts_localhost_manage: false
|
||||||
|
basics__hosts_localhost_content: "{{ ansible_hostname }}.{{ basics__domain }} {{ ansible_hostname }} localhost.localdomain localhost"
|
||||||
|
basics__hosts_ipv4_manage: false
|
||||||
|
basics__hosts_ipv4_content: "{{ ansible_hostname }}.{{ basics__domain }} {{ ansible_hostname }}"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
# handlers file for basics
|
|
@ -0,0 +1,22 @@
|
||||||
|
galaxy_info:
|
||||||
|
author: "Jérémy Gardais"
|
||||||
|
description: "Manage some basics configurations for IPR's servers."
|
||||||
|
license: WTFPL
|
||||||
|
company: IPR
|
||||||
|
issue_tracker_url: https://git.ipr.univ-rennes1.fr/cellinfo/ansible.basics/issues
|
||||||
|
min_ansible_version: 2.2
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- stretch
|
||||||
|
#- name: opensuse
|
||||||
|
# versions:
|
||||||
|
# - all
|
||||||
|
# - 12.1
|
||||||
|
# - 12.2
|
||||||
|
# - 12.3
|
||||||
|
# - 13.1
|
||||||
|
# - 13.2
|
||||||
|
galaxy_tags:
|
||||||
|
- system
|
||||||
|
- debian
|
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
# tasks file for basics
|
||||||
|
|
||||||
|
- name: Set 127.0.0.1 line in hosts file
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
state: present
|
||||||
|
regexp: "^{{ ansible_lo.ipv4.address }}"
|
||||||
|
line: "{{ ansible_lo.ipv4.address }} {{ basics__hosts_localhost_content }}"
|
||||||
|
backup: yes
|
||||||
|
when: (basics__hosts_localhost_manage and
|
||||||
|
ansible_lo.ipv4.address is defined)
|
||||||
|
|
||||||
|
- name: Set ipv4 line in hosts file
|
||||||
|
lineinfile:
|
||||||
|
dest: /etc/hosts
|
||||||
|
state: present
|
||||||
|
regexp: "^{{ ansible_default_ipv4.address }}"
|
||||||
|
line: "{{ ansible_default_ipv4.address }} {{ basics__hosts_ipv4_content }}"
|
||||||
|
backup: yes
|
||||||
|
when: (basics__hosts_ipv4_manage and
|
||||||
|
ansible_default_ipv4.address is defined)
|
|
@ -0,0 +1 @@
|
||||||
|
localhost
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- apt
|
Reference in New Issue