Rob Harris
2018-04-23 5d45630d38a5201c65e670342119f9eeadf30cef
commit | author | age
5d0992 1 # The Manual Menace
7c832b 2 > In this lab learners will use Ansible to drive automated provisioning of Projects in Openshift, Git, Jenkins and Nexus.
c951f7 3
7c832b 4 ![automation-xkcd](https://imgs.xkcd.com/comics/automation.png)
D 5
6 ## Exercise Intro
7 In this exercise we will use automation tooling to create Project namespaces for our `CI/CD` tooling along with the `dev` and `test` namespaces for our deployments to live. We do this to manually using the OpenShift CLI; but as we go from cluster to cluster or project to project Dev and Ops teams often find themselves having to redo these tasks again and again. Configuring our cluster using code; we can easily store this in Git and repeat the process again and again. By minimising the time taken to do these repetitive tasks we can accelerate our ability to deliver value to our customers; working on the hard problems they face.
8
9 This exercise uses Ansible to drive the creation of the cluster content. In particular; we'll use a play book called the `OpenShift Applier`. Once the project namespace have been created; we will add some tools to support CI/CD such as Jenkins, Git and Nexus. These tools will be needed by later lessons to automate the build and deploy of our apps. Again; we will use OpenShift Templates and drive their creation in the cluster using Ansible. To prove things are working, finally we'll delete all our content and re-apply the inventory to re-create our clusters content.
5d0992 10
14cd2d 11 #### Why is config-as-code important? 
D 12 * Assurance - Prevents unwanted config changes from people making arbitrary changes to environments. No more Snowflake servers!
13 * Traceability - Commiting config as code means a user has approved and changes can be tracked.
14 * Phoenix Server -  Burn it all to the ground and bring it back; exactly the way it was!
15
5d0992 16 _____
c951f7 17
D 18 ## Learning Outcomes
19 As a learner you will be able to
5d0992 20
D 21 1. Run the OpenShift Applier to automate creating cluster content
22 1. Create and admin project namespaces in OpenShift
23 1. Deploy commonly used applications to support the development process
c951f7 24
D 25 ## Tools and Frameworks
26
5d0992 27 * [GitLab](https://about.gitlab.com/) - Community driven Git server now with integrated DevOps Toolchain.
D 28 * [Nexus](https://www.sonatype.com/nexus-repository-sonatype) - Repository manager for storing lots of application types. Can also host `npm` and `Docker` registries.
29 * [Jenkins](https://jenkins.io/) - OpenSource Build automation server. Highly customisable with plugins.
30 * [Ansible](https://www.ansible.com/) - IT Automation tool used to provision and manage state of cloud and physical infrastructure.
dba30b 31 * [OpenShift Applier](https://github.com/redhat-cop/openshift-applier) - used to apply OpenShift objects to an OpenShift Cluster.
A 32
33
c951f7 34
5d0992 35 ## Big Picture
D 36 This exercise begins with an empty Cluster
37 > TODO - add big picture here...
38
39 _____
c951f7 40
D 41 ## 10,000 Ft View
5d0992 42 > This lab is aimed at the creation of the tooling that will be used to support the rest of the Exercises. The highlevel goal is to create a collection of project namespaces and populate them with Git, Jenkins & Nexus.
D 43
44 If you're feeling confident and don't want to follow the step-by-step guide these highlevel instructions should provide a challenge for you:
45
3b1c96 46 2. Clone the repo `https://github.com/rht-labs/enablement-ci-cd` which contains the scaffold of the project.
3558ae 47
5d0992 48 2. Create `<your-name>-ci-cd`, `<your-name>-dev` and `<your-name>-test` project namespaces using the inventory and run them with the OpenShift Applier to populate the cluster
3558ae 49
D 50 2. Use the templates provided to create build and deployment configs in `<your-name>-ci-cd` for. Templates are on a branch called `exercise1/git-nexus` && `exercise1/jenkins`:
5d0992 51     * Nexus
D 52     * GitLab
3558ae 53     * Jenkins (using an s2i to pre-configure jenkins)
D 54
5d0992 55 2. Commit your `enablement-ci-cd` repository to the GitLab Instance you've created
3558ae 56
D 57 2. Burn it all down and re-apply your inventory proving config-as-code works. 
c951f7 58
D 59 ## Step by Step Instructions
bc2e43 60 > This is a structured guide with references to exact filenames and explanations.
c951f7 61
bc2e43 62 ### Part 1 - Create OpenShift Projects
de8ebb 63 > _Using the OpenShift Applier, we will add new project namespaces to the cluster which will be used throughout the exercise._
D 64
e7c877 65 3. Clone the scaffold project to your local machine and pull all remote branches for use in later labs. Open the repo in your favourite editor.
bc2e43 66 ```bash
e7c877 67 $ git clone https://github.com/rht-labs/enablement-ci-cd && cd enablement-ci-cd
RH 68 ```
69 Followed by;
70 ```
71 $ for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
72    git branch --track ${branch#remotes/origin/} $branch
73 done
c951f7 74 ```
D 75
bc2e43 76 3. The project is laid out as follows
D 77 ```
78 .
79 ├── README.md
62db52 80 ├── apply.yml
bc2e43 81 ├── docker
62db52 82 │   └── jenkins-slave-npm
bc2e43 83 ├── inventory
62db52 84 │   ├── host_vars
D 85 │   │   ├── ci-cd-tooling.yml
86 │   │   └── projects-and-policies.yml
87 │   └── hosts
bc2e43 88 ├── jenkins-s2i
D 89 ├── params
62db52 90 │   └── project-requests-ci-cd
bc2e43 91 ├── requirements.yml
D 92 └── templates
62db52 93     └── project-requests.yml
bc2e43 94 ```
D 95  * `docker` folder contains our jenkins-slave images that will be used by the builds.
96  * `jenkins-s2i` contains the configuration and plugins we want to bring jenkins to life with
97  * `params` houses the variables we will load the templates with
98  * `templates` is a collection of OpenShift templates
62db52 99  * `inventory/host_vars/*.yml` is the collection of objects we want to insert into the cluster.
bc2e43 100  * `requirements.yml` is a manifest which contains the ansible modules needed to run the playbook
62db52 101  * `apply.yml` is a playbook that sets up some variables and runs the OpenShift Applier role.
bc2e43 102
62db52 103 3. Open the `apply.yml` file in the root of the project. Update the namespace variables by replacing the `<YOUR_NAME>` with your name or initials. For example; my name is Dónal so I've created: 
D 104 ```yaml
105   vars:
106     ci_cd_namespace: donal-ci-cd
107     dev_namespace: donal-dev
108     test_namespace: donal-test
109 ```
110
111 3. Open the `inventory/host_vars/projects-and-policies.yml` file; you should see some variables setup already to create the `<YOUR_NAME>-ci-cd` namespace. This object is passed to the OpenShift Applier to call the `templates/project-requests.yml` template with the `params/project-requests-ci-cd` parameters. We will add some additional content here but first let's explore the parameters and the template
112
113 3. Open the `params/project-requests-ci-cd` and replace the `<YOUR_NAME>` with your name to create the correstponding projects in the cluster. 
ff1bd7 114 ![new-item](../images/exercise1/ci-cd-project-namespace.png)
bc2e43 115
62db52 116 3. Let's add two more param files to pass to our template to be able to create a `dev` and `test` project.
D 117   * Create another two params files `params/project-requests-dev` & `params/project-requests-test`. 
118   * Add to `params/project-requests-dev` the following; substituting `<YOUR_NAME>` accordingly
119 ```
120 NAMESPACE=<YOUR_NAME>-dev
121 NAMESPACE_DISPLAY_NAME=<YOUR-NAME> Dev
122 ```
123   * Add to `params/project-requests-test` the following; substituting `<YOUR_NAME>` accordingly
124 ```
125 NAMESPACE=<YOUR_NAME>-test
126 NAMESPACE_DISPLAY_NAME=<YOUR-NAME> Test
127 ```
bc2e43 128
62db52 129 3. In the `inventory/host_vars/projects-and-policies.yml` file; add the new objects for the projects you want to create (dev & test) by adding another object to the content array for each. You can copy and paste them from the `ci-cd` example and update them accordingly. If you do this; remember to change the params file! e.g.
bc2e43 130 ```yaml
62db52 131     - name: "{{ dev_namespace }}"
D 132       template: "{{ playbook_dir }}/templates/project-requests.yml"
ff1bd7 133       template_action: create
62db52 134       params: "{{ playbook_dir }}/params/project-requests-dev"
ff1bd7 135       tags:
D 136       - projects
62db52 137     - name: "{{ test_namespace }}"
D 138       template: "{{ playbook_dir }}/templates/project-requests.yml"
ff1bd7 139       template_action: create
62db52 140       params: "{{ playbook_dir }}/params/project-requests-test"
ff1bd7 141       tags:
D 142       - projects
bc2e43 143 ```
ff1bd7 144 ![project-request-yaml](../images/exercise1/project-request-yml.png)
bc2e43 145
D 146 3. With the configuration in place; install the OpenShift Applier dependency
147 ```bash
148 $ ansible-galaxy install -r requirements.yml --roles-path=roles
149 ```
150
f79b6f 151 3. Apply the inventory by logging into OpenShift and running the following: 
bc2e43 152 ```bash
D 153 $ oc login -p <password> -u <user> <cluster_url>
62db52 154 $ ansible-playbook apply.yml -i inventory/ -e target=bootstrap
D 155 ```
156 where the `-e target=bootstrap` is passing an additional variable specifying that we run the `bootstrap` inventory
bc2e43 157
f79b6f 158 3. Once successful you should see an output similar to this: ![playbook-success](../images/exercise1/play-book-success.png)
bc2e43 159
D 160 ### Part 2 - Nexus and GitLab
3f16e0 161 > _Now that we have our Projects setup; we can start to populate them with Apps to be used in our dev lifecycle_
bc2e43 162
b43054 163 #### Part 2a - Nexus
3558ae 164 4. In the `enablement-ci-cd` repo, checkout the templates for Nexus by running
3f16e0 165 ```bash
3558ae 166 $ git checkout exercise1/git-nexus templates/nexus.yml
D 167 ```
f79b6f 168 The template contains all the things needed to setup a persistent nexus server, exposing a service and route while also creating the persistent volume needed. Have a read through the template; at the bottom you'll see a collection of parameters we will pass to the template.
3558ae 169
D 170 4. Add some parameters for running the template by creating a new file in the `params` directory. 
171 ```bash
172 $ touch params/nexus
3f16e0 173 ```
D 174
3558ae 175 4. The essential params to inclue in this file are: `params` directory. 
D 176 ```bash
177 VOLUME_CAPACITY=5Gi
178 MEMORY_LIMIT=2Gi
179 ```
180
62db52 181 4. Create a new object in the inventory variables `inventory/host_vars/ci-cd-tooling.yml` called `ci-cd-deployments` and populate it's `content` is as follows
D 182
3558ae 183 ```yaml
62db52 184 ---
D 185 ansible_connection: local
186 openshift_cluster_content:
187 - object: ci-cd-tooling
188   content:
ff1bd7 189     - name: "nexus"
62db52 190       namespace: "{{ ci_cd_namespace }}"
D 191       template: "{{ playbook_dir }}/templates/nexus.yml"
192       params: "{{ playbook_dir }}/params/nexus"
ff1bd7 193       tags:
D 194       - nexus
3558ae 195 ```
ff1bd7 196 ![ci-cd-deployments-yml](../images/exercise1/ci-cd-deployments-yml.png)
3558ae 197
06fc7b 198 4. Run the OpenShift applier, specifying the tag `nexus` to speed up it's execution (`-e target=tools` is to run the other inventory).
3558ae 199 ```bash
06fc7b 200 $ ansible-playbook apply.yml -e target=tools \
3558ae 201      -i inventory/ \
ff1bd7 202      -e "filter_tags=nexus"
3558ae 203 ```
D 204
b47510 205 4. Once successful; login to the cluster through the browser (using cluster URL) and navigate to the `<YOUR_NAME>-ci-cd`. You should see Nexus up and running. You can login with default credentials (admin / admin123) ![nexus-up-and-running](../images/exercise1/nexus-up-and-running.png)
3558ae 206
b43054 207 #### Part 2b - GitLab
D 208 <p class="tip">
209 NOTE - This section may already have been completed for you, please check with your tutor. If this is the case, skip to section 6 to add your code to GitLab.
210 </p>
211
f79b6f 212 4. Now let's do the same thing for GitLab to get it up and running. Checkout the template and params provided by running
3558ae 213 ```bash
aa106a 214 $ git checkout exercise1/git-nexus templates/gitlab.yml params/gitlab
3558ae 215 ``` 
D 216 Explore the template; it contains the PVC, buildConfig and services. The DeploymentConfig is made up of these apps
217  - Redis (3.2.3)
218  - PostgreSQL (9.4)
219  - GitLab CE (v10.2.3)
220
b47510 221 4. Open the `params/gitlab` file and complete the following params
RH 222 <p class="tip">
223 Note - The values here for the LDAP and BIND credentials will be provided by your tutor.
224 </p>
3558ae 225 ```
D 226 LDAP_BIND_DN=uid=<BIND_USER>,ou=People,dc=<YOUR_DOMAIN>,dc=com
227 LDAP_USER_FILTER=(memberof=CN=YourGroup,OU=Users,DC=<YOUR_DOMAIN>,DC=com)
228 LDAP_PASSWORD=<BIND_USER_PASSWORD>
229 LDAP_HOST=<LDAP_HOST>
230 LDAP_BASE=ou=People,dc=<YOUR_DOMAIN>,dc=com
231 LDAP_LABEL="<LDAP_DESCRIPTION>"
232 GITLAB_ROOT_PASSWORD=<GITLAB_ROOT_USER_PASSWORD>
233 GITLAB_DATA_VOL_SIZE=2Gi
234 POSTGRESQL_VOL_SIZE=1Gi
235 APPLICATION_HOSTNAME=<GITLAB_URL>
c41b51 236 NAMESPACE=<YOUR_NAME>-ci-cd
3558ae 237 ```
D 238 where the following need to be replaced by actual values:
239     * `<BIND_USER>` is the user used to query the LDAP
240     * `<BIND_USER_PASSWORD>` is the password used when querying the LDAP
241     * `<YOUR_DOMAIN>` is the domain the LDAP is hosted on
242     * `<LDAP_HOST>` is fqdn of the LDAP server
243     * `<LDAP_DESCRIPTION>` is the description to be used on the sign-in header for GitLab eg "Name LDAP Login"
244     * `<GITLAB_ROOT_USER_PASSWORD>` is the root user for GOD access on the GitLab instance eg password123
245     * `<GITLAB_URL>` is the endpoint for gitlab. It will take the form `gitlab-<YOUR_NAME>-ci-cd.apps.<ENV_ID>.<YOUR_DOMAIN>.com`
246
62db52 247 4. Create another object in the inventory `inventory/host_vars/ci-cd-tooling.yml` file to run the build & deploy of this template. Add the following and update the `namespace:` accordingly
3558ae 248 ```yaml
ff1bd7 249     - name: "gitlab"
62db52 250       namespace: "{{ ci_cd_namespace }}"
D 251       template: "{{ playbook_dir }}/templates/gitlab.yml"
252       params: "{{ playbook_dir }}/params/gitlab"
ff1bd7 253       tags:
D 254       - gitlab
3558ae 255 ```
D 256
257 4. Run the OpenShift applier, specifying the tag `gitlab` to speed up it's execution.
258 ```bash
06fc7b 259 $ ansible-playbook apply.yml -e target=tools \
3558ae 260      -i inventory/ \
ff1bd7 261      -e "filter_tags=gitlab"
3558ae 262 ```
D 263
ff1bd7 264 4. Once successful; login to the cluster and navigate to the `<YOUR_NAME>-ci-cd`. You should see GitLab up and running. ![gitlab-up-and-running](../images/exercise1/gitlab-up-and-running.png)
c41b51 265
aa106a 266 4. Navigate to gitlab. You can login using your cluster credentials using the LDAP tab displaying your `<LDAP_DESCRIPTION>` from previous steps
ff1bd7 267 ![gitlab-ui](../images/exercise1/gitlab-ui.png)
c41b51 268
de8ebb 269 4. Once logged in create a new project called `enablement-ci-cd` and mark it as internal. Once created; copy out the `git remote add origin ...` instructions for use on the next step.
ff1bd7 270 ![gitlab-new-project](../images/exercise1/gitlab-new-project.png)
D 271 <p class="tip">
de8ebb 272 Note - we would not normally make the project under your name but create an group and add the project there on residency but for simplicity of the exercise we'll do that here
ff1bd7 273 </p>
D 274
275 4. Commit your local project to this new origin by first removing the existing origin (github) where the the project was cloned from. Remember to substitute `<YOUR_NEW_GIT_PROJECT>` accordingly
276 ```bash
06e3b4 277 $ git remote set-url origin <YOUR_NEW_GIT_PROJECT>
ff1bd7 278 $ git add . 
D 279 $ git commit -m "Adding git and nexus config"
280 $ git push -u origin --all
281 ```
06e3b4 282 **Note - When making changes to enablement-ci-cd you should frequently commit the changes to git.**
bc2e43 283
D 284 ### Part 3 - Jenkins & s2i
de8ebb 285 > _Create a build and deployment config for Jenkins. Add new configuration and plugins to the OCP Stock Jenkins using s2i_
bc2e43 286
ff1bd7 287 5. Add the Jenkins Build & Deployment configs to the `enablement-ci-cd` repo by merging the contents `exercise1/jenkins` in
D 288 ```bash
289 $ git checkout exercise1/jenkins templates/jenkins.yml
290 ```
291 The Jenkins template is essentially the standard persistent jenkins one with OpenShift.
292
293 5. As before; create a new set of params by creating a `params/jenkins` file and adding some overrides to the template and updating the `NAMESPACE` value.
294 ```bash
295 MEMORY_LIMIT=8Gi
f54f70 296 VOLUME_CAPACITY=10Gi
ff1bd7 297 JVM_ARCH=x86_64
D 298 NAMESPACE=<YOUR_NAME>-ci-cd
299 JENKINS_OPTS=--sessionTimeout=720
300 ```
62db52 301
D 302 5. Add a `jenkins` variable to the ansible inventory underneath the git (if you have it) and nexus ones.
ff1bd7 303 ```yaml
D 304     - name: "jenkins"
62db52 305       namespace: "{{ ci_cd_namespace }}"
D 306       template: "{{ playbook_dir }}/templates/jenkins.yml"
307       params: "{{ playbook_dir }}/params/jenkins"
ff1bd7 308       tags:
D 309       - jenkins
310 ```
f79b6f 311 This configuration, if applied now, will create the deployment configuration needed for Jenkins but the `${NAMESPACE}:${JENKINS_IMAGE_STREAM_TAG}` in the template won't exist yet.
ff1bd7 312
D 313 5. To create this image we will take the supported OpenShift Jenkins Image and bake into it some extra configuration using an [s2i](https://github.com/openshift/source-to-image) builder image. More information on Jenkins s2i is found on the [openshift/jenkins](https://github.com/openshift/jenkins#installing-using-s2i-build) github page. To create an s2i configuration for jenkins, check out the pre-canned configuration source in the `enablement-ci-cd` repo
314 ```bash
315 $ git checkout exercise1/jenkins-s2i jenkins-s2i
316 ```
317 The structure of the jenkins s2i config is 
318 ```
319 jenkins-s2i
320 ├── README.md
321 ├── configuration
322 │   ├── build-failure-analyzer.xml
323 │   ├── init.groovy
324 │   ├── jenkins.plugins.slack.SlackNotifier.xml
325 │   └── jobs
326 │       └── seed-multibranch-job
327 │           └── config.xml
328 └── plugins.txt
329 ```
330  * `plugins.txt` is a list of `pluginId:version` for Jenkins to pre-install when starting
331  * `./configuration` contains content that is placed in `${JENKINS_HOME}`. A `config.xml` could be placed in here to control the bulk of Jenkins configuration.
332  * `./configuration/jobs/*` contains job names and xml config that jenkins loads when starting. The seed job in there we will return to in later lessons.
de8ebb 333  * `build-failure-analyzer.xml` is config for the plugin to read the logs and look for key items based on a Regex. More on this in later lessons.
ff1bd7 334  * `init.groovy` contains a collection of settings jenkins configures itself with when launching
D 335
336 5. Let's add a plugin for Jenkins to be started with, [green-balls](https://plugins.jenkins.io/greenballs). This simply changes the default `SUCCESS` status of Jenkins from Blue to Green. Append the `plugins.txt` file with 
337 ```txt
338 greenballs:1.15
339 ``` 
340 ![green-balls.png](../images/exercise1/green-balls.png)
341 Why does Jenkins have Blue Balls? More can be found [on reddit](https://www.reddit.com/r/programming/comments/4lu6q8/why_does_jenkins_have_blue_balls/) or the [jenkins blog](https://jenkins.io/blog/2012/03/13/why-does-jenkins-have-blue-balls/)
342
06e3b4 343 5. Before building and deploying the Jenkins s2i; add git credentials to it. These will be used by Jenkins to access the Git Repositories where our apps will be stored. We want Jenkins to be able to push tags to it so write access is required. There are a few ways we can do this; either adding them to the `template/jenkins.yml` as environment Variables and then including them in the `params/jenkins` file.  We could also create a token in GitLab and use it as the source secret in the jenkins template. 
RH 344 But for simplicity just replace the `<USERNAME>` && `<PASSWORD>` in the `jenkins-s2i/configuration/init.groovy` with your ldap credentials as seen below. This init file gets run when Jenkins launches and will setup the credentials for use in our Jobs in the next exercises
ff1bd7 345 <p class="tip">
de8ebb 346 Note in a residency we would not use your GitCredentials for pushing and pulling from Git, A service user would be created for this.
ff1bd7 347 </p>
D 348 ```groovy
349 gitUsername = System.getenv("GIT_USERNAME") ?: "<USERNAME>"
350 gitPassword = System.getenv("GIT_PASSWORD") ?: "<PASSWORD>"
351 ```
352
de8ebb 353 5. Open the `params/jenkins-s2i` file and add the following content; replacing variables as appropriate. 
ff1bd7 354 ```
D 355 SOURCE_REPOSITORY_URL=<YOUR_ENABLEMENT_REPO>
356 NAME=jenkins
357 SOURCE_REPOSITORY_CONTEXT_DIR=jenkins-s2i
358 IMAGE_STREAM_NAMESPACE=<YOUR_NAME>-ci-cd
06e3b4 359 SOURCE_REPOSITORY_USERNAME=<BASE64_YOUR_LDAP_USERNAME>
RH 360 SOURCE_REPOSITORY_PASSWORD=<BASE64_YOUR_LDAP_PASSWORD>
ff1bd7 361 ```
D 362 where 
de8ebb 363     * `<YOUR_ENABLEMENT_REPO>` is the full path clone path of the repo where this project is stored (including the https && .git)
D 364     * `<YOUR_NAME>` is the prefix for your `-ci-cd` project.
365     * Explore some of the other parameters in `templates/jenkins-s2i.yml`
06e3b4 366     * `<BASE64_YOUR_LDAP_USERNAME>` is the base64encoded username builder pod will use to login and clone the repo with
RH 367     * `<BASE64_YOUR_LDAP_PASSWORD>` is the base64encoded password the builder pod will use to authenticate and clone the repo using
f79b6f 368 You can use `echo -n '<YOUR_LDAP_PASSWORD>' | openssl base64` to encode your username and password accordingly. For example 'password' base64 encoded will look like `cGFzc3dvcmQ=`.
de8ebb 369 <p class="tip">
D 370 Note in a residency we would not use your GitCredentials for pushing and pulling from Git, A service user would be created for this.
371 </p>
ff1bd7 372
62db52 373 5. Create a new object `ci-cd-builds` in the ansible `inventory/host_vars/ci-cd-tooling.yml` to drive the s2i build configuration.
ff1bd7 374 ```yaml
D 375   - object: ci-cd-builds
376     content:
377     - name: "jenkins-s2i"
62db52 378       namespace: "{{ ci_cd_namespace }}"
D 379       template: "{{ playbook_dir }}/templates/jenkins-s2i.yml"
380       params: "{{ playbook_dir }}/params/jenkins-s2i"
ff1bd7 381       tags:
D 382       - jenkins
383 ```
384
385 5. Commit your code to your GitLab instance
386 ```bash
de8ebb 387 $ git add .
ff1bd7 388 $ git commit -m "Adding Jenkins and Jenkins s2i"
D 389 $ git push
390 ```
391
392 5. When your code is commited; run the OpenShift Applier to add the config to the cluster
393 ```bash
06fc7b 394 $ ansible-playbook apply.yml -e target=tools \
ff1bd7 395      -i inventory/ \
D 396      -e "filter_tags=jenkins"
397 ```
398
de8ebb 399 5. This will trigger a build of the s2i and when it's complete it will add an imagestream of `<YOUR_NAME>-ci-cd/jenkins:latest` to the project. The Deployment config should kick in and deploy the image once it arrives. You can follow the build of the s2i by going to the OpenShift console's project
D 400 ![jenkins-s2i-log](../images/exercise1/jenkins-s2i-log.png)
bc2e43 401
de8ebb 402 5. When the Jenkins deployment has completed; login (using your openshift credentials) and accept the role permissions. You should now see a fairly empty Jenkins with just the seed job
3558ae 403
de8ebb 404 ### Part 4 - Jenkins Hello World 
D 405 > _To test things are working end-to-end; create a hello world job that doesn't do much but proves we can pull code from git and that our balls are green._
406
407 6. Log in to Jenkins and hit `New Item` ![new-item](../images/exercise1/new-item.png).
408
e90e9c 409 6. Create a freestyle job called `hello-world` ![jenkins-new-hello-world](../images/exercise1/jenkins-new-hello-world.png).
de8ebb 410
f79b6f 411 6. On the Source Code Management tab; add your `enablement-ci-cd` git repo and hit the dropdown to add your credentials we baked into the s2i on previous steps ![jenkins-scm-git](../images/exercise1/jenkins-scm-git.png)
de8ebb 412
D 413 6. On the build tab add an Execute Shell step and fill it with `echo "Hello World"` ![jenkins-hello-world](../images/exercise1/jenkins-hello-world.png).
414
415 6. Run the build and we should see if pass succesfully and with Green Balls! ![jenkins-green-balls](../images/exercise1/jenkins-green-balls.png)
416
417 ### Part 5 - Live, Die, Repeat
7c832b 418 > _In this section you will proove the infra as code is working by deleting your Cluster Content and recreating it all_
de8ebb 419
D 420 7. Commit your code to the new repo in GitLab
7c832b 421 ```bash
D 422 $ git add .
423 $ git commit -m "ADD - all ci/cd contents"
424 $ git push
425 ```
de8ebb 426
D 427 7. Burn your OCP content to the ground
7c832b 428 ```bash
D 429 $ oc delete project <YOUR_NAME>-ci-cd
430 $ oc delete project <YOUR_NAME>-dev
431 $ oc delete project <YOUR_NAME>-test
432 ```
de8ebb 433
7c832b 434 7. Re-apply the inventory to re-create it all!
D 435 ```bash
436 $ oc login -p <password> -u <user> <cluster_url>
437 $ ansible-playbook apply.yml -i inventory/ -e target=bootstrap
438 $ ansible-playbook apply.yml -i inventory/ -e target=tools
439 ```
c951f7 440
5d0992 441 _____
D 442
c951f7 443 ## Extension Tasks
de8ebb 444 > _Ideas for go-getters. Advanced topic for doers to get on with if they finish early. These will usually not have a solution and are provided for additional scope._
c951f7 445
3558ae 446  - Add more secure access for Nexus (ie not admin / admin123) using the automation to drive secret creation
ff1bd7 447  - Add a SonarQube persistent deployment to the `ci-cd-deployments` section.
D 448  - Add `jenkins.plugins.slack.SlackNotifier.xml` to `jenkins-s2i/configuration` to include URL of Slack for team build notifications and rebuild Jenkins S2I
c951f7 449
5d0992 450 _____
D 451
c951f7 452 ## Additional Reading
7c832b 453 > List of links or other reading that might be of use / reference for the exercise
01c4da 454
RH 455 ## Slide links
456
457 - [Intro](https://docs.google.com/presentation/d/1LsfAkH8GfIhulEoy_yd-usWBfDHnZEyQdNvYeTmAg4A/)
458 - [Wrap-up](https://docs.google.com/presentation/d/1cfyJ6SHddZNbM61oz67r870rLYVKY335zGclXN2uLMY/)
5d4563 459 - [All Material](https://drive.google.com/drive/folders/13Bt4BXf9P2OB8VI4YQNcNONF1786dqOx)