Skip to content

Manage deployment in production environment

Shared Account edited this page Dec 4, 2018 · 5 revisions

Deployment system

Deploying applications are going to be done at DeployCenter which built up on AWX Project that leverages Ansible and its playbook or modules to deploy application.

The deploy system contains multiple instances and each instance is specified as an inventory in Inventories section. Each instance names as production-vps#{suffix} which suffix ranges from 1..34 and each corresponding to a virtual instance in Hetzner3 system.

For example, the first virtual machine's name is production-vps1, the second one is production-vps2 and so on.

To deploy an application, please follow these steps:

Deploy steps

  1. Create a new application template or select an existing one
  2. Update its settings if there is any
  3. Click to deploy

Remember this system deploys master branch or revision from application repository only.

Manage deployment

This writes about how to manage a deployment that includes

  • Create a new application template
  • Deploy an application
  • Delete a template

Prerequisites

Get to know application template

A reference template can be fetched here Reference template - this is for reference, if you are urged to deploy to go to next section Manage application template.

Let look at the reference template and see what it contains

---
deploy:
  - app_name: hemoroizi.net
    zone_apex: hemoroizi.net
    domains: ["hemoroizi.net"]
    document_root: "src/public"
    application_type: app
    source_url: "[email protected]:Oxi-Dev/hemoroizi.net.git"
    scm: git
    source_branch: master
    deploy_user: deploy
    enable_ssl: True
    enforce_nossl: False
    require_migrate: False
    ssl_configuration:
      ssl_cert: |
      ssl_key: |
    require_certbot: True
    database:
      host: 127.0.0.1
      username: root
      password: supersecret
      database: bonsoir

The template is a YAML file which has:

  • app_name: application domain name (requires)
  • zone_apex: if the application domain name is a subdomain, like sub.example.com, then example.com should be filled here (optional)
  • domains: domains to be filled in NGINX server_name, e.g ["example.com"] (require)
  • document_root: empty by default, useful when application code is not in the root of application revision (optional)
  • application_type: app by default, use to specify application type (require)
  • source_url: application source here, e.g "[email protected]:Oxi-Dev/example.com" (require)
  • scm: git by default (optional)
  • source_branch: master by default, application revision (optional)
  • deploy_user: deploy by default (optional)
  • ssl_configuration: containter to defines SSL related keys; you do not have to fill this container when cert is requested via certbot
    • ssl_cert: default is empty, fill SSL cert content here
    • ssl_key: default is empty, fill SSL key file here
  • enable_ssl: false by default, set to True to enable SSL; require ssl_configuration to filled if cert requested from other sources not certbot
  • require_certbot: false by default, set to True if request SSL cert from LetsEncrypt (optional)
  • cron: a container for cronjob (optional)_
    • name: cronjob name e.g example-1
    • minute: set minute to run, e.g 0 - 59
    • hour: set hour to run, e.g 1-23
    • command: php file or file need to run in the root document directory, e.g index.php
    • prefix: cronjob prefix
  • database: a container to specify database settings
    • host: database host IP address of domain name (require)
    • username: database username
    • password: database password
    • database: databaser name

Managing application template

As a developer, just focus on how to create a new application that define settings and then deploy on production environment.

Please note: Due to the limitation of the infrastructure, especially, SSL/TLS infrastructure limitation, this deployment centre supports the application with a single domain name only.

Create a new application template

An application template contains settings like GitHub URL, domain name, DB settings, etc as well as the instance where application revision to be deployed.

From the scratch

Steps

  1. Get the reference template
  2. Modify domain name, and GitHub URL, etc accordingly.
  3. Select Templates under RESOURCES section in the left pane
  4. Click the green square with plus sign inside to create a new template
  5. Paste modified content in step 2 in EXTRA VARIABLES (please use YAML)
  6. Set NAME, for example, deploy.example.com
  7. Set JOB TYPE to Run
  8. Set INVENTORY to expected virtual machine instance
  9. Set PLAYBOOK to deploy.yml
  10. If not specified, select BioeliteVert 2018
  11. Change VERBOSITY or leave it as default
  12. Click the green button with SAVE to save.

Clone other application templates

We can also clone an existing one if we need to add another deployment to a virtual machine instance.

Steps

  1. Select Templates under RESOURCES section in the left pane
  2. Select an existing template in the right, and click on stacked paper icon its right to clone that application template
  3. After a new template with the existing application name and cloned date will be created right beneath that existing template, click on the new template name to edit
  4. Continue from step 5 in the From the scratch section above

Deploying applications

Steps

  1. Select Templates under RESOURCES section in the left pane
  2. Select an existing template to deploy
  3. Click the Rocket icon in it's right to deploy