This is an old revision of the document!
This guide assumes that you already have a MaaS environment set up and working with windows images uploaded. If you do not, head over to How to deploy MAAS, finish that and come back when you are finished.
Prerequisites:
We are going to go through all the steps required to stand up a new Hyper-V CI. At the end of this guide, you should have:
Note, this guide does not cover high availability. That is a topic for a different howto.
First things first. We need a working juju environment to start things off.
We should strive to use the latest stable juju when deploying a new CI environment. However, if any blocking bugs arise, a bug report should be filed against juju-core. Blocking bugs are usually fixed and backported to stable promptly.
sudo apt-add-repository -y ppa:juju/stable sudo apt-get update && sudo apt-get install -y juju-core sudo apt-get install -y juju-deployer
juju init
maas: type: maas maas-server: 'http://<ip>/MAAS/' maas-oauth: '<Key you got from http://<MAAS IP>/MAAS/account/prefs/>' bootstrap-timeout: 1800 enable-os-refresh-update: true enable-os-upgrade: true
juju switch maas
juju bootstrap --debug --show-log
If you have any troubles bootstrapping and you need to retry, you have to destroy the environment and run the above command again:
juju destroy-environment maas --force -y
juju status --format tabular
You should see something like:
ubuntu@ubuntu-maas:~$ juju status --format tabular [Services] NAME STATUS EXPOSED CHARM [Units] ID STATE VERSION MACHINE PORTS PUBLIC-ADDRESS [Machines] ID STATE VERSION DNS INS-ID SERIES HARDWARE 0 started 1.24.3 likable-rock.maas /MAAS/api/1.0/nodes/node-ad58279e-1aab-11e5-bdef-d8d385e3761a/ trusty arch=amd64 cpu-cores=16 mem=32768M
Next, we need to deploy jenkins, zuul and active-directory. Jenkins charm exists upstream, and we will use it. The zuul charm is a bit custom made for this CI, so we need to clone it our github repository.
So lets clone necessary charms locally:
sudo apt-get install -y git mkdir -p ~/charms/trusty && cd ~/charms/trusty git clone https://github.com/cloudbase/zuul-charm.git zuul mkdir -p ~/charms/win2012r2 && cd ~/charms/win2012r2 git clone git@bitbucket.org:cloudbase/active-directory-charm.git active-directory cd active-directory ./download-juju-powershell-modules.sh
This bit of the CI rarely changes, so once deployed we will probably not touch it to often.
Now lets deploy the charms. Navigate to the charms folder:
cd ~/charms
and create a file called infra.yaml with the following content (edit where necesarry):
maas: services: jenkins: num_units: 1 charm: cs:trusty/jenkins options: password: SuperSecretPassword plugins: "gearman-plugin throttle-concurrents parameterized-trigger" zuul: num_units: 1 charm: local:trusty/zuul branch: git@github.com:cloudbase/zuul-charm.git options: username: hyper-v-ci ssh-key: | -----BEGIN RSA PRIVATE KEY----- <YOUR KEY GOES HERE> -----END RSA PRIVATE KEY----- git-user-email: "microsoft_hyper-v_ci@microsoft.com" git-user-name: "hyper-v-ci" active-directory: num_units: 1 charm: local:win2012r2/active-directory branch: git@bitbucket.org:cloudbase/active-directory-charm.git options: domain-name: "hyperv-ci.local" password: "Nob0dyC@nGuessThisAm@zingPassw0rd^"
Using that file we will now deploy our charms. Take note, charms will be configured to use the information you provide.
At the end you should have something like this:
$ juju status --format tabular [Services] NAME STATUS EXPOSED CHARM active-directory unknown false local:win2012r2/active-directory-1 jenkins unknown false cs:trusty/jenkins-4 zuul unknown false local:trusty/zuul-0 [Units] ID WORKLOAD-STATE AGENT-STATE VERSION MACHINE PORTS PUBLIC-ADDRESS MESSAGE active-directory/0 unknown idle 1.24.3 1 1-65535/tcp,1-65535/udp another-month.maas jenkins/0 unknown idle 1.24.3 2 8080/tcp stunning-digestion.maas zuul/0 unknown idle 1.24.3 3 exalted-nerve.maas [Machines] ID STATE VERSION DNS INS-ID SERIES HARDWARE 0 started 1.24.3 likable-rock.maas /MAAS/api/1.0/nodes/node-ad58279e-1aab-11e5-bdef-d8d385e3761a/ trusty arch=amd64 cpu-cores=16 mem=32768M 1 started 1.24.3 another-month.maas /MAAS/api/1.0/nodes/node-b092b82a-1aab-11e5-b839-d8d385e3761a/ win2012r2 arch=amd64 cpu-cores=16 mem=32768M 2 started 1.24.3 stunning-digestion.maas /MAAS/api/1.0/nodes/node-b1c505a4-1aab-11e5-bdef-d8d385e3761a/ trusty arch=amd64 cpu-cores=16 mem=32768M 3 started 1.24.3 exalted-nerve.maas /MAAS/api/1.0/nodes/node-b2499210-1aab-11e5-b839-d8d385e3761a/ trusty arch=amd64 cpu-cores=16 mem=32768M
The zuul charm sets up most of what we need automatically. However, given that jenkins allows the user to create arbitrary jobs, the layout.yaml may not fit with the job names you created. So after creating the jenkins jobs (not yet automated), you will need to tweak the layout.yaml for zuul.
So lets access jenkins now:
juju status --format oneline jenkins
This hsould show you the public address of the jenkins nodes deployed:
$ juju status --format oneline jenkins - jenkins/0: stunning-digestion.maas (started) 8080/tcp
If you've set up the MaaS node as your local resolver, then you should be able to resolve the randomly nenerated hostname (stunning-digestion.maas in this case). If not, you can resolve it by simply doing:
nslookup stunning-digestion.maas <maas ip>
example:
nslookup stunning-digestion.maas 10.255.251.167 Server: 10.255.251.167 Address: 10.255.251.167#53 Name: stunning-digestion.maas Address: 10.255.251.177
Navigate over to http://10.255.251.177:8080 and log in using: