diff --git a/exercises/ansible_rhel/2.6-workflows/README.md b/exercises/ansible_rhel/2.6-workflows/README.md index 4e136d297..3f91755f0 100644 --- a/exercises/ansible_rhel/2.6-workflows/README.md +++ b/exercises/ansible_rhel/2.6-workflows/README.md @@ -1,9 +1,9 @@ # Workshop Exercise - Workflows -**Read this in other languages**: -
![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md). +**Read this in other languages**: +![uk](../../../images/uk.png) [English](README.md), ![japan](../../../images/japan.png)[日本語](README.ja.md), ![brazil](../../../images/brazil.png) [Portugues do Brasil](README.pt-br.md), ![france](../../../images/fr.png) [Française](README.fr.md), ![Español](../../../images/col.png) [Español](README.es.md). -## Table Contents +## Table of Contents * [Objective](#objective) * [Guide](#guide) @@ -15,16 +15,14 @@ ## Objective -The basic idea of a workflow is to link multiple Job Templates together. They may or may not share inventory, playbooks or even permissions. The links can be conditional: +The purpose of a workflow is to link multiple job templates together. These templates may or may not share inventory, playbooks, or permissions. The links can be conditional: -* if job template A succeeds, job template B is automatically executed afterwards -* but in case of failure, job template C will be run. +* If Job Template A succeeds, Job Template B is executed next. +* If it fails, Job Template C runs instead. -And the workflows are not even limited to Job Templates, but can also include project or inventory updates. +Workflows can include not only job templates but also project or inventory updates. -This enables new applications for Ansible automation controller: different Job Templates can build upon each other. E.g. the networking team creates playbooks with their own content, in their own Git repository and even targeting their own inventory, while the operations team also has their own repos, playbooks and inventory. - -In this lab you’ll learn how to setup a workflow. +This flexibility allows different teams to collaborate efficiently. For example, a networking team can manage its own repositories and inventories, while an operations team handles other aspects. In this lab, you’ll learn how to set up a workflow. ## Guide @@ -32,38 +30,35 @@ In this lab you’ll learn how to setup a workflow. You have two departments in your organization: -* The web operations team that is developing playbooks in their own Git branch named `webops` -* The web developers team that is developing playbooks in their own Git branch named `webdev`. - -When there is a new Node.js server to deploy, two things need to happen: +* **Web operations team:** developing playbooks in their Git branch `webops`. +* **Web developers team:** working in their branch `webdev`. -#### Web operations team +When a new Node.js server is needed, the following tasks must be performed: -* `httpd`, `firewalld`, and `node.js` need to be installed, `SELinux` settings configured, the firewall needs to be opened, and `httpd` and `node.js` should get started. +#### Web operations team tasks -#### Web developers team +* Install `httpd`, `firewalld`, and `node.js`. +* Configure `SELinux` settings, open the firewall, and start `httpd` and `node.js`. -* The most recent version of the web application needs to be deployed and `node.js` needs to be restarted. +#### Web developers team tasks -In other words, the Web operations team prepares a server for application deployment, and the Web developers team deploys the application on the server. +* Deploy the latest version of the web application and restart `node.js`. ---- +The web operations team sets up the server, and the developers deploy the application. -To make things somewhat easier for you, everything needed already exists in a Github repository: playbooks, JSP-files etc. You just need to glue it together. +> **Note:** +> For this example, both teams use branches of the same Git repository. In a real scenario, your source control structure may vary. -> **Note** -> -> In this example we use two different branches of the same repository for the content of the separate teams. In reality, the structure of your Source Control repositories depends on a lot of factors and could be different. +--- ### Set up projects -First you have to set up the Git repo as a Project like you normally would. +First, set up the Git repositories as projects. -> **Warning** -> -> If you are still logged in as user **wweb**, log out of and log in as user **admin**. +> **Warning:** +> If logged in as **wweb**, log out and log in as **admin**. -Within **Resources** -> **Projects**, click the **Add** button to create a project for the web operations team. Fill out the form as follows: +Within **Automation Execution** -> **Projects**, click **Create Project** to set up the web operations team’s project: @@ -78,20 +73,20 @@ Within **Resources** -> **Projects**, click the **Add** button to create a proje - - + + - + - + - + @@ -100,11 +95,11 @@ Within **Resources** -> **Projects**, click the **Add** button to create a proje
Organization Default
Default Execution Environment
Execution Environment Default execution environment
Source Control Credential TypeSource control type Git
Source Control URLSource control URL https://github.com/ansible/workshop-examples.git
Source Control Branch/Tag/CommitSource control branch/tag/commit webops
-Click **Save** +Click **Create project**. ---- -Within **Resources** -> **Projects**, click the **Add** button to create a project for the web developers team. Fill out the form as follows: +![create_project](images/create_project.png) +Repeat the process to set up the **Webdev Git Repo**, using the branch `webdev`. @@ -118,20 +113,20 @@ Within **Resources** -> **Projects**, click the **Add** button to create a proje - - + + - + - + - + @@ -140,179 +135,89 @@ Within **Resources** -> **Projects**, click the **Add** button to create a proje
ParameterOrganization Default
Default Execution Environment
Execution Environment Default execution environment
Source Control Credential TypeSource control type Git
Source Control URLSource control URL https://github.com/ansible/workshop-examples.git
Source Control Branch/Tag/CommitSource control branch/tag/commit webdev
-Click **Save** +--- ### Set up job templates -Now you have to create two Job Templates like you would for "normal" Jobs. +Within **Automation Execution** -> **Templates** -> **Create template** -> **Create job template**, fill out the form with the following values: -Within **Resources** -> **Templates**, click the **Add** button and choose **Add job template**: + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterValue
NameWeb App Deploy
InventoryWorkshop Inventory
ProjectWebops Git Repo
Playbookrhel/webops/web_infrastructure.yml
Execution EnvironmentDefault execution environment
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterValue
NameWeb App Deploy
Job TypeRun
InventoryWorkshop Inventory
ProjectWebops Git Repo
Execution EnvironmentDefault execution environment
Playbookrhel/webops/web_infrastructure.yml
CredentialsWorkshop Credential
Limitweb
Options✓ Privilege Escalation
+![create_template_webops](images/create_template_webops.png) -Click **Save** +Click **Create job template**, and then repeat the process for the **Node.js Deploy** template, changing the project to **Webdev Git Repo** and the playbook to `rhel/webdev/install_node_app.yml`. --- -Within **Resources** -> **Templates**, click the **Add** button and choose **Add job template**: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParameterValue
NameNode.js Deploy
Job TypeRun
InventoryWorkshop Inventory
ProjectWebdev Git Repo
Execution EnvironmentDefault execution environment
Playbookrhel/webdev/install_node_app.yml
CredentialsWorkshop Credential
Limitweb
Options✓ Privilege Escalation
- -Click **Save** - -> **Tip** -> -> If you want to know what the Ansible Playbooks look like, check out the Github URL and switch to the appropriate branches. - ### Set up the workflow -Workflows are configured in the **Templates** view, you might have noticed you can choose between **Add job template** and **Add workflow template** when adding a template. - -Within **Resources** -> **Templates**, click the **Add** button and choose **Add workflow template**: - - - - - - - - - - -
NameDeploy Webapp Server
OrganizationDefault
- -Click **Save** - -After saving the template the **Workflow Visualizer** opens to allow you to build a workflow. You can later open the **Workflow Visualizer** again by using the button on the template details page and selecting **Visualizer** from the menu. - - ![start](images/start.png) +Within **Automation Execution** -> **Templates** -> **Create template** -> **Create workflow job template**, fill in the details: -Click on the **Start** button, an **Add Node** window opens. Assign an action to the node, via node type by selecting **Job Template**. + + + + + + + + + +
ParameterValue
NameDeploy Webapp Server
-Select the **Web App Deploy** job template and click **Save**. +Click **Create workflow job template** to open the **Workflow Visualizer**. - ![Add Node](images/add_node.png) +![add_step](images/visualizer_add_step.png) -A new node is shown, connected to the **START** button with the name of the job template. Hover the mouse pointer over the node, you’ll see options to add a node (+), view node details (i), edit the node (pencil), link to an available node (chain), and delete the node (trash bin). +Click the **Add Step** button and assign the **Web App Deploy** job template to the first node. Add a second node by clicking the 3 dot sign, selecting the "Add step and link" and assign the **Node.js Deploy** template with the **Run on success** status type. Select **Next** and **Finish** to complete the workflow. - ![workflow node](images/workflow_node.png) +![app_deploy](images/visualizer_add_step_app_deploy.png) -Hover over the node and click the (+) sign to add a new node. -* For the **Run Type** select **On Success** (default) and click **Next**. +![add_link](images/visualizer_add_step_add_link.png) -> **Tip** -> -> The run type allows for more complex workflows. You could lay out different execution paths for successful and for failed playbook runs. +![add_nodejs](images/visualizer_add_step_nodejs.png) -* For **Node Type** select **Job Template** (default) and choose the **Node.js Deploy** job template. -Click **Save**. +Click **Save** to finalize the workflow. - ![Add Nodejs](images/add_node_nodejs.png) -Click **Save** in the top right corner of the **Visualizier** view. +![overview](images/visualizer_overview.png) -> **Tip** -> -> The **Visualizer** has options for setting up more advanced workflows, please refer to the documentation. +--- ### Launch workflow -From within the **Deploy Webapp Server** Details page, **Launch** the workflow. - - ![launch](images/launch.png) - -Note how the workflow run is shown in the Jobs > Deploy Webapp Server Output. In contrast to a normal job template job execution, there is no playbook output when the job completes but the time to complete the job is displayed. If you want to look at the actual playbook run, hover over the node you wish to see the details on and click it. Within the Details view of the job, select the **Output** menu to see the playbook output. If you want to get back the **Output** view of the **Deploy WebappServer** workflow, under Views -> Jobs -> **XX - Deploy Webapp Server** will take you back to the Output overview. - -NOTE: Where `XX` is the number of the job run. +Within the **Deploy Webapp Server** template, click **Launch template**. -![jobs view of workflow](images/job_workflow.png) +![launch_template](images/launch_template.png) -After the job was finished, check if everything worked fine: from your control host run the following curl command against `node1`, `node2` and `node3`. The output of each curl command should be `Hello World`. +Once the workflow completes, verify the results by checking the job details. Run the following command on the control host to confirm the deployment: ```bash -[student@ansible-1 ansible-files]$ curl http://nodeX/nodejs +curl http://nodeX/nodejs Hello World ``` diff --git a/exercises/ansible_rhel/2.6-workflows/images/create_project.png b/exercises/ansible_rhel/2.6-workflows/images/create_project.png new file mode 100644 index 000000000..679cbd062 Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/create_project.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/create_template_webdev.png b/exercises/ansible_rhel/2.6-workflows/images/create_template_webdev.png new file mode 100644 index 000000000..8ceeebe88 Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/create_template_webdev.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/create_template_webops.png b/exercises/ansible_rhel/2.6-workflows/images/create_template_webops.png new file mode 100644 index 000000000..19d8cb578 Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/create_template_webops.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/launch_template.png b/exercises/ansible_rhel/2.6-workflows/images/launch_template.png new file mode 100644 index 000000000..f094a78af Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/launch_template.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step.png b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step.png new file mode 100644 index 000000000..5efb23b85 Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_add_link.png b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_add_link.png new file mode 100644 index 000000000..88e25ee72 Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_add_link.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_app_deploy.png b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_app_deploy.png new file mode 100644 index 000000000..93193c068 Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_app_deploy.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_nodejs.png b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_nodejs.png new file mode 100644 index 000000000..3a3c8d262 Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/visualizer_add_step_nodejs.png differ diff --git a/exercises/ansible_rhel/2.6-workflows/images/visualizer_overview.png b/exercises/ansible_rhel/2.6-workflows/images/visualizer_overview.png new file mode 100644 index 000000000..8a2c5195d Binary files /dev/null and b/exercises/ansible_rhel/2.6-workflows/images/visualizer_overview.png differ