mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 09:39:56 +00:00
Adjusts the /etc/hosts files to make all instances visible by the hostname in the subnet
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
---
|
||||
- hosts: nodes
|
||||
sudo: true
|
||||
vars_files:
|
||||
- vagrant.yml
|
||||
tasks:
|
||||
|
||||
- name: installing dependencies
|
||||
@@ -80,3 +82,29 @@
|
||||
line: "alias docker-compose='/opt/docker-compose/bin/docker-compose'"
|
||||
state: present
|
||||
regexp: '^alias docker-compose=.*$'
|
||||
|
||||
- name: building the /etc/hosts file with all nodes
|
||||
lineinfile:
|
||||
dest: /etc/hosts
|
||||
line: "{{ item.private_ip }} {{ item.hostname }}"
|
||||
regexp: "^{{ item.private_ip }} {{ item.hostname }}$"
|
||||
state: present
|
||||
with_items: instances
|
||||
|
||||
- name: fixing the hostname
|
||||
hostname:
|
||||
name: "{{ inventory_hostname }}"
|
||||
|
||||
- name: adjusting the /etc/hosts to the new hostname
|
||||
lineinfile:
|
||||
dest: /etc/hosts
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
with_items:
|
||||
- regexp: '^127\.0\.0\.1'
|
||||
line: "127.0.0.1 localhost {{ inventory_hostname }}"
|
||||
- regexp: '^127\.0\.1\.1'
|
||||
line: "127.0.1.1 {{ inventory_hostname }}"
|
||||
|
||||
Reference in New Issue
Block a user