Add initial nginx config to deployment playbook

This commit is contained in:
Ethan Paul 2021-11-20 00:40:23 -05:00
parent d611301f8a
commit eb1ff31e30
No known key found for this signature in database
GPG Key ID: 6A337337DF6B5B1A

View File

@ -10,6 +10,8 @@
- name: Clean up old orechestration data - name: Clean up old orechestration data
hosts: cluster hosts: cluster
gather_facts: false gather_facts: false
tags:
- cleanup
vars_files: vars_files:
- vars/services.yaml - vars/services.yaml
- vars/access.yaml - vars/access.yaml
@ -53,6 +55,19 @@
loop_control: loop_control:
label: "{{ item.Name }}" label: "{{ item.Name }}"
- name: Fetch existing Nginx configs
ansible.builtin.command:
cmd: ls {{ local_datastore_mount }}/appdata/nginx/conf.d/
changed_when: false
register: _nginx_configs
- name: Remove legacy nginx configs
when: item.replace('.conf', '') not in skylab_services
ansible.builtin.file:
path: "{{ local_datastore_mount }}/appdata/nginx/conf.d/{{ item }}.conf"
state: absent
loop: "{{ _nginx_configs.stdout_lines }}"
- name: Deploy stack service{{ (' ' + service) if service is defined else 's' }} - name: Deploy stack service{{ (' ' + service) if service is defined else 's' }}
hosts: cluster hosts: cluster
@ -83,6 +98,15 @@
loop_control: loop_control:
label: "{{ item.name }}" label: "{{ item.name }}"
- name: Create compose directory
become: true
ansible.builtin.file:
path: "{{ skylab_compose_dir }}"
state: directory
owner: "{{ ansible_user }}"
group: "{{ skylab_group_admin.name }}"
mode: 0770
- name: Install compose file - name: Install compose file
vars: vars:
app: "{{ item.value }}" app: "{{ item.value }}"
@ -124,6 +148,9 @@
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
- name: Configure datastore directories
run_once: true
block:
- name: Determine volume directories - name: Determine volume directories
vars: vars:
_stack_volume_directories: [] _stack_volume_directories: []
@ -143,3 +170,31 @@
group: "{{ skylab_group_admin.name }}" group: "{{ skylab_group_admin.name }}"
mode: 0770 mode: 0770
loop: "{{ _stack_volume_directories | subelements('volumes') }}" loop: "{{ _stack_volume_directories | subelements('volumes') }}"
- name: Deploy stack
vars:
ansible_python_interpreter: "{{ skylab_ansible_venv }}/bin/python"
community.docker.docker_stack:
name: "{{ item.key }}"
compose:
- "{{ skylab_compose_dir }}/{{ item.key }}.yaml"
prune: false
state: present
loop: "{{ _services | dict2items }}"
loop_control:
label: "{{ item.key }}"
- name: Configure reverse proxy
run_once: true
block:
- name: Create nginx config
when: item.value.domain is defined
ansible.builtin.template:
src: stack-nginx.conf.j2
dest: "{{ local_datastore_mount }}/appdata/nginx/conf.d/{{ item.key }}.conf"
owner: "{{ ansible_user }}"
group: "{{ skylab_group_admin.name }}"
mode: 0464
loop: "{{ _services | dict2items }}"
loop_control:
label: "{{ item.value.domain | default(item.key) }}"