Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from f5devcentral/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
chen23 committed Apr 3, 2017
2 parents 417054d + 936eb0f commit 36f54e2
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ also be leveraged to provide Service Catalog of L4-L7 services.

.. toctree::
:maxdepth: 2
:caption: Lab 4: Using Jenkins to Orchestrate
:caption: Lab 4: Using Jenkins to Automate

lab4/lab4_guide.rst

Expand All @@ -64,6 +64,12 @@ The goal of this lab is to demonstrate how complex automation tasks can be hidde
In this case the deployment is in UDF 2.0. Running through the Lab demonstrates how easy it is to change the destination
to AWS or Azure or private cloud environments with keeping the shim layer unchanged.

.. toctree::
:maxdepth: 2
:caption: Lab 5: Using Jenkins to Orchestrate

lab5/lab5_guide.rst

Indices and tables
==================

Expand Down
2 changes: 2 additions & 0 deletions docs/lab3/scripted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ An excerpt of the script that performs Lab 2 (create a DNS Sync Group):
There is the same number of steps involved, but one-click!

The full script can be found on `GitHub <https://github.com/f5devcentral/f5-dns-automation-demo-12-1-x/blob/master/f5-udf-2.0/udf.sh>`_.

Exploring the Demo
==================

Expand Down
204 changes: 204 additions & 0 deletions docs/lab5/lab5_guide.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
Jenkins Pipeline
================

During the prior lab :doc:`../lab4/lab4_guide` Jenkins was used to provide a frontend tool to launch the automation scripts from :doc:`../lab3/scripted`.

This lab will leverage Jenkins Pipeline to create a workflow that will validate the individual steps that are executing in a more declarative manner.

Restoring the BIG-IP Configuration
==================================

This step is to cleanup the BIG-IP config that was created in prior Labs.
RDP into the Windows jump host.

Reset both BIG-IP to be the same state as after Lab 1.

Find the "Resetting" links on the Desktop.

.. image:: ../lab1/resetting-links.png
:scale: 75%
:align: center

Double-click on both of these and you should see a window appear briefly like the following.

.. image:: ../lab1/resetting-bigip.png
:scale: 50%
:align: center

Verify that you no longer see the changes that were previously deployed.

Creating a pipeline
===================

Jenkins allows you to put together a collection of actions, branch on conditions, and measure the results.

This can be put together to put together a series of stages.

* Stage 1: Enable DNS Sync
* Stage 2: Cluster DNS Devices
* Stage 3: Add additional DNS Configuration
* Stage 4: Import App Svcs iApp Template
* Stage 5: Deploy App Svcs iApp Template
* Stage 6: Add DNS Configuration
* Stage 7: Verify Configuration

To describe these stages we can create a "Jenkinsfile" that will instruct Jenkins to execute these stages.

The following will pull down a copy of the scripts used in this lab and execute the steps to create a DNS cluster.

.. code-block:: groovy
stage('clone git repo') {
node {
git url: 'https://github.com/f5devcentral/f5-dns-automation-demo-12-1-x.git', branch:'master'
}
}
stage('enable dns sync') {
node {
dir ('lib') {
sh 'python bigip_dns_helper.py --host=10.1.1.7 --action enable_sync'
sh 'python bigip_dns_helper.py --host=10.1.1.7 --action add_datacenter --datacenter SUBNET_10'
sh 'python bigip_dns_helper.py --host=10.1.1.7 --action add_datacenter --datacenter SUBNET_30'
sh 'python bigip_dns_helper.py --host=10.1.1.7 --action add_server --datacenter SUBNET_10 --server_name bigip1 --server_ip=10.1.10.240'
sh 'python bigip_dns_helper.py --host=10.1.1.7 --action add_server --datacenter SUBNET_30 --server_name bigip2 --server_ip=10.1.30.240'
sh 'python bigip_dns_helper.py --host=10.1.1.7 --action save_config'
}
}
}
stage('gtm add') {
node {
dir ('lib') {
sh 'sleep 3'
sh 'python bigip_dns_helper.py --host=10.1.1.8 --action gtm_add --peer_host=10.1.1.7 --peer_selfip 10.1.10.240'
sh 'sleep 3'
}
}
}
The full code can be found on `GitHub <https://github.com/f5devcentral/f5-dns-automation-demo-12-1-x/blob/master/f5-udf-2.0/Jenkinsfile>`_.

