blob: 0bf6347a95c18e2c30eb0d8fdd12266e9c6046bf [file] [log] [blame]
Brian Freeman48d30542019-08-20 13:13:58 -05001#cloud-config
2# vim: syntax=yaml
3write_files:
4- path: /opt/format-disks
5 permissions: '0700'
6 content: |
7 #!/bin/bash
8 voldata_id="%voldata_id%"
9 voldata_dev="/dev/disk/by-id/virtio-$(echo ${voldata_id} | cut -c -20)"
10 mkfs.ext4 ${voldata_dev}
11 mkdir -pv /var/lib/jenkins
12 echo "${voldata_dev} /var/lib/jenkins ext4 defaults 1 2" >> /etc/fstab
13 mount /var/lib/jenkins
14- path: /opt/jenkins_vm_entrypoint.sh
15 permissions: '0755'
16 content: |
17 #!/bin/bash -x
18
19 printenv
20
21 echo `hostname -I` `hostname` >> /etc/hosts
22
23 function restart_jenkins() {
24 sudo systemctl restart jenkins
25 sleep 1
26 echo -n "Restarting jenkins"
27 until $(curl --output /dev/null --silent --head --fail http://localhost:8080/login); do
28 printf '.'
29 sleep 3
30 done
31 echo
32 sleep 1
33 }
34
35 cp ~ubuntu/.ssh/authorized_keys /root/.ssh
36
37 cat > /etc/apt/apt.conf.d/90curtin-aptproxy<<EOF
38 Acquire::http::Proxy "http://10.145.122.117:8000/";
39 EOF
40
41 apt-get update
42
43 cat >> /etc/inputrc <<EOF
44 set show-all-if-ambiguous on
45 set show-all-if-unmodified on
46 set match-hidden-files off
47 set mark-symlinked-directories on
48 EOF
49
50 export HOME=/root
51 apt-get -y install git
52 git config --global user.email "jenkins@localhost"
53 git config --global user.name "jenkins"
54 apt-get -y install etckeeper
55 apt-get -y install curl openjdk-8-jre unzip python3-openstackclient python3-heatclient python3-jenkins-job-builder jq openvpn python3-pip xmlstarlet tree
56 pip3 install robotframework
57
58 # install Jenkins
59 wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
60 sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
61 apt-get update
62 apt-get -y install jenkins
63
64 mkdir -p ~jenkins/.ssh
65 cp ~ubuntu/.ssh/authorized_keys ~jenkins/.ssh
66 chown -R jenkins:jenkins ~jenkins/.ssh
67
68 su -l jenkins -c "/opt/jenkins-init-1.sh"
69
70 restart_jenkins
71
72 su -l jenkins -c "/opt/jenkins-init-2.sh"
73
74 restart_jenkins
75
76- path: /opt/jenkins-init-1.sh
77 permissions: '0755'
78 content: |
79 #!/bin/bash -x
80
81 git config --global user.email "jenkins@localhost"
82 git config --global user.name "jenkins"
83
84 cd ~jenkins
85
86 cp /etc/skel/.profile .
87 cat > .bashrc <<EOF
88 alias ls='ls --color -F'
89 EOF
90
91 git init
92
93 git add -A
94 git commit -m 'Initial installation config' > /dev/null
95
96 rm -f secrets/initialAdminPassword
97 rm -rf users/admin
98 rsync -avP /opt/jenkins/ .
99
100 git add -A
101 git commit -m 'Set up jenkins user' > /dev/null
102
103- path: /opt/jenkins-init-2.sh
104 permissions: '0755'
105 content: |
106 #!/bin/bash -x
107
108 cd ~jenkins
109 ln -s /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar
110
111 sleep 20
112 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin git
113 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin ws-cleanup
114 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin envinject
115 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin gerrit-trigger
116 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin robot
117 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin postbuildscript
118 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin timestamper
119 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin build-blocker-plugin
120 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin build-timeout
121 java -jar jenkins-cli.jar -s http://localhost:8080/ -auth jenkins:jenkins install-plugin influxdb
122
123 git add -A
124 git commit -m 'Install initial plugins' > /dev/null
125
126 git clone https://github.com/garyiwu/onap-lab-ci.git
127 cd onap-lab-ci
128 jenkins-jobs update -r jjb
129
130- path: /opt/jenkins/jenkins.install.InstallUtil.lastExecVersion
131 content: |
132 2.46.3
133- path: /opt/jenkins/users/jenkins/config.xml
134 content: |
135 <?xml version='1.0' encoding='UTF-8'?>
136 <user>
137 <fullName>jenkins</fullName>
138 <properties>
139 <jenkins.security.ApiTokenProperty>
140 <apiToken>{AQAAABAAAAAwQAGpldGajxw//dhxd53gZGv4w0JnZYDETTLBQdpotQXt02s0lq13YrhyaytbLFMflb98hzWY9YBlDIThZt7u+Q==}</apiToken>
141 </jenkins.security.ApiTokenProperty>
142 <com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty plugin="credentials@2.1.13">
143 <domainCredentialsMap class="hudson.util.CopyOnWriteMap$Hash"/>
144 </com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty>
145 <hudson.model.MyViewsProperty>
146 <views>
147 <hudson.model.AllView>
148 <owner class="hudson.model.MyViewsProperty" reference="../../.."/>
149 <name>all</name>
150 <filterExecutors>false</filterExecutors>
151 <filterQueue>false</filterQueue>
152 <properties class="hudson.model.View$PropertyList"/>
153 </hudson.model.AllView>
154 </views>
155 </hudson.model.MyViewsProperty>
156 <org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty plugin="display-url-api@2.0">
157 <providerId>default</providerId>
158 </org.jenkinsci.plugins.displayurlapi.user.PreferredProviderUserProperty>
159 <hudson.model.PaneStatusProperties>
160 <collapsed/>
161 </hudson.model.PaneStatusProperties>
162 <hudson.search.UserSearchProperty>
163 <insensitiveSearch>false</insensitiveSearch>
164 </hudson.search.UserSearchProperty>
165 <hudson.security.HudsonPrivateSecurityRealm_-Details>
166 <passwordHash>#jbcrypt:$2a$10$Esc9z/mnK/CQ8crgFbE3/eP1EI6pvzIHRBe3SSik7rrNt.DDftON2</passwordHash>
167 </hudson.security.HudsonPrivateSecurityRealm_-Details>
168 <hudson.tasks.Mailer_-UserProperty plugin="mailer@1.20">
169 <emailAddress>jenkins@localhost</emailAddress>
170 </hudson.tasks.Mailer_-UserProperty>
171 </properties>
172 </user>
173
174runcmd:
175- /opt/format-disks
176- /opt/jenkins_vm_entrypoint.sh