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
df741bae
Commit
df741bae
authored
Jun 08, 2015
by
Kristopher Ruzic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add stuff from erp5-standalone, completes install and reruns ansible on boot
parent
79547388
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
154 additions
and
0 deletions
+154
-0
playbook/roles/wendelin-standalone/files/wendelin-show
playbook/roles/wendelin-standalone/files/wendelin-show
+117
-0
playbook/roles/wendelin-standalone/files/wendelin-startup
playbook/roles/wendelin-standalone/files/wendelin-startup
+10
-0
playbook/roles/wendelin-standalone/tasks/main.yml
playbook/roles/wendelin-standalone/tasks/main.yml
+27
-0
No files found.
playbook/roles/wendelin-standalone/files/wendelin-show
0 → 100644
View file @
df741bae
#!/usr/bin/python2.7
import
os
import
sys
import
subprocess
import
glob
import
time
import
getopt
import
sqlite3
from
xml.dom
import
minidom
#from slapos.proxy.db_version import DB_VERSION
import
json
def
fmt_date
():
return
time
.
strftime
(
"%Y%m%d"
)
def
get_connection_information
():
conn
=
sqlite3
.
connect
(
"/opt/slapos/slapproxy.db"
)
cur
=
conn
.
cursor
()
qry
=
cur
.
execute
(
"SELECT connection_xml FROM partition11 WHERE connection_xml IS NOT NULL AND software_type='create-erp5-site'"
)
for
row
in
qry
:
xml
=
str
(
row
[
0
])
break
instance
=
minidom
.
parseString
(
xml
)
try
:
el
=
instance
.
getElementsByTagName
(
'parameter'
)[
0
]
value
=
el
.
childNodes
[
0
].
nodeValue
json_text
=
json
.
loads
(
value
)
return
(
json_text
[
'family-admin'
],
json_text
[
'inituser-password'
])
except
Exception
,
e
:
print
e
print
"empty"
return
(
None
,
None
)
def
check_tables
():
conn
=
sqlite3
.
connect
(
"/opt/slapos/slapproxy.db"
)
cur
=
conn
.
cursor
()
qry
=
cur
.
execute
(
"SELECT CASE WHEN tbl_name = 'partition11' THEN 1 ELSE 0 END FROM sqlite_master WHERE tbl_name = 'partition11' AND type = 'table'"
)
if
qry
:
pass
else
:
print
"tables aren't ready yet, your build may have failed, check logs in /opt/slapos/log/"
sys
.
exit
(
0
)
def
get_build_status
():
try
:
f
=
open
(
"/opt/slapos/log/slapos-node-software-"
+
fmt_date
()
+
".log"
)
except
:
f
=
open
(
"/opt/slapos/log/slapos-node-software.log"
)
lines
=
f
.
readlines
()
if
"Finished software releases"
not
in
lines
[
-
1
]:
return
False
if
"ERROR"
in
lines
[
-
3
]:
return
"err"
return
True
# Check if the last two lines show the software finished building.
# If an error came just before this, we'll report failure.
# Otherwise it passed and we can move on.
# We want to open today's log, as it is most up to date
def
status
():
build
=
get_build_status
()
if
build
:
zope_ip
,
pw
=
get_connection_information
()
print
(
"Build successful, connect to:
\
n
"
" "
+
zope_ip
+
" with
\
n
"
" username: zope password: "
+
pw
)
elif
not
build
:
print
"Your software is still building, be patient it can take awhile"
elif
build
==
"err"
:
print
"An error occurred while building, check /opt/slapos/log/slapos-node-software-"
+
\
fmt_date
()
+
".log for details"
def
info
():
if
get_build_status
():
print
get_connection_information
()
else
:
print
"Information unavailable at this time, run "
+
sys
.
argv
[
0
]
+
" -s for details"
def
usage
():
print
(
"Get the status and information of your ERP5 build
\
n
"
"Usage:"
)
print
(
" --help (-h): Print this message and exit
\
n
"
" --status (-s): Print the status of the build
\
n
"
" --info (-i): Print the partition tables
\
n
"
" --dump (-d): Dump the entire database (alias for slapos proxy show)
\
n
"
)
def
dump
():
subprocess
.
call
([
"slapos"
,
"proxy"
,
"show"
,
"-u"
,
"/opt/slapos/slapproxy.db"
])
def
main
(
argv
):
# parse command line options
try
:
opts
,
args
=
getopt
.
getopt
(
argv
,
"sihd"
,
[
"status"
,
"info"
,
"help"
,
"dump"
])
except
getopt
.
error
,
msg
:
usage
()
sys
.
exit
(
2
)
# process arguments
for
opt
,
arg
in
opts
:
if
opt
in
(
"-h"
,
"--help"
):
usage
()
sys
.
exit
()
elif
opt
in
(
"-s"
,
"--status"
):
check_tables
()
status
()
elif
opt
in
(
"-i"
,
"--info"
):
check_tables
()
info
()
elif
opt
in
(
"-d"
,
"--dump"
):
dump
()
if
__name__
==
"__main__"
:
main
(
sys
.
argv
[
1
:])
playbook/roles/wendelin-standalone/files/wendelin-startup
0 → 100644
View file @
df741bae
#!/bin/bash
# Reruns the ansible playbook, does nothing else
PLAYBOOK_ROOT
=
/opt/slapos.playbook/playbook/
PLAYBOOK_FILE
=
wendelin-standalone.yml
cd
$PLAYBOOK_ROOT
# cd into the playbook directory
echo
"Starting Ansible playbook:"
ansible-playbook
$PLAYBOOK_FILE
-i
hosts
--connection
=
local
playbook/roles/wendelin-standalone/tasks/main.yml
View file @
df741bae
...
...
@@ -11,3 +11,30 @@
-
name
:
Request Wendelin instance
shell
:
cat /tmp/playbook-request-wendelin | slapos console
-
name
:
create wendelin-show
copy
:
src=wendelin-show dest=/usr/local/bin/wendelin-show mode=755
-
name
:
Request ERP5 Cluster
shell
:
cat /tmp/playbook-request-wendelin | slapos console
-
name
:
Add startup script
copy
:
src=wendelin-startup dest=/usr/local/bin/wendelin-startup mode=755
-
name
:
Add to rc.local
lineinfile
:
dest=/etc/rc.local insertbefore=BOF
line='bash /usr/local/bin/wendelin-startup &'
state=present
-
name
:
Get slapos.playbook directory name
shell
:
cd /tmp/tmpplaybookwendelin-standalone.*/slapos.playbook.git/playbook/; echo $(pwd)/
register
:
tmp_dir
-
name
:
Check if /opt/slapos.playbook already exists
stat
:
path=/opt/slapos.playbook/
register
:
playbook_state
-
name
:
Copy slapos.playbook
copy
:
src={{ tmp_dir.stdout }} dest=/opt/slapos.playbook/
when
:
playbook_state.stat.exists == False
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