Created
May 25, 2016 18:49
-
-
Save gfoster/3d29f544b7753786102a12af73c2cf46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## FACTS ## | |
- set_fact: "nginx_conf_file=production-{{ item }}" | |
when: "nginx_conf_file is not defined and cluster_env == 'production' and '{{ item }}' in group_names" | |
with_items: "{{applications}}" | |
- set_fact: "nginx_conf_file={{ cluster_env }}" | |
when: nginx_conf_file is not defined | |
## GO ## | |
# - debug: var=nginx_conf_file | |
# - debug: var=group_names | |
# - debug: var=item | |
# - debug: var=cluster_env | |
# - debug: var=nginx_certs | |
- name: install nginx | |
apt: pkg=nginx={{ nginx_version }} state=present | |
notify: | |
- restart nginx | |
- name: ensure the nginx dir | |
file: path=/etc/nginx state=directory owner=root | |
- name: ensure the nginx log dir | |
file: path=/var/log/nginx state=directory owner=nobody group=nogroup | |
- name: ensure the default site is removed | |
file: path=/etc/nginx/sites-{{ item }}/default state=absent | |
with_items: | |
- enabled | |
- available | |
notify: | |
- restart nginx | |
- name: nginx.conf | |
template: src={{ nginx_conf_file }}.conf.j2 dest=/etc/nginx/nginx.conf | |
notify: | |
- reload nginx | |
- name: SSL KEYs | |
template: src=certs/{{ item }}.key dest=/etc/nginx/{{ item }}.key | |
notify: | |
- reload nginx | |
with_items: "{{nginx_certs}}" | |
- name: SSL PEMs | |
template: src=certs/{{ item }}.pem dest=/etc/nginx/{{ item }}.pem | |
notify: | |
- reload nginx | |
with_items: "{{nginx_certs}}" | |
- name: httaccess | |
htpasswd: "path=/home/{{ deploy_user }}/.htpasswd name={{ basic_auth_user }} password={{ basic_auth_pass }} mode=0777" | |
notify: | |
- reload nginx | |
- meta: flush_handlers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment