Creating and Fine-Tuning the Workflows

This topic describes how to fine-tune and arrange Workflows and Tasks (Actions) to perform a blue/green deployment.

This page includes the following:

Actions

To set up the Workflow infrastructure three main actions must be carried out:

  1. Create the Application Workflows and Component Workflows needed to move the Package from one state to the next (Deploy, Mark_Stable, Switch, and so on).
  2. Arrange the Actions and Jobs in the Component Workflows.
  3. Arrange the Component Workflows in the Application Workflows.

Watch the video:

Workflow Overview

Graphic depicting Package Stateflow Model

To Create the Workflows

The first Application Workflow "Trigger_Deployment" has been already created via the Application Wizard. This Workflow will be used to determine which endpoint is available at the time of deployment based on the Profile (green or blue). Let us now create the other Application Workflows:

  1. Open the BLUE_GREEN_APP Application.
  2. Go to Workflows > All Workflows.
  3. Click the Create icon in the toolbar.
  4. Name the Workflow "Deploy". This Workflow will be used to deploy the Application on a set of Targets.
  5. Select the Install type.
  6. Select the BLUE_GREEN_APP Application.
  7. Store the Workflow in the same folder where the "Trigger_Deployment" Workflow is located. For example: BLUE_GREEN.
  8. Click Create.
  9. Repeat steps 3-7 to create more Application Workflows:
    NameTypeFolderDescription
    SwitchInstallBLUE_GREENSwitches the routed traffic to the new installation.
    Switch_BackInstallBLUE_GREENSwitches the routed traffic back to the previous installation.
    Mark_StableInstallBLUE_GREENMarks the Package as "stable" in the production version.
    Trigger_UndeployInstallBLUE_GREENTriggers the "Undeploy_environment" Workflow based on the current Package Profile (green or blue).
    Undeploy_EnvironmentInstallBLUE_GREENUndeploys the Application from the current set of Targets.

    These Workflows will be used to move the Package to the next state in the stateflow.

  10. Let us now create the Subworkflows (Component Workflows) which will make up the different tasks of the previously defined Application Workflows. Follow the steps below:

    1. Open the Release Automation perspective and click the Workflows tab in the sidebar.
    2. Click the Create button in the toolbar. The Create Workflow dialog is displayed.
    3. Name the first Component Workflow "Database".
    4. Select the Install type.
    5. Select the BLUE_GREEN_APP Application.
    6. Save the Workflow in the same folder where you stored the Application Workflows (for example, BLUE_GREEN).
    7. Click Create.
    8. Repeat the previous steps to create the other Component Workflows which will make up the "Deploy" Application Workflow:
      NameTypeFolderDescription
      CREATE_IMAGEInstallBLUE_GREENThe Docker image Component Packages the necessary infrastructure.
      DEPLOY_IMAGEInstallBLUE_GREENSpins up the Docker image.
      GeneralInstallBLUE_GREENChanges the Package state and sets the variables in the Environment.
    9. Component Workflows needed for the "Trigger_Deployment" Application Workflow:
      NameTypeFolderDescription
      General1InstallBLUE_GREENDetermines which Profile can be used to deploy the Application.
    10. Component Workflows needed for the "Switch" Application Workflow:
      NameTypeFolderDescription
      Load_BalancerInstallBLUE_GREENSwitches the load balancer from "green" to "blue" (and vice versa).
    11. Component Workflows needed for the "Switch_Back" Application Workflow:
      NameTypeFolderDescription
      Load_BalancerInstallBLUE_GREENSwitches the load balancer from "green" to "blue" (and vice versa).
    12. Component Workflows needed for the "Mark_Stable" Application Workflow:
      NameTypeFolderDescription
      General1InstallBLUE_GREENMarks the installed version as "stable". Traffic is routed. As of now, changes will be deployed to the Targets assigned to the other Profile.
    13. Component Workflows needed for the "Trigger_Undeploy" Application Workflow:
      NameTypeFolderDescription
      General1InstallBLUE_GREENUsed to determine which Profile can be used to undeploy the Application.
    14. Component Workflows needed for the "Undeploy_environment" Application Workflow:
      NameTypeFolderDescription
      ApplicationInstallBLUE_GREENRemoves the Docker container from the Environment.

To Arrange Workflows and Actions

