Skip to content

Commit dede226

Browse files
committed
Working script to create a jenkins server
I'm still short of adding the port and mapping the floating ip, but close. I also intended to use userdata to do an apt-get install jenkins. Change-Id: If86e3f381bb951de48cc984c0e863b896ed33353
1 parent 8baa156 commit dede226

File tree

26 files changed

+1666
-45
lines changed

26 files changed

+1666
-45
lines changed

examples/cloud-init.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash -x
2+
echo '*** start cloud-init ***'
3+
wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
4+
echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
5+
apt-get update
6+
apt-get install -y jenkins
7+
echo 'JENKINS_ARGS="${JENKINS_ARGS} --argumentsRealm.passwd.jenkins=admin --argumentsRealm.roles.jenkins=admin"' >> /etc/default/jenkins
8+
cat >/var/lib/jenkins/config.xml <<!
9+
<?xml version='1.0' encoding='UTF-8'?>
10+
<hudson>
11+
<disabledAdministrativeMonitors/>
12+
<version>1.0</version>
13+
<numExecutors>2</numExecutors>
14+
<mode>NORMAL</mode>
15+
<useSecurity>true</useSecurity>
16+
<authorizationStrategy class="hudson.security.LegacyAuthorizationStrategy"/>
17+
<securityRealm class="hudson.security.LegacySecurityRealm"/>
18+
<disableRememberMe>false</disableRememberMe>
19+
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy\$DefaultProjectNamingStrategy"/>
20+
<workspaceDir>\${ITEM_ROOTDIR}/workspace</workspaceDir>
21+
<buildsDir>\${ITEM_ROOTDIR}/builds</buildsDir>
22+
<markupFormatter class="hudson.markup.EscapedMarkupFormatter"/>
23+
<jdks/>
24+
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
25+
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
26+
<clouds/>
27+
<slaves/>
28+
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
29+
<views>
30+
<hudson.model.AllView>
31+
<owner class="hudson" reference="../../.."/>
32+
<name>All</name>
33+
<filterExecutors>false</filterExecutors>
34+
<filterQueue>false</filterQueue>
35+
<properties class="hudson.model.View\$PropertyList"/>
36+
</hudson.model.AllView>
37+
</views>
38+
<primaryView>All</primaryView>
39+
<slaveAgentPort>0</slaveAgentPort>
40+
<label></label>
41+
<nodeProperties/>
42+
<globalNodeProperties/>
43+
</hudson>
44+
!
45+
cat >/var/lib/jenkins/jenkins.security.QueueItemAuthenticatorConfiguration.xml <<!
46+
<?xml version='1.0' encoding='UTF-8'?>
47+
<jenkins.security.QueueItemAuthenticatorConfiguration>
48+
<authenticators/>
49+
</jenkins.security.QueueItemAuthenticatorConfiguration>
50+
!
51+
service jenkins restart
52+
echo '*** stop cloud-init ***'\n"
53+

examples/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def option_parser():
291291
parser.add_argument(
292292
'--data',
293293
metavar='<data>',
294-
default='{}',
294+
default={},
295295
help='Json data for command.',
296296
)
297297
parser.add_argument(

examples/connection.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
"""
14+
Example Connection Command
15+
16+
Make sure you can authenticate before running this command.
17+
18+
For example:
19+
python -m examples.connection
20+
"""
21+
22+
import sys
23+
24+
from examples import common
25+
from openstack import connection
26+
27+
28+
def make_connection(opts):
29+
args = {
30+
'auth_plugin': opts.auth_plugin,
31+
'auth_url': opts.auth_url,
32+
'project_name': opts.project_name,
33+
'domain_name': opts.domain_name,
34+
'project_domain_name': opts.project_domain_name,
35+
'user_domain_name': opts.user_domain_name,
36+
'user_name': opts.user_name,
37+
'password': opts.password,
38+
'verify': opts.verify,
39+
'token': opts.token,
40+
}
41+
conn = connection.Connection(preference=opts.user_preferences, **args)
42+
return conn
43+
44+
45+
def run_connection(opts):
46+
conn = make_connection(opts)
47+
print("Connection: %s" % conn)
48+
for flavor in conn.compute.list_flavors():
49+
print(flavor.id + " " + flavor.name)
50+
return
51+
52+
53+
if __name__ == "__main__":
54+
opts = common.setup()
55+
sys.exit(common.main(opts, run_connection))

0 commit comments

Comments
 (0)