Commit 3127d004 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat!: support environment auto-stop

BREAKING CHANGE: now review environments will auto stop after 4 hours
by default. Configurable (see doc).
parent 2887d9d4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -274,6 +274,7 @@ Here are variables supported to configure the integration environment:
| :lock: `ANSIBLE_REVIEW_PRIVATE_KEY`    | The SSH private key to be use in `review` env      | `$ANSIBLE_PRIVATE_KEY`                   |
| `ANSIBLE_REVIEW_PUBLIC_KEY`     | The SSH public key associated to the private key to be use in `review` env      | `$ANSIBLE_PUBLIC_KEY`                   |
| :lock: `ANSIBLE_REVIEW_VAULT_PASSWORD` | The Ansible vault password for `review` env        | `$ANSIBLE_VAULT_PASSWORD`                 |
| `ANSIBLE_REVIEW_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop `review` environments | `4 hours` |

### Integration environment configuration

@@ -296,6 +297,7 @@ Here are variables supported to configure the integration environment:
| :lock: `ANSIBLE_INTEG_PRIVATE_KEY`    | The SSH private key to be use in `integration` env     | `$ANSIBLE_PRIVATE_KEY`                  |
| `ANSIBLE_INTEG_PUBLIC_KEY`      | The SSH public key associated to the private key to be use in `integration` env  | `$ANSIBLE_PUBLIC_KEY`                   |
| :lock: `ANSIBLE_INTEG_VAULT_PASSWORD` | The Ansible vault password for `integration` env       | `$ANSIBLE_VAULT_PASSWORD`                |
| `ANSIBLE_INTEG_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop the `integration` env | `never` |

### Staging environment configuration

@@ -318,6 +320,7 @@ Here are variables supported to configure the staging environment:
| :lock: `ANSIBLE_STAGING_PRIVATE_KEY`    | The SSH private key to be use in `staging` env     | `$ANSIBLE_PRIVATE_KEY`                  |
| `ANSIBLE_STAGING_PUBLIC_KEY`     | The SSH public key associated to the private key to be use in `staging` env      | `$ANSIBLE_PUBLIC_KEY`                   |
| :lock: `ANSIBLE_STAGING_VAULT_PASSWORD` | The Ansible vault password for `staging` env       | `$ANSIBLE_VAULT_PASSWORD`                |
| `ANSIBLE_STAGING_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop the `staging` env | `never` |

### Production environment configuration

+15 −0
Original line number Diff line number Diff line
@@ -138,6 +138,11 @@
          "advanced": true,
          "default": "$ANSIBLE_DEFAULT_EXTRA_ARGS"
        },
        {
          "name": "ANSIBLE_REVIEW_AUTOSTOP_DURATION",
          "description": "The amount of time before GitLab will automatically stop `review` environments",
          "default": "4 hours"
        },
        {
          "name": "ANSIBLE_REVIEW_PLAYBOOK_FILE",
          "description": " The playbook filename for `review` env",
@@ -180,6 +185,11 @@
          "description": "The application name for integration env (only define if different from global)",
          "advanced": true
        },
        {
          "name": "ANSIBLE_INTEG_AUTOSTOP_DURATION",
          "description": "The amount of time before GitLab will automatically stop the `integration` env",
          "default": "never"
        },
        {
          "name": "ANSIBLE_INTEG_ENVIRONMENT_URL",
          "type": "url",
@@ -250,6 +260,11 @@
          "description": "The application name for staging env (only define if different from global)",
          "advanced": true
        },
        {
          "name": "ANSIBLE_STAGING_AUTOSTOP_DURATION",
          "description": "The amount of time before GitLab will automatically stop the `staging` env",
          "default": "never"
        },
        {
          "name": "ANSIBLE_STAGING_ENVIRONMENT_URL",
          "type": "url",
+7 −1
Original line number Diff line number Diff line
@@ -69,6 +69,10 @@ variables:
  ANSIBLE_HOST_KEY_CHECKING: "false"
  ANSIBLE_DEFAULT_ROLES_PATH: "$CI_PROJECT_DIR/roles"

  ANSIBLE_REVIEW_AUTOSTOP_DURATION: "4 hours"
  ANSIBLE_INTEG_AUTOSTOP_DURATION: "never"
  ANSIBLE_STAGING_AUTOSTOP_DURATION: "never"

  # default: one-click deploy
  ANSIBLE_PROD_DEPLOY_STRATEGY: manual

@@ -647,6 +651,7 @@ ansible-review:
  environment:
    name: review/$CI_COMMIT_REF_NAME
    on_stop: ansible-cleanup-review
    auto_stop_in: "$ANSIBLE_REVIEW_AUTOSTOP_DURATION"
  resource_group: review/$CI_COMMIT_REF_NAME
  rules:
    # exclude tags
@@ -704,6 +709,7 @@ ansible-integration:
  environment:
    name: integration
    on_stop: ansible-cleanup-integration
    auto_stop_in: "$ANSIBLE_INTEG_AUTOSTOP_DURATION"
  resource_group: integration
  rules:
    # only on integration branch(es), with $ANSIBLE_INTEG_PLAYBOOK_FILE set
@@ -756,6 +762,7 @@ ansible-staging:
  environment:
    name: staging
    on_stop: ansible-cleanup-staging
    auto_stop_in: "$ANSIBLE_STAGING_AUTOSTOP_DURATION"
  resource_group: staging
  rules:
    # only on production branch(es), with $ANSIBLE_STAGING_PLAYBOOK_FILE set
@@ -792,7 +799,6 @@ ansible-cleanup-staging:
###############################
#           Prod              #
###############################

ansible-production:
  extends: .ansible-deploy
  stage: production