Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.playbook
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
slapos.playbook
Commits
2f7ab90d
Commit
2f7ab90d
authored
May 21, 2015
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm-bootstrap: configure hosts file witn hostname of all vm in cluster
parent
8e2f0834
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
playbook/roles/vm-bootstrap/files/format_hosts
playbook/roles/vm-bootstrap/files/format_hosts
+20
-0
playbook/roles/vm-bootstrap/tasks/hostname.yml
playbook/roles/vm-bootstrap/tasks/hostname.yml
+20
-0
No files found.
playbook/roles/vm-bootstrap/files/format_hosts
0 → 100644
View file @
2f7ab90d
#!/usr/bin/python
import
sys
print
sys
.
argv
[
1
:]
host_content
=
open
(
'/etc/hosts'
,
'r'
).
read
()
hpath
=
sys
.
argv
[
1
]
domain
=
sys
.
argv
[
2
]
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
'
)
playbook/roles/vm-bootstrap/tasks/hostname.yml
View file @
2f7ab90d
...
...
@@ -8,6 +8,10 @@
get_url
:
url=http://10.0.2.100/ipv4 dest=/etc/opt/ipv4 mode=666
ignore_errors
:
True
-
name
:
Download cluster.hash
get_url
:
url=http://10.0.2.100/cluster.hash dest=/tmp/cluster.hash mode=666
ignore_errors
:
True
-
name
:
stat /etc/opt/hostname
stat
:
path=/etc/opt/hostname
register
:
hostname_file
...
...
@@ -16,6 +20,10 @@
stat
:
path=/etc/opt/ipv4
register
:
ipv4_file
-
name
:
stat /tmp/cluster.hash
stat
:
path=/tmp/cluster.hash
register
:
cluster_hash
-
name
:
replace /etc/hostname
copy
:
src=/etc/opt/hostname dest=/etc/hostname mode=666
when
:
hostname_file.stat.exists == True
...
...
@@ -32,6 +40,18 @@
lineinfile
:
dest=/etc/hosts line="{{ lookup('file', '/etc/opt/ipv4') }} {{ lookup('file', '/etc/opt/hostname') }}.tl.teralab-datascience.fr {{ lookup('file', '/etc/opt/hostname') }}"
when
:
hostname_file.stat.exists == True
-
name
:
setting cluster
get_url
:
url="{{ lookup('file', '/tmp/cluster.hash') }}/hosts" dest=/tmp/hosts mode=666 validate_certs=no
when
:
cluster_hash.stat.exists == True
-
name
:
stat /tmp/hosts
stat
:
path=/tmp/hosts
register
:
hostname_file
-
name
:
Format hosts
script
:
format_hosts /tmp/hosts tl.teralab-datascience.fr
when
:
cluster_hash.stat.exists == True
-
name
:
managing resolv.conf file
lineinfile
:
dest=/etc/resolv.conf line="search tl.teralab-datascience.fr"
...
...
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