{"id":13,"date":"2026-08-02T09:45:34","date_gmt":"2026-08-02T09:45:34","guid":{"rendered":"https:\/\/www.tomasz-avila.pl\/?p=13"},"modified":"2026-08-02T10:30:25","modified_gmt":"2026-08-02T10:30:25","slug":"playing-with-etc-hosts-by-ansible","status":"publish","type":"post","link":"https:\/\/www.tomasz-avila.pl\/?p=13","title":{"rendered":"Playing with \/etc\/hosts by Ansible"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">dnsmasq is a better solution for this purpose, but the goal is to play with Ansible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s the continuation of the post: <a href=\"https:\/\/www.tomasz-avila.pl\/?p=11\" data-type=\"post\" data-id=\"11\">My own VPN on a VPS<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The main goal is to play with Ansible. The second goal is to be able to connect to the hosts by their names rather then by their IPs. For this purpose, I will update \/etc\/hosts file on each host automatically by Ansible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Preparing the host files on the Ansible server<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In first place, I edit the hosts file on Ansible:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@vps-dc91297d ~]# tail -n3 \/etc\/hosts \n10.8.0.1 vps\n10.8.0.2 komputer01\n10.8.0.3 pi<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, I will be able to use the hosts name in the Ansible configuration file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Ansible installation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>dnsmasq is a better solution for this purpose, but the goal is to play with Ansible. It&#8217;s the continuation of the post: My own VPN on a VPS The main goal is to play with Ansible. The second goal is to be able to connect to the hosts by their names rather then by their [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=\/wp\/v2\/posts\/13","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":4,"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":26,"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/26"}],"wp:attachment":[{"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tomasz-avila.pl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}