- name: deploy Airflow containers to Docker Cloud
  hosts: localhost
  vars:
    dockercloud_conf: "{{ playbook_dir }}/files/docker-cloud.yml"
  environment:
    DOCKERCLOUD_USER: "{{ dockercloud_user }}"
    DOCKERCLOUD_PASS: "{{ dockercloud_pass }}"
    DOCKERCLOUD_NAMESPACE: "{{ dockercloud_namespace }}"
    DOCKERCLOUD_STACK: airflow

  tasks:
    - name: create Docker Cloud stack if needed
      shell: docker-cloud stack inspect $DOCKERCLOUD_STACK || docker-cloud stack create --sync -n $DOCKERCLOUD_STACK

    - name: update Docker Cloud stack
      shell: docker-cloud stack update --sync $DOCKERCLOUD_STACK -f {{ dockercloud_conf }}
      environment:
        EXECUTOR: Celery
        AIRFLOW_ENABLE_AUTH: True
        STATSD_ENABLED: True
        REMOTE_BASE_LOG_FOLDER: "{{ remote_base_log_folder }}"
        REMOTE_LOG_CONN_ID: "{{ remote_log_conn_id }}"
        DB_URI: "{{ db_uri }}"
        DB_USER: "{{ db_user }}"
        DB_PASSWORD: "{{ db_password }}"
        DB_TABLE: "{{ db_table }}"
        SMTP_HOST: "{{ smtp_host }}"
        SMTP_USER: "{{ smtp_user }}"
        SMTP_PASSWORD: "{{ smtp_password }}"
        FERNET_KEY: "{{ fernet_key }}"
        DD_API_KEY: "{{ datadog_api_key }}"
        DD_HOSTNAME: opentrials-airflow
        NON_LOCAL_TRAFFIC: True

    - name: redeploy Airflow
      shell: docker-cloud stack redeploy $DOCKERCLOUD_STACK

- name: deploy Airflow containers to Docker Cloud
  hosts: localhost
  vars:
    dockercloud_conf: "{{ playbook_dir }}/files/docker-cloud.yml"
  environment:
    DOCKERCLOUD_USER: "{{ dockercloud_user }}"
    DOCKERCLOUD_PASS: "{{ dockercloud_pass }}"
    DOCKERCLOUD_NAMESPACE: "{{ dockercloud_namespace }}"
    DOCKERCLOUD_STACK: airflow-production

  tasks:
    - name: create Docker Cloud stack if needed
      shell: docker-cloud stack inspect $DOCKERCLOUD_STACK || docker-cloud stack create --sync -n $DOCKERCLOUD_STACK

    - name: update Docker Cloud stack
      shell: docker-cloud stack update --sync $DOCKERCLOUD_STACK -f {{ dockercloud_conf }}
      environment:
        EXECUTOR: Celery
        AIRFLOW_ENABLE_AUTH: True
        STATSD_ENABLED: True
        REMOTE_BASE_LOG_FOLDER: "{{ remote_base_log_folder }}"
        REMOTE_LOG_CONN_ID: "{{ remote_log_conn_id }}"
        DB_URI: "{{ db_uri }}"
        DB_USER: "{{ db_user }}"
        DB_PASSWORD: "{{ db_password }}"
        DB_TABLE: "{{ db_table }}"
        SMTP_HOST: "{{ smtp_host }}"
        SMTP_USER: "{{ smtp_user }}"
        SMTP_PASSWORD: "{{ smtp_password }}"
        FERNET_KEY: "{{ fernet_key }}"
        DD_API_KEY: "{{ datadog_api_key }}"
        DD_HOSTNAME: opentrials-airflow
        NON_LOCAL_TRAFFIC: True

    - name: redeploy Airflow
      shell: docker-cloud stack redeploy $DOCKERCLOUD_STACK

Change default DockerCloud Stack name
Change default DockerCloud Stack name

We had to change the name to redeploy to a new cluster.
