Commit fef2c122 authored by Alain Takoudjou's avatar Alain Takoudjou

Merge branch 'logging' into 'master'

playbook: fix configuration of /etc/hosts file

Changes for /etc/hosts configuration in vm-bootstrap

See merge request !11
parents 274b8a7c 8ba4cd77
...@@ -4,17 +4,20 @@ import sys ...@@ -4,17 +4,20 @@ import sys
print sys.argv[1:] print sys.argv[1:]
host_content = open('/etc/hosts', 'r').read() host_content = open('/etc/hosts', 'r').readlines()
hpath = sys.argv[1] hpath = sys.argv[1]
domain = sys.argv[2] domain = sys.argv[2]
lines_entry = ""
for content in open(hpath, 'r').readlines():
if content:
items = content.strip().split(' ')
entry = "%s %s.%s %s" % (items[1], items[0], domain, items[0])
print entry
if not entry in host_content:
lines_entry += entry + "\n"
if lines_entry:
with open('/etc/hosts', 'a') as hosts:
hosts.write(lines_entry)
with open('/etc/hosts', 'a') as hosts:
for content in open(hpath, 'r').readlines():
if content:
items = content.strip().split(' ')
entry = "%s %s.%s %s" % (items[1], items[0], domain, items[0])
print entry
if not entry in host_content:
hosts.write(entry)
hosts.write('\n')
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
when: hostname_file.stat.exists == True when: hostname_file.stat.exists == True
- name: managing hosts file - name: managing hosts file
lineinfile: dest=/etc/hosts regexp="^127.0.1.1" line="" lineinfile: dest=/etc/hosts regexp="^127.0.1.1" line="" state=absent
when: hostname_file.stat.exists == True when: hostname_file.stat.exists == True
- name: setting hosts special line - name: setting hosts special line
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment