2020-12-09 03:21:03 +00:00
|
|
|
---
|
|
|
|
- name: Prompt for input
|
|
|
|
hosts: all
|
|
|
|
tags:
|
|
|
|
- always
|
|
|
|
gather_facts: false
|
|
|
|
vars_prompt:
|
|
|
|
- name: application
|
|
|
|
prompt: Enter name of application stack to deploy
|
|
|
|
private: false
|
|
|
|
vars_files:
|
2021-02-05 04:07:04 +00:00
|
|
|
- vars/applications.yaml
|
2020-12-09 03:21:03 +00:00
|
|
|
tasks:
|
|
|
|
- name: Validate user input
|
|
|
|
assert:
|
|
|
|
that: application in omni_compose_apps.keys()
|
|
|
|
|
|
|
|
- name: Set facts for usage later
|
|
|
|
set_fact:
|
|
|
|
_runtime_application: "{{ application }}"
|
|
|
|
|
|
|
|
|
|
|
|
- import_playbook: initialize.yml
|
|
|
|
|
|
|
|
|
2021-01-15 05:31:07 +00:00
|
|
|
- name: Build image
|
|
|
|
hosts: virtualization
|
|
|
|
vars_files:
|
2021-02-05 04:07:04 +00:00
|
|
|
- vars/applications.yaml
|
2021-01-15 05:31:07 +00:00
|
|
|
tasks:
|
|
|
|
- import_tasks: tasks/docker/build.yml
|
|
|
|
|
|
|
|
|
2020-12-09 03:21:03 +00:00
|
|
|
- name: Configure datastore
|
|
|
|
hosts: jupiter
|
|
|
|
vars_files:
|
2021-02-05 04:07:04 +00:00
|
|
|
- vars/applications.yaml
|
|
|
|
- vars/secrets/applications.yaml
|
2020-12-09 03:21:03 +00:00
|
|
|
tasks:
|
|
|
|
- name: Create application datastore directory
|
|
|
|
become: true
|
|
|
|
file:
|
|
|
|
path: "{{ omni_datastore_mount }}{{ omni_compose_apps[_runtime_application].datastore }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ omni_compose_apps[_runtime_application].account.name }}"
|
|
|
|
group: "{{ omni_compose_apps[_runtime_application].account.name }}"
|
|
|
|
mode: 0750
|
|
|
|
|
2021-04-29 23:06:22 +00:00
|
|
|
- name: Create datastore assets
|
|
|
|
become: true
|
|
|
|
template:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ omni_datastore_mount }}{{ omni_compose_apps[_runtime_application].datastore }}/{{ item.name }}"
|
|
|
|
owner: "{{ omni_compose_apps[_runtime_application].account.name }}"
|
|
|
|
group: "{{ omni_compose_apps[_runtime_application].account.name }}"
|
|
|
|
mode: "{{ item.permissions | default(0644) }}"
|
|
|
|
loop: "{{ omni_compose_apps[_runtime_application].assets | default([]) }}"
|
|
|
|
|
2020-12-09 03:21:03 +00:00
|
|
|
|
|
|
|
- name: Configure docker stack
|
|
|
|
hosts: jupiter
|
|
|
|
vars_files:
|
2021-02-05 04:07:04 +00:00
|
|
|
- vars/applications.yaml
|
|
|
|
- vars/secrets/applications.yaml
|
2020-12-09 03:21:03 +00:00
|
|
|
tasks:
|
|
|
|
- name: Create compose configuration directory
|
|
|
|
become: true
|
|
|
|
file:
|
|
|
|
path: "{{ omni_docker_configs }}/{{ _runtime_application }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ ansible_user }}"
|
2020-12-09 03:41:29 +00:00
|
|
|
group: docker
|
|
|
|
mode: 0750
|
2020-12-09 03:21:03 +00:00
|
|
|
|
|
|
|
- name: Install docker-compose file
|
|
|
|
become: true
|
|
|
|
template:
|
2020-12-09 03:41:29 +00:00
|
|
|
src: docker-compose/{{ _runtime_application }}.yaml.j2
|
2020-12-09 03:21:03 +00:00
|
|
|
dest: "{{ omni_docker_configs }}/{{ _runtime_application }}/docker-compose.yaml"
|
2020-12-09 03:41:29 +00:00
|
|
|
owner: "{{ ansible_user }}"
|
|
|
|
group: docker
|
|
|
|
mode: 0640
|
2021-04-26 01:02:08 +00:00
|
|
|
register: _stack_file_state
|
|
|
|
|
|
|
|
- name: Remove the existing stack
|
2021-04-26 01:14:00 +00:00
|
|
|
when: _stack_file_state.changed is true or omni_compose_apps[_runtime_application].force_clean | default(false) is true
|
2021-04-26 01:02:08 +00:00
|
|
|
docker_stack:
|
|
|
|
name: "{{ _runtime_application }}"
|
|
|
|
state: absent
|
|
|
|
compose:
|
|
|
|
- "{{ omni_docker_configs }}/{{ _runtime_application }}/docker-compose.yaml"
|
2020-12-09 03:21:03 +00:00
|
|
|
|
|
|
|
- name: Deploy the stack
|
|
|
|
docker_stack:
|
|
|
|
name: "{{ _runtime_application }}"
|
|
|
|
state: present
|
|
|
|
compose:
|
|
|
|
- "{{ omni_docker_configs }}/{{ _runtime_application }}/docker-compose.yaml"
|