Commit c92c10fe authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feat/deployment-strategy' into 'master'

feat(deploy): redesign deployment strategy

See merge request to-be-continuous/ansible!44
parents 99cd1225 5ee6042e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -323,7 +323,7 @@ Here are variables supported to configure the staging environment:
| ------------------------------- | -------------------------------------------------- | --------------------------------------------------------- |
| `ANSIBLE_PROD_APP_NAME`         | Application name for `production` env  | `$ANSIBLE_BASE_APP_NAME` |
| `ANSIBLE_PROD_ENVIRONMENT_URL`  | The production environment url _(only define for static environment URLs declaration and if different from default)_ | `$ANSIBLE_ENVIRONMENT_URL` |
| `AUTODEPLOY_TO_PROD`            | Set this variable to auto-deploy to production. If not set deployment to production will be manual (default behaviour). | **has to be defined to enable automatic prod deployment** |
| `ANSIBLE_PROD_DEPLOY_STRATEGY`  | Defines the deployment to production strategy. One of `manual` (i.e. _one-click_) or `auto`. | `manual` |
| `ANSIBLE_PROD_INVENTORY`        | The inventory for `production` env                 | `$ANSIBLE_DEFAULT_INVENTORY`                              |
| `ANSIBLE_PROD_TAGS`             | The tags for `production` env                      | `$ANSIBLE_DEFAULT_TAGS`                                   |
| `ANSIBLE_PROD_EXTRA_ARGS`       | The command line args  for `production` env        | `$ANSIBLE_DEFAULT_EXTRA_ARGS`                             |
+5 −3
Original line number Diff line number Diff line
@@ -327,9 +327,11 @@
          "advanced": true
        },
        {
          "name": "AUTODEPLOY_TO_PROD",
          "type": "boolean",
          "description": "Set this variable to auto-deploy to production. If not set deployment to production will be manual (default behaviour)."
          "name": "ANSIBLE_PROD_DEPLOY_STRATEGY",
          "description": "Defines the deployment to production strategy.",
          "type": "enum",
          "values": ["manual", "auto"],
          "default": "manual"
        },
        {
          "name": "ANSIBLE_PROD_INVENTORY",
+6 −7
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@ variables:
  ANSIBLE_SCRIPTS_DIR: "."
  ANSIBLE_HOST_KEY_CHECKING: "false"
  ANSIBLE_DEFAULT_ROLES_PATH: "$CI_PROJECT_DIR/roles"

  # default: one-click deploy
  ANSIBLE_PROD_DEPLOY_STRATEGY: manual

  # default production ref name (pattern)
  PROD_REF: '/^(master|main)$/'
  # default integration ref name (pattern)
@@ -783,7 +787,6 @@ ansible-cleanup-staging:
#           Prod              #
###############################

# Deploy to production if on branch master and variable OS_PROD_PROJECT defined and AUTODEPLOY_TO_PROD is set
ansible-production:
  extends: .ansible-deploy
  stage: production
@@ -809,10 +812,6 @@ ansible-production:
    # exclude if $ANSIBLE_PROD_PLAYBOOK_FILE not set
    - if: '$ANSIBLE_PROD_PLAYBOOK_FILE == null || $ANSIBLE_PROD_PLAYBOOK_FILE == ""'
      when: never
    # if $AUTODEPLOY_TO_PROD: auto
    - if: '$AUTODEPLOY_TO_PROD == "true"'
    # else if PUBLISH_ON_PROD enabled: auto (because the publish job was blocking)
    - if: '$PUBLISH_ON_PROD == "true"'
    # else: manual, blocking
    - if: $ANSIBLE_PROD_PLAYBOOK_FILE # useless test, just to prevent GitLab warning
    - if: '$ANSIBLE_PROD_DEPLOY_STRATEGY == "manual"'
      when: manual
    - if: '$ANSIBLE_PROD_DEPLOY_STRATEGY == "auto"'