Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Łukasz Nowak
slapos.package
Commits
8ba4cd77
Commit
8ba4cd77
authored
Aug 13, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playbook: fix configuration of /etc/hosts file
parent
c7fac123
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
playbook/roles/vm-bootstrap/files/format_hosts
playbook/roles/vm-bootstrap/files/format_hosts
+14
-11
playbook/roles/vm-bootstrap/tasks/hostname.yml
playbook/roles/vm-bootstrap/tasks/hostname.yml
+1
-1
No files found.
playbook/roles/vm-bootstrap/files/format_hosts
View file @
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'
).
read
lines
()
hpath
=
sys
.
argv
[
1
]
hpath
=
sys
.
argv
[
1
]
domain
=
sys
.
argv
[
2
]
domain
=
sys
.
argv
[
2
]
lines_entry
=
""
with
open
(
'/etc/hosts'
,
'a'
)
as
hosts
:
for
content
in
open
(
hpath
,
'r'
).
readlines
():
for
content
in
open
(
hpath
,
'r'
).
readlines
():
if
content
:
if
content
:
items
=
content
.
strip
().
split
(
' '
)
items
=
content
.
strip
().
split
(
' '
)
entry
=
"%s %s.%s %s"
%
(
items
[
1
],
items
[
0
],
domain
,
items
[
0
])
entry
=
"%s %s.%s %s"
%
(
items
[
1
],
items
[
0
],
domain
,
items
[
0
])
print
entry
print
entry
if
not
entry
in
host_content
:
if
not
entry
in
host_content
:
hosts
.
write
(
entry
)
lines_entry
+=
entry
+
"
\
n
"
hosts
.
write
(
'
\
n
'
)
if
lines_entry
:
with
open
(
'/etc/hosts'
,
'a'
)
as
hosts
:
hosts
.
write
(
lines_entry
)
playbook/roles/vm-bootstrap/tasks/hostname.yml
View file @
8ba4cd77
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment