Commit c036a50f authored by Rafael Monnerat's avatar Rafael Monnerat

Initial release of wendelin-standalone setup

Contributed by Kristopher Ruzic (kristopher.ruzic@nexedi.com)
parent 35824342
......@@ -37,6 +37,7 @@
- { role: "install-script", playbook_yml: "re6stnet.yml", script_path: "install/re6st"}
- { role: "install-script", playbook_yml: "vifib.yml", script_path: "install/vifib"}
- { role: "install-script", playbook_yml: "erp5-standalone.yml", script_path: "install/erp5-standalone"}
- { role: "install-script", playbook_yml: "wendelin-standalone.yml", script_path: "install/wendelin-standalone"}
- { role: "install-script", playbook_yml: "slapos-test-node.yml", script_path: "install/slapos-test-node"}
- { role: "install-script", playbook_yml: "gnet-re6stnet.yml", script_path: "install/gnet/re6st"}
- { role: "install-script", playbook_yml: "gnet-server.yml", script_path: "install/gnet/slapos"}
......
......@@ -9,9 +9,6 @@
- name: create partition script
copy: src=request-erp5-cluster dest=/tmp/playbook-request-erp5-cluster mode=700
- name: create erp5-show
copy: src=erp5-show dest=/usr/local/bin/erp5-show mode=755
- name: Request ERP5 Cluster
shell: cat /tmp/playbook-request-erp5-cluster | slapos console
......
......@@ -19,5 +19,8 @@
wait_for: host=127.0.0.1 port=8080 delay=10
- name: Run slapos format for initial bootstrap
service: "slapos node format --now --alter_user=True"
shell: "slapos node format --now --alter_user=True"
when: slapos_cfg.stat.exists == False
- name: Set ownership for /opt/slapgrid
shell: "chown slapsoft:slapsoft /opt/slapgrid"
......@@ -7,18 +7,25 @@ import glob
import time
import getopt
import sqlite3
from urllib2 import urlopen
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():
# get all of the installed software types by checking the SR urls
# return a list, and run routine on all of them
def discover_software():
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor()
qry = cur.execute("SELECT DISTINCT software_release FROM partition11")
return [row[0] for row in qry]
def get_connection_information(software_release):
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'")
qry = cur.execute("SELECT connection_xml FROM partition11 WHERE connection_xml IS NOT NULL AND software_release=?", (software_release,) )
for row in qry:
xml = str(row[0])
break
......@@ -27,21 +34,25 @@ def get_connection_information():
try:
el = instance.getElementsByTagName('parameter')[0]
value = el.childNodes[0].nodeValue
except:
return "error"
if not value.startswith("{"):
value = "\"" + value + "\""
json_text = json.loads(value)
if 'family-admin' in json_text:
return (json_text['family-admin'], json_text['inituser-password'])
except Exception, e:
print e
print "empty"
elif 'insecure' in json_text:
return (json_text, None)
else:
return (None, None)
def check_tables():
conn = sqlite3.connect("/opt/slapos/slapproxy.db")
cur = conn.cursor()
qry = cur.execut("SELECT CASE WHEN tbl_name = 'partition11' THEN 1 ELSE 0 END FROM sqlite_master WHERE tbl_name = 'partition11' AND type = 'table'")
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:
if qry is None:
print "tables aren't ready yet, your build may have failed, check logs in /opt/slapos/log/"
sys.exit(0)
......@@ -54,7 +65,7 @@ def get_build_status():
if "Finished software releases" not in lines[-1]:
return False
if "ERROR" in lines[-3]:
return "err"
return "error"
return True
# Check if the last two lines show the software finished building.
......@@ -62,19 +73,29 @@ def get_build_status():
# Otherwise it passed and we can move on.
# We want to open today's log, as it is most up to date
def status():
def status(software_release):
build = get_build_status()
if build:
zope_ip, pw = get_connection_information()
zope_ip, pw = get_connection_information(software_release)
print ("Build successful, connect to:\n"
" " + zope_ip + " with\n"
" " + zope_ip)
if pw is not None:
print (" with\n"
" username: zope password: " + pw)
elif not build:
print "Your software is still building, be patient it can take awhile"
elif build == "err":
elif build == "error":
print "An error occurred while building, check /opt/slapos/log/slapos-node-software-" + \
fmt_date() + ".log for details"
# check if the services are actually running (run slapos node and parse output)
if pw is None:
zope_ip = "https://" + zope_ip[zope_ip.index("@")+1:]
r1 = urlopen(zope_ip)
if r1.getcode() != 200:
print "At least one of your services isn't running! Check with slapos node"
print "restart a service with slapos node restart slappart:service"
def info():
if get_build_status():
print get_connection_information()
......@@ -99,6 +120,9 @@ def main(argv):
except getopt.error, msg:
usage()
sys.exit(2)
if len(opts) == 0:
usage()
sys.exit(2)
# process arguments
for opt, arg in opts:
if opt in ("-h", "--help"):
......@@ -106,10 +130,12 @@ def main(argv):
sys.exit()
elif opt in ("-s", "--status"):
check_tables()
status()
for sr in discover_software():
status(sr)
elif opt in ("-i", "--info"):
check_tables()
info()
for sr in discover_software():
info(sr)
elif opt in ("-d", "--dump"):
dump()
......
---
- name: create erp5-show
copy: src=erp5-show dest=/usr/local/bin/erp5-show mode=755
import json
# copied from the request-erp5-cluster script, only changed the url to point to wendelin
software_url = 'https://lab.nexedi.cn/nexedi/slapos/raw/master/software/wendelin/software.cfg'
# Choose a SlapOS Node
# If you are deploying SlapOS Master with Webrunner, then computer_id is 'slaprunner'
computer_id = 'local_computer'
parameter_dict = {
"timezone": "UTC",
"site-id": "erp5",
"bt5": "erp5_full_text_myisam_catalog erp5_configurator_standard",
"zope-partition-dict": {
"admin": {
"family": "admin",
"thread-amount": 4,
"port-base": 2220,
"instance-count": 1
},
"activities-node": {
"family": "activities",
"thread-amount": 4,
"instance-count": 1,
"timerserver-interval": 1,
"port-base": 2230
},
"distribution-node": {
"family": "distribution",
"thread-amount": 1,
"instance-count": 1,
"port-base": 2210,
"timerserver-interval": 1
}
}
}
# Choose a title
title = "instance-of-wendelin"
request(software_url,
title,
filter_kw={'computer_guid': computer_id},
software_type='default',
partition_parameter_kw={
'_': json.dumps(parameter_dict, sort_keys=True, indent=2),
}
)
#!/bin/bash
# Reruns the ansible playbook, does nothing else
PLAYBOOK_ROOT=/opt/slapos.playbook/
PLAYBOOK_FILE=wendelin-standalone.yml
cd $PLAYBOOK_ROOT # cd into the playbook directory
ansible-playbook $PLAYBOOK_FILE -i hosts --connection=local
---
- name: Add ipv6 to lo interface
shell: ip -6 addr add 2001::1/64 dev lo
ignore_errors: True
- name: Supply wendelin software release
shell: slapos supply https://lab.nexedi.cn/nexedi/slapos/raw/master/software/wendelin/software.cfg local_computer
- name: create partition script
copy: src=request-wendelin dest=/tmp/playbook-request-wendelin mode=700
- name: Request Wendelin instance
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
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
roles:
- wendelin-standalone
- standalone-shared
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