-
Notifications
You must be signed in to change notification settings - Fork 2
/
nodepool_config.sh
149 lines (113 loc) · 3.75 KB
/
nodepool_config.sh
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
set -eux
THIS_FILE=$(readlink -f $0)
THIS_DIR=$(dirname $THIS_FILE)
. $THIS_DIR/functions.sh
NODEPOOL_XENSERVER_XVA_URL="http://downloads.vmd.citrix.com/OpenStack/xenapi-in-the-cloud-appliances/prod_ci"
NODEPOOL_XENSERVER_ISO_URL="http://05c1b21d02b2453e74a7-e2f09c34733a73af7a3cee3d72db6e03.r39.cf5.rackcdn.com/images/XenServer-6.2.0-install-cd.iso"
NODEPOOL_XENSERVER_ISO_URL="http://72138ad341c10f5edfcb-3d52c4cbb0f211abe3707d33bf0e2856.r94.cf5.rackcdn.com/creedence-debug.iso"
NODEPOOL_XENSERVER_ISO_URL="http://downloadns.citrix.com.edgesuite.net/10175/XenServer-6.5.0-xenserver.org-install-cd.iso"
######
# Clone project-config
sudo rm -rf /opt/nodepool/project-config
get_project_config
######
# Make sure scripts dir exists
test -d /opt/nodepool/project-config/nodepool/scripts
source $THIS_DIR/nodepool_rewrite_config.sh
######
# Copy ssh settings
sudo rm -rf $NODEPOOL_HOME_DIR/.ssh
sudo mkdir $NODEPOOL_HOME_DIR/.ssh
sudo cp $THIS_DIR/nodepool.priv $NODEPOOL_HOME_DIR/.ssh/id_rsa
sudo cp $THIS_DIR/jenkins.priv $NODEPOOL_HOME_DIR/.ssh/jenkins
######
# Configure logging
sudo tee /etc/nodepool/logging.conf << EOF
[loggers]
keys=root,nodepool,requests,image
[handlers]
keys=console,debug,normal,image
[formatters]
keys=simple
[logger_root]
level=WARNING
handlers=console
[logger_requests]
level=WARNING
handlers=debug,normal
qualname=requests
[logger_nodepool]
level=DEBUG
handlers=debug,normal
qualname=nodepool
[logger_image]
level=INFO
handlers=image
qualname=nodepool.image.build
propagate=0
[handler_console]
level=WARNING
class=StreamHandler
formatter=simple
args=(sys.stdout,)
[handler_debug]
level=DEBUG
class=logging.handlers.TimedRotatingFileHandler
formatter=simple
args=('/var/log/nodepool/debug.log', 'midnight', 1, 30,)
[handler_normal]
level=INFO
class=logging.handlers.TimedRotatingFileHandler
formatter=simple
args=('/var/log/nodepool/nodepool.log', 'midnight', 1, 30,)
[handler_image]
level=INFO
class=logging.handlers.TimedRotatingFileHandler
formatter=simple
args=('/var/log/nodepool/image.log', 'midnight', 1, 30,)
[formatter_simple]
format=%(asctime)s %(levelname)s %(name)s: %(message)s
datefmt=
EOF
######
# Add startup script
sudo tee /etc/init/nodepool.conf << NODEPOOLSTARTER
start on runlevel [2345]
stop on runlevel [016]
setuid $NODEPOOL_USER
chdir $NODEPOOL_HOME_DIR
script
export NODEPOOL_SSH_KEY="\$(cat $NODEPOOL_HOME_DIR/.ssh/jenkins.pub | cut -d' ' -f 2)"
export NODEPOOL_PYPI_MIRROR="http://pypi.python.org/simple"
export NODEPOOL_XENSERVER_XVA_URL=$NODEPOOL_XENSERVER_XVA_URL
export NODEPOOL_XENSERVER_ISO_URL=$NODEPOOL_XENSERVER_ISO_URL
/opt/nodepool/env/bin/python \\
/opt/nodepool/env/bin/nodepoold \\
-l /etc/nodepool/logging.conf \\
-d
end script
NODEPOOLSTARTER
sudo chown -R $NODEPOOL_USER:$NODEPOOL_USER $NODEPOOL_HOME_DIR/.ssh
sudo chmod -R g-w,g-r,o-w,o-r $NODEPOOL_HOME_DIR/.ssh
sudo chmod -R g-w,o-w /etc/nodepool /opt/nodepool
sudo chown -R $NODEPOOL_USER:nogroup /var/log/nodepool
sudo chmod -R g-w,o-w /var/log/nodepool
######
# Generate public keys
sudo -u $NODEPOOL_USER bash -c "\
ssh-keygen -y -f $NODEPOOL_HOME_DIR/.ssh/jenkins > $NODEPOOL_HOME_DIR/.ssh/jenkins.pub"
sudo -u $NODEPOOL_USER bash -c "\
ssh-keygen -y -f $NODEPOOL_HOME_DIR/.ssh/id_rsa > $NODEPOOL_HOME_DIR/.ssh/id_rsa.pub"
######
# Create a management script
sudo tee /usr/local/bin/osci-nodepool << EOF
#!/bin/bash
sudo -u $NODEPOOL_USER -i \\
NODEPOOL_SSH_KEY="\$(cat $NODEPOOL_HOME_DIR/.ssh/jenkins.pub | cut -d' ' -f 2)" \\
NODEPOOL_PYPI_MIRROR="http://pypi.python.org/simple" \\
NODEPOOL_XENSERVER_XVA_URL=$NODEPOOL_XENSERVER_XVA_URL \\
NODEPOOL_XENSERVER_ISO_URL=$NODEPOOL_XENSERVER_ISO_URL \\
/opt/nodepool/env/bin/nodepool "\$@"
EOF
sudo chmod 0755 /usr/local/bin/osci-nodepool