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,22 +148,53 @@
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
- name: Determine volume directories - name: Configure datastore directories
run_once: true
block:
- name: Determine volume directories
vars:
_stack_volume_directories: []
when: item.value.volumes is defined
ansible.builtin.set_fact:
_stack_volume_directories: "{{ _stack_volume_directories + [{'user': (item.value.user | default(ansible_user)), 'volumes': (item.value.volumes.values() | list)}] }}"
loop: "{{ _services | dict2items }}"
loop_control:
label: "{{ item.key }}"
- name: Create service directories
become: true
ansible.builtin.file:
path: "{{ local_datastore_mount }}{{ item.1 }}"
state: directory
owner: "{{ item.0.user }}"
group: "{{ skylab_group_admin.name }}"
mode: 0770
loop: "{{ _stack_volume_directories | subelements('volumes') }}"
- name: Deploy stack
vars: vars:
_stack_volume_directories: [] ansible_python_interpreter: "{{ skylab_ansible_venv }}/bin/python"
when: item.value.volumes is defined community.docker.docker_stack:
ansible.builtin.set_fact: name: "{{ item.key }}"
_stack_volume_directories: "{{ _stack_volume_directories + [{'user': (item.value.user | default(ansible_user)), 'volumes': (item.value.volumes.values() | list)}] }}" compose:
- "{{ skylab_compose_dir }}/{{ item.key }}.yaml"
prune: false
state: present
loop: "{{ _services | dict2items }}" loop: "{{ _services | dict2items }}"
loop_control: loop_control:
label: "{{ item.key }}" label: "{{ item.key }}"
- name: Create service directories - name: Configure reverse proxy
become: true run_once: true
ansible.builtin.file: block:
path: "{{ local_datastore_mount }}{{ item.1 }}" - name: Create nginx config
state: directory when: item.value.domain is defined
owner: "{{ item.0.user }}" ansible.builtin.template:
group: "{{ skylab_group_admin.name }}" src: stack-nginx.conf.j2
mode: 0770 dest: "{{ local_datastore_mount }}/appdata/nginx/conf.d/{{ item.key }}.conf"
loop: "{{ _stack_volume_directories | subelements('volumes') }}" owner: "{{ ansible_user }}"
group: "{{ skylab_group_admin.name }}"
mode: 0464
loop: "{{ _services | dict2items }}"
loop_control:
label: "{{ item.value.domain | default(item.key) }}"