{"id":15775047,"url":"https://github.com/jtyr/ansible-etc_hosts","last_synced_at":"2026-05-07T11:33:52.441Z","repository":{"id":69603075,"uuid":"104350461","full_name":"jtyr/ansible-etc_hosts","owner":"jtyr","description":"Ansible role which contains a module that helps to manage the /etc/hosts file.","archived":false,"fork":false,"pushed_at":"2020-01-10T14:17:26.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-06T19:53:32.155Z","etag":null,"topics":["ansible","ansible-role","etc-hosts"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jtyr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-21T13:17:17.000Z","updated_at":"2020-05-08T19:06:54.000Z","dependencies_parsed_at":"2023-04-16T08:35:23.794Z","dependency_job_id":null,"html_url":"https://github.com/jtyr/ansible-etc_hosts","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jtyr/ansible-etc_hosts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-etc_hosts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-etc_hosts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-etc_hosts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-etc_hosts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtyr","download_url":"https://codeload.github.com/jtyr/ansible-etc_hosts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-etc_hosts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32735207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-role","etc-hosts"],"created_at":"2024-10-04T16:42:07.016Z","updated_at":"2026-05-07T11:33:52.422Z","avatar_url":"https://github.com/jtyr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"etc_hosts\n=========\n\nAnsible role which helps to manage the `/etc/hosts` file.\n\nModule used by this role was originally submitted as a\n[PR](https://github.com/ansible/ansible/pull/19283) to Ansible but it was\nrefused.\n\n\nExamples\n--------\n\n```yaml\n- name: Example how to use the etc_hosts role\n  hosts: all\n  vars:\n    etc_hosts:\n      # Add simple record\n      - ip: 10.0.0.2\n        hostname: some.domain3.com\n      # Add record with aliases\n      - ip: 10.0.0.4\n        hostname: some.domain4.com\n        alias:\n          - some\n          - other\n          - alias\n      # Remove record\n      - ip: 10.0.0.4\n        hostname: some.domain4.com\n        state: absent\n  roles:\n    - etc_hosts\n\n- name: Example how to use the etc_hosts module in standalone mode\n  hosts: all\n  roles:\n    - etc_hosts\n  tasks:\n    - name: Add a new record without alias\n      etc_hosts:\n        ip: 10.0.0.1\n        hostname: some.domain1.com\n\n    - name: Add a new record with hostname for the same IP\n      etc_hosts:\n        ip: 10.0.0.1\n        hostname: some.domain2.com\n\n    - name: Add a new record with another IP for the same hostname\n      etc_hosts:\n        ip: 10.0.0.2\n        hostname: some.domain3.com\n\n    - name: Add a new record with hostname and alias for the same IP\n      etc_hosts:\n        ip: 10.0.0.3\n        hostname: some.domain3.com\n        alias: some\n\n    - name: Add a new record with multiple aliases\n      etc_hosts:\n        ip: 10.0.0.4\n        hostname: some.domain4.com\n        alias:\n          - some\n          - other\n\n    - name: Update the list of aliases for the existing IP and hostname\n      etc_hosts:\n        ip: 10.0.0.4\n        hostname: some.domain4.com\n        alias:\n          - some\n          - other\n          - alias\n\n    - name: Remove all records with the specified IP\n      etc_hosts:\n        ip: 10.0.0.1\n        state: absent\n\n    - name: Remove all records with the specified hostname\n      etc_hosts:\n        hostname: some.domain3.com\n        state: absent\n\n    - name: Remove record with specified IP and hostname\n      etc_hosts:\n        ip: 10.0.0.4\n        hostname: some.domain4.com\n        state: absent\n```\n\n\nInstallation\n------------\n\nThe role can be downloaded either via Ansible Galaxy command:\n\n```shell\n$ ansible-galaxy install jtyr.etc_hosts,master,etc_hosts\n```\n\nor via Ansible Gallaxy requirements file:\n\n```shell\n$ cat ./requirements.yaml\n---\n\n- src: https://github.com/jtyr/ansible-etc_hosts.git\n  name: etc_hosts\n$ ansible-galaxy -r ./requirements.yaml\n```\n\nor via Git:\n\n```shell\n$ git clone https://github.com/jtyr/ansible-etc_hosts.git etc_hosts\n```\n\n\nLicense\n-------\n\nMIT\n\n\nAuthor\n------\n\nJiri Tyr\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyr%2Fansible-etc_hosts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtyr%2Fansible-etc_hosts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyr%2Fansible-etc_hosts/lists"}