1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/bin/sh
#
# Copyright (C) 2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# This is a "morph deploy" configuration extension to fully configure
# a Mason instance at deployment time. It uses the following variables
# from the environment:
#
# * ARTIFACT_CACHE_SERVER
# * MASON_CLUSTER_MORPHOLOGY
# * MASON_DEFINITIONS_REF
# * MASON_DISTBUILD_ARCH
# * MASON_TEST_HOST
# * TROVE_HOST
# * TROVE_ID
# * CONTROLLERHOST
set -e
ROOT="$1"
##########################################################################
# Copy Mason files into root filesystem
##########################################################################
mkdir -p "$ROOT"/usr/lib/mason
cp mason/mason.sh "$ROOT"/usr/lib/mason/mason.sh
cp mason/mason-report.sh "$ROOT"/usr/lib/mason/mason-report.sh
cp mason/mason.timer "$ROOT"/etc/systemd/system/mason.timer
cp mason/mason.service "$ROOT"/etc/systemd/system/mason.service
##########################################################################
# Set up httpd web server
##########################################################################
cp mason/httpd.service "$ROOT"/etc/systemd/system/httpd.service
mkdir -p "$ROOT"/srv/mason
cat >>"$ROOT"/etc/httpd.conf <<EOF
.log:text/plain
EOF
mkdir -p "$ROOT"/var/mason
##########################################################################
# Copy files needed for Ansible configuration
##########################################################################
mkdir -p "$ROOT/usr/share/mason-setup"
mkdir -p "$ROOT/usr/lib/mason-setup"
cp mason/share/* "$ROOT/usr/share/mason-setup"
cp -r mason/ansible "$ROOT/usr/lib/mason-setup/"
cp mason/mason-setup.service "$ROOT"/etc/systemd/system/mason-setup.service
ln -s ../mason-setup.service "$ROOT"/etc/systemd/system/multi-user.target.wants/mason-setup.service
##########################################################################
# Check variables
##########################################################################
if [ -n "$MASON_GENERIC" ]; then
echo Not configuring Mason, it will be generic
exit 0
fi
if [ "$ARTIFACT_CACHE_SERVER" = "" \
-o "$MASON_CLUSTER_MORPHOLOGY" = "" \
-o "$MASON_DEFINITIONS_REF" = "" \
-o "$MASON_DISTBUILD_ARCH" = "" \
-o "$MASON_TEST_HOST" = "" ]; then
echo Not configuring as Mason, some options not defined
exit 1
fi
##########################################################################
# Generate config variable shell snippet
##########################################################################
MASON_DATA="$ROOT/etc/mason"
mkdir -p "$MASON_DATA"
python <<'EOF' >"$MASON_DATA/mason.conf"
import os, sys, yaml
trove_configuration={
'ARTIFACT_CACHE_SERVIER': os.environ['ARTIFACT_CACHE_SERVER'],
'MASON_CLUSTER_MORPHOLOGY': os.environ['MASON_CLUSTER_MORPHOLOGY'],
'MASON_DEFINITIONS_REF': os.environ['MASON_DEFINITIONS_REF'],
'MASON_DISTBUILD_ARCH': os.environ['MASON_DISTBUILD_ARCH'],
'MASON_TEST_HOST': os.environ['MASON_TEST_HOST'],
'TROVE_ADMIN_NAME': os.environ['TROVE_ADMIN_NAME'],
'TROVE_ID': os.environ['TROVE_ID'],
'TROVE_HOST': os.environ['TROVE_HOST'],
'CONTROLLERHOST': os.environ['CONTROLLERHOST'],
}
yaml.dump(trove_configuration, sys.stdout, default_flow_style=False)
EOF
##########################################################################
# Enable services
##########################################################################
ln -s ../mason.timer "$ROOT"/etc/systemd/system/multi-user.target.wants/mason.timer
ln -s ../mason.service "$ROOT"/etc/systemd/system/multi-user.target.wants/mason.service
ln -s ../httpd.service "$ROOT"/etc/systemd/system/multi-user.target.wants/httpd.service
|