Implement docker compose app deployment playbook

This commit is contained in:
2020-12-08 22:21:03 -05:00
parent 1990413fbe
commit 0016b318e2
6 changed files with 392 additions and 11 deletions

View File

@@ -10,14 +10,6 @@
tasks:
- import_tasks: tasks/nginx/install.yml
- name: Install configuration
become: true
copy:
src: nginx.conf
dest: /etc/nginx/nginx.conf
notify:
- restart-nginx
- name: Set required SELinux options
become: true
seboolean:
@@ -26,3 +18,37 @@
state: true
notify:
- restart-nginx
- name: Configure Nginx
hosts: jupiter
vars_files:
- vars/applications.yml
vars:
_letsencrypt_cert_dir: /etc/letsencrypt/live
handlers:
- name: restart-nginx
import_tasks: tasks/nginx/services.yml
tasks:
- name: Install server configuration
become: true
copy:
src: nginx/nginx.conf
dest: /etc/nginx/nginx.conf
notify:
- restart-nginx
- name: Install application configurations
when: item.value.published.host is defined
become: true
template:
src: nginx/{{ item.key }}.nginx.conf.j2
dest: /etc/nginx/conf.d/{{ item.key }}.conf
owner: nginx
group: "{{ ansible_user }}"
mode: 0755
loop: "{{ omni_compose_apps | dict2items }}"
loop_control:
label: "{{ item.key }} ({{ item.value.published.host | default('none') }})"
notify:
- restart-nginx

View File

@@ -0,0 +1,68 @@
---
- 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.yml
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: Configure datastore
hosts: jupiter
vars_files:
- vars/applications.yml
- vars/secrets/applications.yml
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.yml
- vars/secrets/applications.yml
tasks:
- name: Create compose configuration directory
become: true
file:
path: "{{ omni_docker_configs }}/{{ _runtime_application }}"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: 0700
- name: Install docker-compose file
become: true
template:
src: docker-compose/bitwarden.yaml.j2
dest: "{{ 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"