{"id":19871905,"url":"https://github.com/saltstack-formulas/hostsfile-formula","last_synced_at":"2025-04-05T09:08:45.316Z","repository":{"id":13185852,"uuid":"15869327","full_name":"saltstack-formulas/hostsfile-formula","owner":"saltstack-formulas","description":"Use minion IDs to keep /etc/hosts and hostnames consistent for clusters without DNS","archived":false,"fork":false,"pushed_at":"2025-01-06T23:08:24.000Z","size":212,"stargazers_count":33,"open_issues_count":9,"forks_count":88,"subscribers_count":38,"default_branch":"master","last_synced_at":"2025-03-29T08:08:42.158Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saltstack-formulas.png","metadata":{"files":{"readme":"docs/README.rst","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-01-13T13:48:52.000Z","updated_at":"2024-05-04T14:46:13.000Z","dependencies_parsed_at":"2024-12-23T13:14:24.291Z","dependency_job_id":"ef7bdea7-ee81-42bc-ab67-8cdda0208ed5","html_url":"https://github.com/saltstack-formulas/hostsfile-formula","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fhostsfile-formula","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fhostsfile-formula/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fhostsfile-formula/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saltstack-formulas%2Fhostsfile-formula/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saltstack-formulas","download_url":"https://codeload.github.com/saltstack-formulas/hostsfile-formula/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312081,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-12T16:13:56.712Z","updated_at":"2025-04-05T09:08:45.263Z","avatar_url":"https://github.com/saltstack-formulas.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":".. _readme:\n\nhostsfile\n=========\n\n|img_travis| |img_sr|\n\n.. |img_travis| image:: https://travis-ci.com/saltstack-formulas/hostsfile-formula.svg?branch=master\n   :alt: Travis CI Build Status\n   :scale: 100%\n   :target: https://travis-ci.com/saltstack-formulas/hostsfile-formula\n.. |img_sr| image:: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n   :alt: Semantic Release\n   :scale: 100%\n   :target: https://github.com/semantic-release/semantic-release\n\nFormula to set up name resolution for all members of a salt cluster in /etc/hosts.\n\n.. contents:: **Table of Contents**\n\nGeneral notes\n-------------\n\nSee the full `SaltStack Formulas installation and usage instructions\n\u003chttps://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html\u003e`_.\n\nIf you are interested in writing or contributing to formulas, please pay attention to the `Writing Formula Section\n\u003chttps://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#writing-formulas\u003e`_.\n\nIf you want to use this formula, please pay attention to the ``FORMULA`` file and/or ``git tag``,\nwhich contains the currently released version. This formula is versioned according to `Semantic Versioning \u003chttp://semver.org/\u003e`_.\n\nSee `Formula Versioning Section \u003chttps://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning\u003e`_ for more details.\n\nIf you need (non-default) configuration, please pay attention to the ``pillar.example`` file and/or `Special notes`_ section.\n\nContributing to this repo\n-------------------------\n\n**Commit message formatting is significant!!**\n\nPlease see `How to contribute \u003chttps://github.com/saltstack-formulas/.github/blob/master/CONTRIBUTING.rst\u003e`_ for more details.\n\nSpecial notes\n-------------\n\nTo enable the Salt Mine the `mine_functions` option `needs to be applied to a Minion \u003chttps://docs.saltproject.io/en/latest/topics/mine/#mine-functions\u003e`_\n\nAvailable states\n----------------\n\n.. contents::\n   :local:\n\n``hostsfile``\n^^^^^^^^^^^^^\n\nUses the `Salt Mine \u003chttp://docs.saltstack.com/topics/mine/\u003e`_ function ``network.ip_addrs`` to add minion ids and their regarding ips to the local hosts file.\n\nAt a minimum, you must enable the network.ip_addrs function in pillar or in ``/etc/salt/minion``::\n\n    mine_functions:\n      network.ip_addrs: []\n\nThe formula works best if the minion id is the fqdn and (if the machines have more than one interface) the desired interface to use for this is configured with the mine function::\n\n    mine_functions:\n      network.interfaces: []\n      network.ip_addrs:\n        - eth1\n    mine_interval: 2\n\nIf you are already using network.ip_addrs for something else (perhaps another state that wants information on a different interface than hostsfile should use), you can specify a mine alias in pillar to query instead::\n\n    hostsfile:\n      alias: hostsfile_interface\n\n    mine_functions:\n      hostsfile_interface:\n        mine_function: network.ip_addrs\n        iface: eth0\n\nBy default all minions in mine are added to the hosts file, but that can be overridden too::\n\n    hostsfile:\n      minions: '*-thisdatacenter-something'\n\nBy default specified minions in mine are added to the hosts file::\n\n    hostsfile:\n      minions: 'zk[1-5] and kafka[1-5]'\n      type: 'compound'\n\nAnd you can add explicit entries for non-mine hosts as well::\n\n    hostsfile:\n      hosts:\n        server1: 10.10.10.10\n        server2: 10.10.10.11\n\nTo reduce the hostnames for an IP to those given in pillar\nyou can place them in ``pillar[hostsfile:only]``::\n\n    hostsfile:\n      only:\n        10.10.10.10:\n            - server1.my.domain\n            - server1\n        10.10.10.11:\n            - server2.my.domain\n            - server2\n\nTo remove an IP from the hostsfile specify an empty list\nof hostnames::\n\n    hostsfile:\n        only:\n            127.0.1.1: []\n\n``hostsfile.hostname``\n^^^^^^^^^^^^^^^^^^^^^^\n\nAlso set and persist the hostname (again - using the minion id). This has so far been most useful on EC2 instances.\n\nWorks on RedHat/CentOS 5.X or RedHat/CentOS 6.X and Amazon OS - should also work on Ubuntu/Debian.\n\nTesting\n-------\n\nLinux testing is done with ``kitchen-salt``.\n\nRequirements\n^^^^^^^^^^^^\n\n* Ruby\n* Docker\n\n.. code-block:: bash\n\n   $ gem install bundler\n   $ bundle install\n   $ bin/kitchen test [platform]\n\nWhere ``[platform]`` is the platform name defined in ``kitchen.yml``,\ne.g. ``debian-9-2019-2-py3``.\n\n``bin/kitchen converge``\n^^^^^^^^^^^^^^^^^^^^^^^^\n\nCreates the docker instance and runs the ``TEMPLATE`` main state, ready for testing.\n\n``bin/kitchen verify``\n^^^^^^^^^^^^^^^^^^^^^^\n\nRuns the ``inspec`` tests on the actual instance.\n\n``bin/kitchen destroy``\n^^^^^^^^^^^^^^^^^^^^^^^\n\nRemoves the docker instance.\n\n``bin/kitchen test``\n^^^^^^^^^^^^^^^^^^^^\n\nRuns all of the stages above in one go: i.e. ``destroy`` + ``converge`` + ``verify`` + ``destroy``.\n\n``bin/kitchen login``\n^^^^^^^^^^^^^^^^^^^^^\n\nGives you SSH access to the instance for manual testing.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack-formulas%2Fhostsfile-formula","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaltstack-formulas%2Fhostsfile-formula","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaltstack-formulas%2Fhostsfile-formula/lists"}