This repository has been archived on 2024-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
omni-ansible/playbooks/deploy-compose.yml

89 lines
2.3 KiB
YAML

---
- 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:
- vars/applications.yaml
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
- name: Build image
hosts: virtualization
vars_files:
- vars/applications.yaml
tasks:
- import_tasks: tasks/docker/build.yml
- name: Configure datastore
hosts: jupiter
vars_files:
- vars/applications.yaml
- vars/secrets/applications.yaml
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
- name: Configure docker stack
hosts: jupiter
vars_files:
- vars/applications.yaml
- vars/secrets/applications.yaml
tasks:
- name: Create compose configuration directory
become: true
file:
path: "{{ omni_docker_configs }}/{{ _runtime_application }}"
state: directory
owner: "{{ ansible_user }}"
group: docker
mode: 0750
- name: Install docker-compose file
become: true
template:
src: docker-compose/{{ _runtime_application }}.yaml.j2
dest: "{{ omni_docker_configs }}/{{ _runtime_application }}/docker-compose.yaml"
owner: "{{ ansible_user }}"
group: docker
mode: 0640
register: _stack_file_state
- name: Remove the existing stack
when: _stack_file_state.changed is true
docker_stack:
name: "{{ _runtime_application }}"
state: absent
compose:
- "{{ omni_docker_configs }}/{{ _runtime_application }}/docker-compose.yaml"
- name: Deploy the stack
docker_stack:
name: "{{ _runtime_application }}"
state: present
compose:
- "{{ omni_docker_configs }}/{{ _runtime_application }}/docker-compose.yaml"