Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize nginx vhost generation #863

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 5 additions & 81 deletions ansible/roles/nginx_vhost/tasks/defaulthost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@
tags:
- nginx_vhost

- name: remove previous fragments dir for aws_elb_default
file:
path: "{{nginx_conf_dir}}/vhost_fragments/aws_elb_default"
state: absent
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: ensure fragments dir for default vhost for ala is present
file:
path: "{{nginx_conf_dir}}/vhost_fragments/ala_default"
state: directory
mode: 0755
owner: root
group: root
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: add upstream fragment
template:
src: "fragment_02_upstream.j2"
Expand All @@ -65,69 +46,13 @@
tags:
- nginx_vhost

- name: add start of default vhost for ala
template:
src: "ala_default_start.j2"
dest: "{{nginx_conf_dir}}/vhost_fragments/ala_default/10_ala_default_start"
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: add start location fragment for default vhost for Amazon load balancer health checks
template:
src: "fragment_70_location_start.j2"
dest: "{{nginx_conf_dir}}/vhost_fragments/ala_default/70_location_{{ item.sort_label | default(item.path | basename) }}_70_start"
with_items:
- "{{ nginx_paths }}"
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: add default contents location fragment for default vhost for Amazon load balancer health checks
- name: Create Nginx default config from template
template:
src: "fragment_71_location_default.j2"
dest: "{{nginx_conf_dir}}/vhost_fragments/ala_default/70_location_{{ item.sort_label | default(item.path | basename) }}_71_default"
with_items:
- "{{ nginx_paths }}"
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: add usual contents location fragment for default vhost for Amazon load balancer health checks
template:
src: "fragment_73_location.j2"
dest: "{{nginx_conf_dir}}/vhost_fragments/ala_default/70_location_{{ item.sort_label | default(item.path | basename) }}_73_content"
with_items:
- "{{ nginx_paths }}"
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: add end location fragment for default vhost for Amazon load balancer health checks
template:
src: "fragment_75_location_end.j2"
dest: "{{nginx_conf_dir}}/vhost_fragments/ala_default/70_location_{{ item.sort_label | default(item.path | basename) }}_75_end"
with_items:
- "{{ nginx_paths }}"
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: add end of default vhost for ala
template:
src: "ala_default_end.j2"
dest: "{{nginx_conf_dir}}/vhost_fragments/ala_default/90_ala_default_end"
when: ala_default_vhost and vhost_required
tags:
- nginx_vhost

- name: assemble fragments into default vhost for Amazon load balancer health checks
assemble:
src: "{{nginx_conf_dir}}/vhost_fragments/ala_default"
dest: "{{nginx_conf_dir}}/sites-available/ala_default.conf"
when: ala_default_vhost and vhost_required
src: "nginx_vhost_default.j2"
dest: "{{ nginx_conf_dir }}/sites-available/ala_default.conf"
when: vhost_required | bool == True
notify:
- reload nginx
- reload nginx
tags:
- nginx_vhost

Expand All @@ -147,4 +72,3 @@
ala_default_vhost: False
tags:
- nginx_vhost

Loading