After creating the Application and Component Workflows, add specific Actions and Jobs to the Component Workflows and arrange them in a logical order.

  1. First, add and arrange the appropriate Actions within each Component Workflow:

    • Deploy Application Workflow (determines which endpoint is available at the time of deployment based on the Profile - green or blue).

      1. Database Component Workflow.

        1. Drag-and-drop the following Actions to the editor:

          Name Title Description
          PCK.AUTOMIC_MSSQL.PUB.ACTION.CREATE_DB Create Database Creates a specific database.
          PCK.AUTOMIC_TEXT.PUB.ACTION.REPLACE_TEXT Text replace text Replaces a selected text.
          PCK.AUTOMIC_JDBC:PUB.ACTION.EXECUTE_SQL_SCRIPT DB Execute Script Executes a SQL script located on the agent host.
          PCK.AUTOMIC_JDBC:PUB.ACTION.EXECUTE_SQL_SCRIPT DB Execute Script Executes a SQL script located on the agent host.
          PCK.AUTOMIC_JDBC:PUB.ACTION.EXECUTE_SQL_SCRIPT DB Execute Script Executes a SQL script located on the agent host.
        2. Arrange the Actions in the editor to resemble the screenshot below:

          Graphic displaying actions in component workflow

          The first component deployed by the Workflow is the Application MSSQL Database. This process is straight forward. First, a new database is created with the MSSQL Action Pack. While the database is being created, an update to one of the SQL scripts runs in parallel. After this, the scripts are executed in the correct order.

        The second component to be deployed is a Docker container to host the Application. Deploying this component is a two-step process. The first step is creating the image. The second one is deploying it.

      2. CREATE_IMAGE Component Workflow (used to make the "Docker image" Component Package the necessary infrastructure):

        1. Drag-and-drop the following Actions to the editor and name them as follows:

          Name Title Description
          PCK.AUTOMIC_DOCKER.PUB.ACTION.CREATE_IMAGE Pull an image from public docker repository This action is used to create an image by pulling it from the docker public repository. By default the Image tag value is 'latest'.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.CREATE_DIR CREATE_PERSISTENT_DIR Creates a persistent directory.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.CREATE_DIR CREATE_BUILD_DIRECTORY Creates a new build directory.
          PCK.AUTOMIC_DOCKER.PUB.ACTION.CREATE_CONTAINER Create container from existing image Creates a container in the docker system from an existing image.
          PCK.AUTOMIC_AGENT_2_AGENT.PUB.ACTION.TRANSFER TRANSFER_NEW_VERSION_FILES Transfers one or more files from one host to another host using the agent-to-agent file transfer mechanism.
          PCK.AUTOMIC_DOCKER.PUB.ACTION.START_CONTAINER START_CONTAINER Starts an existing container as per the specified container id.
          PCK.AUTOMIC_DOCKER.PUB.ACTION.CHANGE_CONTAINER_STATE STOP_CONTAINER_AFTER_WAR_FILE_EXPLODED Changes the state of an existing container to stop.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.COPY COPY_CONFIG_FILE Copies the configuration file.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.COPY COPY_DRIVER Copies the driver.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.COPY COPY_APPLICATION_TAR_TO_BUILD_DIRECTORY Copies the Application tar to the build directory.
          PCK.AUTOMIC_TEXT.PUB.ACTION.REPLACE_TEXT EDIT_DATABASE_CONNECTION_SETTINGS Replaces the values in database connection settings.
          PCK.AUTOMIC_TEXT.PUB.ACTION.REPLACE_TEXT Text replace text Replaces the text in the image index file.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.PACK TAR_APPLICATION Archives the tar Application file with all subitems.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.PACK TAR_DOCKERFILE_AND_APPLICATION Archives the docker and Application file with all subitems.
          PCK.AUTOMIC_DOCKER.PUB.ACTION.BUILD_IMAGE Build image from Dockerfile Creates a Docker Image from the Docker file
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.DELETE File Delete Deletes the file.
        2. Arrange the Actions in the editor to resemble the screenshot below:

          Select the image to expand it.

          Graphic displaying actions in component workflow

          First, the Workflow pulls a Docker image from a public Docker repository. Then, the Workflow runs a file delete on the previous image directory. Usually this directory is located under /data/ARA/image on the container. When this action is completed, a persistent directory is created under the same path.

          After the image is ready, the Docker Action Pack is used to create a container from the existing pulled image and copy over the war file, driver, and connection string from the database to the Tomcat container. Once the files are placed correctly, the container is started up, so that the copied war file explodes. After one minute, the container is stopped. This clause is triggered with a precondition:

          Image displaying precondition

          As a next step, the Workflow edits the database connection string so that it is possible to connect to the correct database in the BLUE_GREEN Application. After the connection string has been fixed, the index.html file welcome message is changed.

          Finally, the Workflow "TARs up" the Application and Docker file after cleaning up the directories one last time.

      3. DEPLOY_IMAGE Component Workflow (used to spin up the Docker image):

        1. Drag-and-drop the following Actions to the editor and name them as follows:

          Name Title Description
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.COPY COPY_TEMPLATE_AS_TEMPORARY Copies the template.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.REPLACE_TEXT SET_IMAGE_NAME Sets the name of the image.
          PCK.AUTOMIC_TEXT.PUB.ACTION.REPLACE_TEXT SET_PORT_ON_HOST Opens the port needed to connect.
          PCK.AUTOMIC_DOCKER.PUB.ACTION.CREATE_CONTAINER Create container from existing image Creates a new container.
          PCK.AUTOMIC_FILESYSTEM.PUB.ACTION.DELETE DELETE_TEMPLATE_TEMPORARY Deletes the temporary template.
          PCK.AUTOMIC_DOCKER.PUB.ACTION.START_CONTAINER Start existing container Starts an existing container as per the specified container id.
          PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in ARA.

        2. Arrange the Actions in the editor to resemble the screenshot below:

          Image displaying actions in component workflow

          The first Action copies over the docker_template_tomcat file. After that, the second Action sets the name for the image. The third job will then open the port needed to connect. Once this is done, the container is created. The temporary template is deleted and the new container is booted. Finally, some Dynamic Properties are set on the Environment to define the current booted container ID on it.

      4. General Component Workflow. (This Workflow is used to change the Package state):

        1. Drag-and-drop the following Action to the editor and name it as follows:

          Name Title Description
          PCK.AUTOMIC_DM.PUB.ACTION.PackagesTATE_SET DM Set Package State Changes the Package State and sets Variables in the Environment.
        2. Arrange the Subworkflow in the editor to resemble the screenshot below:

          Image displaying subworkflow

    • Trigger_Deployment Application Workflow (deploys the Application on a set of Targets). This Workflow starts once the Package has been moved from the "Active" to the "Deploy" state. A DM job is used to trigger the Deploy Workflow once the Package states have been updated.

      1. Open the DM Set Package State Workflow, drag-and-drop the following Actions to the editor and name them as follows:

        Name Title Description
        PCK.AUTOMIC_DM.PUB.ACTION.GET_DYNAMIC_PROPERTY DM Get Dynamic Property Retrieves the value of a specified Dynamic Property in CDA (blue/green).
        PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in CDA (blue/green)
        PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in CDA (blue/green)
        PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in CDA (blue/green)
        PCK.AUTOMIC_DM.PUB.ACTION.EXECUTE_APPLICATION_WORKFLOW DM Execute Application Workflow Executes the deploy Application Workflow.
      2. Arrange the actions in the editor to resemble the screenshot below.

        Image displaying actions in component workflow

    • Switch Application Workflow (switches the load balancer from the "green" Profile to the "blue" one and vice versa).

      1. Load_Balancer Component Workflow.

        1. Drag-and-drop the following Actions to the editor and name them as follows:

          Name Title Description
          PCK.AUTOMIC_TEXT.PUB.ACTION.REPLACE_TEXT Text replace text Replaces the "green" text to "blue" and vice versa (jpetstore file).
          NGINX   Job used to reload Nginx, the web server software used for this scenario as load balancer.
          PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DB Set Dynamic Property Updates the Dynamic Property.
          PCK.AUTOMIC_DM.PUB.ACTION.PackagesTATE_SET DB Set Package State Set the state of the Package by using its ID.
        2. Arrange the Actions in the editor to resemble the screenshot below:

          Image displaying actions in component workflow

          This Workflow changes the jpetstore file in /etc/nginx/sites-available/jpetstoreusing a text replace action. After this, Nginx is reloaded using a custom Unix action. Then, the Dynamic Properties and Package state are updated to reflect the change that the Package has gone through.

    • Switch_Back Application Workflow (switches the routed traffic back to the previous installation). The Switch_Back Workflow works in the same way as the Switch Workflow. However, its used at a different Package state.

      Once the Package has successfully gone live to the first Target using the above Switch Workflow it can be switched back to the previous Target.

      1. Load_Balancer Component Workflow.

        1. Drag-and-drop the following Actions and Jobs to the editor and name them as follows:

          Name Title Description
          PCK.AUTOMIC_TEXT.PUB.ACTION.REPLACE_TEXT Text replace text Replaces the green text to blue and vice versa (jpetstore file).
          NGINX   Job used to reload Nginx, the web server software used for this scenario as load balancer.
          PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DB Set Dynamic Property Updates Dynamic Property.
          PCK.AUTOMIC_DM.PUB.ACTION.PackagesTATE_SET DB Set Package State Set the state of the Package by using its ID.
        2. Arrange the Actions in the editor to resemble the screenshot below:

          Image displaying actions in component workflow

    • Mark_Stable Workflow (marks the Package as "stable" in the production version).

      1. General Component Workflow.

        1. Drag-and-drop the following Actions to the editor and name them as follows:

          Name Title Description
          PCK.AUTOMIC_DM.PUB.ACTION.PackagesTATE_SET DM Set Package State Sets the state of a specified Package using its ID.
          PCK.AUTOMIC_DM.PUB.ACTION.PackagesTATE_SET DM Set Package State Sets the state of a specified Package using its ID.
          PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in ARA.
          PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in ARA.
          PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in ARA.
        2. Arrange the Actions in the editor to resemble the screenshot below:

          Image displaying actions in component workflow

    • Trigger_Undeploy Workflow. Triggers the "Undeploy_environment" Workflow based on the current Package Profile (green or blue).

      1. General Component Workflow.

        Drag-and-drop the following Actions to the editor and name them as follows:

        Name Title Description
        PCK.AUTOMIC_DM.PUB.ACTION.GET_DYNAMIC_PROPERTY DM Get Dynamic Property Retrieves the value of a specified Dynamic Property in CDA (blue/green).
        PCK.AUTOMIC_DM.PUB.ACTION.EXECUTE_APPLICATION_WORKFLOW DM Execute Application Workflow Executes the deploy Application Workflow.
        PCK.AUTOMIC_DM.PUB.ACTION.PackagesTATE_SET DM Set Package State Sets the state of a specified Package using its ID.
        PCK.AUTOMIC_DM.PUB.ACTION.PackagesTATE_SET DM Set Package State Sets the state of a specified Package using its ID.
        PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in ARA.
        PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in ARA.
      2. Arrange the Actions in the editor to resemble the screenshot below:

        Image displaying actions in component workflow

    • Undeploy_environment Workflow (undeploys the Application from the current set of Targets).

      1. Application Component Workflow.

        Drag-and-drop the following Actions to the editor and name them as follows:

        Name Title Description
        PCK.AUTOMIC_DOCKER.PUB.ACTION.REMOVE_CONTAINER Remove an existing container Removes the container from the Environment.
        PCK.AUTOMIC_DM.PUB.ACTION.SET_DYNAMIC_PROPERTY DM Set Dynamic Property Sets the value of a given Dynamic Property in ARA.
      2. Arrange the Actions in the editor to resemble the screenshot below:

        Image displaying actions in component workflow

        Note: The Remove an existing container task contains a precondition stating that if the Package has no Id it can be skipped. This prevents the Workflow from removing incorrect containers.

        Image displaying preconditions

    You are almost there! The last step will be to arrange the Component Workflows within the Application Workflows.

  2. Second, add and arrange the Component Workflows in the Application Workflows.

    1. Deploy Workflow: this Workflow is designed to deploy the Application into an Environment. It consists of four different Subworkflows. Arrange them as follows:

      Image displaying component workflows in application workflow

      1. Database: makes changes to the database.
      2. CREATE_IMAGE: creates a Docker image.
      3. DEPLOY_IMAGE: deploys the Docker image.
      4. General: sets the Package state.
    2. Trigger_Deployment Workflow: this Workflow will be used to determine which endpoint is available at the time of deployment based on the Profile (green or blue). It triggers the deploy Workflow and consists of only one Component Workflow (General1):

      Image displaying component workflow in application workflow

    3. Switch Workflow: this Workflow will be used to switch the load balancer and make the Blue or Green Endpoints live and available.

      Image displaying component workflow in application workflow

      • Load Balancer: switches the load balancer from "green" to "blue" (and vice versa).
    4. Switch_Back Workflow: switches the routed traffic back to the previous installation. It consists of one Component Workflow: "Load_Balancer"

      Image displaying component workflow in application workflow

      • Load Balancer: switches the load balancer from "green" to "blue" (and vice versa).
    5. Mark_Stable Workflow: marks the Package as stable in the production version. It consists of one Component Workflow: (General1).

      Image displaying component workflow in application workflow

      • General1: marks the installed version as "stable". Traffic is routed. As of now, changes will be deployed to the Targets assigned to the other Profile.
    6. Trigger_Undeploy Workflow: triggers the "Undeploy_environment" Workflow based on current Package Profile (green or blue). It consists of one Component Workflow (General1).

      Image displaying component workflow in application workflow

    7. Undeploy_Environment Workflow. It consists of one Component Workflow (Application):

      Image displaying component workflow in application workflow

      • Application Workflow: removes the Docker container from the Environment.

Next steps:

  1. Assigning Workflows to Package States

Previous steps:

  1. Creating a new Package Type and Defining Package States
  2. Creating the Application with the Wizard
  3. Defining the "Green" Profile
  4. Fine-Tuning the Environment
  5. Fine-Tuning the Components