Commit 52cb3356 authored by Rafael Monnerat's avatar Rafael Monnerat

Merge branch 'master' into 'master'

Initial Release of wendelin-standalone

See merge request !3
parents 670d5f65 c036a50f
......@@ -15,3 +15,4 @@ slapprepare/slapprepare.egg-info
.*.swp
build
dist
playbook/install
......@@ -22,7 +22,7 @@
default: "notoken"
roles:
- re6stnet
- slapos
- { role: re6stnet, package_state: present }
- { role: slapos, package_state: present }
- { role: package, package_name: ntp, package_state: present }
......@@ -22,7 +22,8 @@
default: "notoken"
roles:
- re6stnet
- slapos
- { role: re6stnet, package_state: present }
- { role: slapos, package_state: present }
- { role: package, package_name: ntp, package_state: present }
......@@ -23,11 +23,21 @@
- name: generate scripts
template: src=roles/install-script/templates/dev.j2 dest={{ base_path }}/install/devbook mode=0666
- name: generate index.html
copy: src=roles/install-script/files/index.html dest={{ base_path }}/install/index.html mode=0666
- name: generate index.html
copy: src=roles/install-script/files/index.html dest={{ base_path }}/install/gnet/index.html mode=0666
- name: generate index.html
copy: src=roles/install-script/files/index.html dest={{ base_path }}/install/imt/index.html mode=0666
roles:
- { role: "install-script", playbook_yml: "slapos.yml", script_path: "install/slapos" }
- { 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
......
<html>
<head>
<title></tile>
</head>
<body>
</body>
</html>
......@@ -13,11 +13,11 @@
when: ansible_distribution == "Debian"
- name: Install re6stnet package
apt: name=babeld=1.5.1-nxd2 state=present update_cache=yes
apt: name=babeld=1.5.1-nxd2 state={{ package_state }} update_cache=yes
when: ansible_distribution == "Debian"
- name: Install re6stnet package
apt: name=re6stnet state=present update_cache=yes
apt: name=re6stnet state={{ package_state }} update_cache=yes
when: ansible_distribution == "Debian"
- name: Check if configuration exists already
......
......@@ -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"
- name: Install packages using apt
apt: name=slapos-node state=present update_cache=yes cache_valid_time=3600
apt: name=slapos-node state={{ package_state }} update_cache=yes cache_valid_time=3600
when: ansible_os_family == "Debian"
- name: Install re6stnet on CentOS
yum: name=slapos.node state=present update_cache=yes
yum: name=slapos.node state={{ package_state }} update_cache=yes
when: ansible_os_family == "RedHat"
- name: Check if configuration exists already
......
......@@ -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
#!/bin/bash
if [ ! -f /etc/opt/slapcache.cfg ]; then
slapcache-conf
fi
DFILE="/opt/upgrader/"
TFILE="archive.tar.gz"
mkdir -p $DFILE
cd $DFILE
slapcache-download --destination=$TFILE
tar -xzvf $TFILE
md5sum $TFILE > "/opt/upgrader/next-upgrader-md5sum"
---
- stat: path=/opt/upgrader/last-upgrade
register: last_upgrade
- shell: echo 1 > /opt/upgrader/last-upgrade
when: last_upgrade.stat.exists == False
- file: path=/opt/upgrader/ state=directory mode=0755
- shell: rm -rf /opt/upgrader/playbook/
- file: path=/opt/upgrader/playbook/ state=directory mode=0755
- name: Periodically download the latest playbook
shell: slapcache-download --destination=/opt/upgrader/archive.tar.gz
- name: Uncompress
unarchive: src=/opt/upgrader/archive.tar.gz dest=/opt/upgrader/playbook/
- name: Save new archive MD5
stat: path=/opt/upgrader/archive.tar.gz
register:
archive
- name: Update playbook md5
shell: echo {{ archive.stat.md5 }} > /opt/upgrader/next-upgrade-signature
- name: Stat Current Upgrade Signature
file: path=/opt/upgrader/current-upgrade-signature state=touch mode="0666"
- name: Get /opt/upgrader/next-upgrade-signature content
shell: cat /opt/upgrader/next-upgrade-signature
register:
next_upgrade_signature
- name: Get /opt/upgrader/current-upgrade-signature content
shell: cat /opt/upgrader/current-upgrade-signature
register:
current_upgrade_signature
- name: Do upgrade
shell: ansible-playbook {{ upgrader_playbook }} -i hosts >> /opt/upgrader/latest_upgrade.log
when: (upgrade_after > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature'))
args:
chdir: /opt/upgrader/playbook/
- name: Upgrade Current Upgrade Signature
shell: cat /opt/upgrader/next-upgrade-signature > /opt/upgrader/current-upgrade-signature
when: (upgrade_after > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature'))
- shell: echo {{ ansible_date_time.epoch }} > /opt/upgrader/last-upgrade
when: (upgrade_after > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature'))
- name: Set Cron
cron: name="Launch Upgrader" minute="0" hour="*/3" job='ansible-playbook upgrader-run.yml --with-vars "upgrader-playbook={{ upgrader_playbook }}" -i hosts >> /opt/upgrader/latest_upgrade.log'
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
---
upgrade_after: 1434474611
......@@ -21,6 +21,6 @@
default: "notoken"
roles:
- slapos
- { role: slapos, package_state: present }
- { role: package, package_name: ntp, package_state: present }
- rafael_ssh_key
......@@ -17,7 +17,7 @@
default: "notoken"
roles:
- slapos
- { role: slapos, package_state: present }
- { role: package, package_name: ntp, package_state: present }
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars_files:
- settings/upgrader.yml
roles:
- upgrader
......@@ -17,8 +17,8 @@
default: "notoken"
roles:
- re6stnet-legacy
- slapos
- { role: re6stnet-legacy, package_state: present }
- { role: slapos, package_state: present }
- { role: package, package_name: ntp, package_state: present }
- vifib-server-shuttle
- name: a play that runs entirely on the ansible host
hosts: 127.0.0.1
connection: local
vars:
- upgrader-playbook: vifib-upgrader.yml
- computer_name: noname
- slapostoken: notoken
vars_files:
- settings/vifib.yml
roles:
- { role: re6stnet-legacy, package_state: latest }
- { role: slapos, package_state: latest }
- { role: package, package_name: ntp, package_state: latest }
- { role: package, package_name: ntp, package_state: latest }
- vifib-server
- upgrader
......@@ -2,8 +2,12 @@
hosts: 127.0.0.1
connection: local
vars:
- upgrader-playbook: vifib-upgrader.yml
vars_files:
- settings/vifib.yml
- settings/upgrader.yml
vars_prompt:
- name: "computer_name"
......@@ -17,8 +21,8 @@
default: "notoken"
roles:
- re6stnet-legacy
- slapos
- { role: re6stnet-legacy, package_state: present }
- { role: slapos, package_state: present }
- { role: package, package_name: ntp, package_state: present }
- vifib-server
- upgrader
- 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