{"id":15080755,"url":"https://github.com/francomile/ansible-role-set-hostname","last_synced_at":"2026-02-14T15:31:46.390Z","repository":{"id":244717236,"uuid":"815705987","full_name":"francomile/ansible-role-set-hostname","owner":"francomile","description":"Ansible Role Set Hostname","archived":false,"fork":false,"pushed_at":"2024-06-16T23:25:01.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-11T01:52:39.709Z","etag":null,"topics":["ansible-role","hostname","hosts-file"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francomile.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-15T22:34:59.000Z","updated_at":"2024-06-16T23:25:04.000Z","dependencies_parsed_at":"2024-06-17T00:40:20.183Z","dependency_job_id":null,"html_url":"https://github.com/francomile/ansible-role-set-hostname","commit_stats":null,"previous_names":["francomile/ansible-role-set-hostname"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/francomile/ansible-role-set-hostname","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francomile%2Fansible-role-set-hostname","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francomile%2Fansible-role-set-hostname/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francomile%2Fansible-role-set-hostname/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francomile%2Fansible-role-set-hostname/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francomile","download_url":"https://codeload.github.com/francomile/ansible-role-set-hostname/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francomile%2Fansible-role-set-hostname/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29447982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T14:10:32.461Z","status":"ssl_error","status_checked_at":"2026-02-14T14:09:49.945Z","response_time":53,"last_error":"SSL_read: 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-role","hostname","hosts-file"],"created_at":"2024-09-25T05:30:30.249Z","updated_at":"2026-02-14T15:31:46.371Z","avatar_url":"https://github.com/francomile.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible Set-Hostname Role\n\n[![Lint Ansible roles](https://github.com/francomile/ansible-role-set-hostname/actions/workflows/ansible_lint.yml/badge.svg)](https://github.com/francomile/ansible-role-set-hostname/actions/workflows/ansible_lint.yml)\n\n[![Release role to Ansible Galaxy](https://github.com/francomile/ansible-role-set-hostname/actions/workflows/push_to_galaxy.yml/badge.svg)](https://github.com/francomile/ansible-role-set-hostname/actions/workflows/push_to_galaxy.yml)\n\n## Actions of the Role\n\n* Set hostname via systemd\n* Copy /etc/hostname template in place\n* Copy /etc/hosts template in place\n\n## Common Usage\n\n```yaml\nroles:\n- { role: francomile.set-hostname,\n    # Set default instance hostname, by default it will pick the inventory hostname.\n    set_hostname_default_hostname: \"{{ inventory_hostname }}\",\n    set_hostname_default_ip: \"{{ ansible_default_ipv4.address|default(ansible_all_ipv4_addresses[0]) }}\",\n    set_hostname_set_hosts_file: false, # boolean to define if you whish to replace /etc/hosts with your template. Default is false\n    #  If you set your set_hostname_set_hosts_file to 'true', add your desired entries for /etc/hosts file here in this dictionary below.\n    # The entry will be added to /etc/hosts in format below:\n    # \u003cipaddress\u003e \u003chostname/fqdn\u003e\n    set_hostname_hosts_list: {\n      entry0: {\n        ip_address: \"{{ default_ip }}\",\n        host_name: \"{{ default_hostname }}\"\n      },\n      entry1: {\n        ip_address: \"172.23.132.17\",\n        host_name: \"www.myhost.tld\"\n      }\n    },\n    tags: [\"set-hostname\"]\n    }\n```\n\n## Run the playbook\n\nRun without setting /etc/hosts file:\n\n```shell\nansible-playbook -i inventory playbook.yaml --tags \"set-hostname\"\n```\n\nIf you need to copy your /etc/hosts template, you can enable it on runtime by defining an extra variable for setting `set_hostname_set_hosts_file` to `true`:\n\n```shell\nansible-playbook -i inventory playbook.yaml --tags \"set-hostname\" -e '{\"set_hostname_set_hosts_file\": true}'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancomile%2Fansible-role-set-hostname","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancomile%2Fansible-role-set-hostname","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancomile%2Fansible-role-set-hostname/lists"}