Launching the pipeline
======================

After both BIG-IP are active again open Chrome in the RDP Session and click on the Jenkins link.

.. image:: ../lab4/Jenkins-link.png
:scale: 50%
:align: center

Login to the jenkins server.
The credentials are on the RDP Desktop in the "Jenkins credentials.txt" file.

After login to the Jenkins Web interface, please note the UDF-demo-pipeline folder.

.. image:: udf-demo-pipeline-folder.png
:scale: 75%
:align: center

Click on "UDF-demo-pipeline" and you should see.

.. image:: udf-demo-pipeline-page.png
:scale: 50%
:align: center

In order to run the project click on the left side the "Build Now" link. While the build is running you will see.

.. image:: udf-demo-pipeline-running.png
:scale: 50%
:align: center

When the pipeline is complete you will see:

.. image:: udf-demo-pipeline-finished.png
:scale: 50%
:align: center

Failing Tests
=============

In the previous exercise we deployed a successful deployment. In this exercise we will purposely break the pipeline.

Reset both BIG-IP to be the same state as after Lab 1.

Find the "Resetting" links on the Desktop.

.. image:: ../lab1/resetting-links.png
:scale: 75%
:align: center

Double-click on both of these and you should see a window appear briefly like the following.

.. image:: ../lab1/resetting-bigip.png
:scale: 50%
:align: center

Verify that you no longer see the changes that were previously deployed.

Go back to the 'UDF-demo-pipeline' page.

.. image:: udf-demo-pipeline-page.png
:scale: 50%
:align: center

This time click on the "Configure" link.

Find the "Pipeline" section.

.. image:: udf-demo-pipeline-configure-pipeline.png
:scale: 50%
:align: center

Select the pulldown for "Pipeline script from SCM" and change to "Pipeline Script".

Go to `GitHub <https://raw.githubusercontent.com/f5devcentral/f5-dns-automation-demo-12-1-x/master/f5-udf-2.0/Jenkinsfile>`_ and copy the text into your clipboard.

Paste the contents into the script text area.

Comment out the following lines (around line 100).

.. code-block:: groovy
//sh 'python bigip_dns_helper.py --host 10.1.1.7 --action create_topology_record --name "ldns: region /Common/region_1 server: region /Common/region_1"'
//sh 'python bigip_dns_helper.py --host 10.1.1.7 --action create_topology_record --name "ldns: region /Common/region_2 server: region /Common/region_2"'
//sh 'python bigip_dns_helper.py --host 10.1.1.8 --action create_topology_record --name "ldns: region /Common/region_1 server: region /Common/region_1"'
//sh 'python bigip_dns_helper.py --host 10.1.1.8 --action create_topology_record --name "ldns: region /Common/region_2 server: region /Common/region_2"'
The result should look something like:

.. image:: udf-demo-pipeline-configure-pipeline-comment-out.png
:scale: 50%
:align: center

Now click on the Save Button.

.. image:: save-button.png
:scale: 75%
:align: center

Back on the pipeline page find the "Build Now" link and click on it.

.. image:: udf-demo-pipeline-finished.png
:scale: 50%
:align: center

Once the build completes you should see a failure.

.. image:: udf-demo-pipeline-failure.png
:scale: 50%
:align: center

Hover your mouse over the failure.

.. image:: udf-demo-pipeline-failure-hover.png
:scale: 75%
:align: center

Click on "Logs" to see the detail and expand the failing task.

Hover your mouse over the failure.

.. image:: udf-demo-pipeline-failure-detail.png
:scale: 75%
:align: center

In this case the script "test-internal.py" exited with a non-zero exit code. This causes Jenkins to treat this as a failure. In this case the script was only expecting to see responses from a single Data Center and instead received responses from both Data Centers due to the lack of topology records.
Binary file added docs/lab5/save-button.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lab5/udf-demo-pipeline-failure-detail.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lab5/udf-demo-pipeline-failure-hover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lab5/udf-demo-pipeline-failure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lab5/udf-demo-pipeline-finished.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lab5/udf-demo-pipeline-folder.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lab5/udf-demo-pipeline-page.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lab5/udf-demo-pipeline-running.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36f54e2

Please sign in to comment.