Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jtyr/ansible-etc_hosts
Ansible role which contains a module that helps to manage the /etc/hosts file.
https://github.com/jtyr/ansible-etc_hosts
ansible ansible-role etc-hosts
Last synced: about 1 month ago
JSON representation
Ansible role which contains a module that helps to manage the /etc/hosts file.
- Host: GitHub
- URL: https://github.com/jtyr/ansible-etc_hosts
- Owner: jtyr
- License: mit
- Created: 2017-09-21T13:17:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-10T14:17:26.000Z (about 5 years ago)
- Last Synced: 2024-12-06T19:53:32.155Z (about 1 month ago)
- Topics: ansible, ansible-role, etc-hosts
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
etc_hosts
=========Ansible role which helps to manage the `/etc/hosts` file.
Module used by this role was originally submitted as a
[PR](https://github.com/ansible/ansible/pull/19283) to Ansible but it was
refused.Examples
--------```yaml
- name: Example how to use the etc_hosts role
hosts: all
vars:
etc_hosts:
# Add simple record
- ip: 10.0.0.2
hostname: some.domain3.com
# Add record with aliases
- ip: 10.0.0.4
hostname: some.domain4.com
alias:
- some
- other
- alias
# Remove record
- ip: 10.0.0.4
hostname: some.domain4.com
state: absent
roles:
- etc_hosts- name: Example how to use the etc_hosts module in standalone mode
hosts: all
roles:
- etc_hosts
tasks:
- name: Add a new record without alias
etc_hosts:
ip: 10.0.0.1
hostname: some.domain1.com- name: Add a new record with hostname for the same IP
etc_hosts:
ip: 10.0.0.1
hostname: some.domain2.com- name: Add a new record with another IP for the same hostname
etc_hosts:
ip: 10.0.0.2
hostname: some.domain3.com- name: Add a new record with hostname and alias for the same IP
etc_hosts:
ip: 10.0.0.3
hostname: some.domain3.com
alias: some- name: Add a new record with multiple aliases
etc_hosts:
ip: 10.0.0.4
hostname: some.domain4.com
alias:
- some
- other- name: Update the list of aliases for the existing IP and hostname
etc_hosts:
ip: 10.0.0.4
hostname: some.domain4.com
alias:
- some
- other
- alias- name: Remove all records with the specified IP
etc_hosts:
ip: 10.0.0.1
state: absent- name: Remove all records with the specified hostname
etc_hosts:
hostname: some.domain3.com
state: absent- name: Remove record with specified IP and hostname
etc_hosts:
ip: 10.0.0.4
hostname: some.domain4.com
state: absent
```Installation
------------The role can be downloaded either via Ansible Galaxy command:
```shell
$ ansible-galaxy install jtyr.etc_hosts,master,etc_hosts
```or via Ansible Gallaxy requirements file:
```shell
$ cat ./requirements.yaml
---- src: https://github.com/jtyr/ansible-etc_hosts.git
name: etc_hosts
$ ansible-galaxy -r ./requirements.yaml
```or via Git:
```shell
$ git clone https://github.com/jtyr/ansible-etc_hosts.git etc_hosts
```License
-------MIT
Author
------Jiri Tyr