ansible-personal/roles/nginx/tasks/main.yml

49 lines
1.4 KiB
YAML
Raw Normal View History

---
- name: Add nginx.org apt signing key
apt_key: url=http://nginx.org/keys/nginx_signing.key state=present
tags: nginx
- name: Add nginx.org stable repo
apt_repository: repo="deb http://nginx.org/packages/ubuntu/ {{ ansible_distribution_release }} nginx" state=present
tags: nginx
- name: Install nginx
apt: pkg=nginx update_cache=yes
tags: nginx
- name: Copy nginx config
copy: src={{ item }} dest=/etc/nginx/{{ item }} mode=0644 owner=root group=root
with_items:
- nginx.conf
notify:
- reload nginx
tags: nginx
- name: Remove default nginx vhost
file: path=/etc/nginx/conf.d/default.conf state=absent
tags: nginx
# need to modularize so we can have different vhosts in different files (apples.com and bananas.com in separate config files)
- name: Configure nginx vhosts
template: src={{ item }} dest=/etc/nginx/conf.d/{{ inventory_hostname }}.conf mode=0644 owner=root group=root
with_first_found:
- "../templates/{{ inventory_hostname }}.conf.j2"
- "../templates/default.conf.j2"
notify:
- reload nginx
tags: nginx
- name: Configure munin vhost
copy: src=munin.conf dest=/etc/nginx/conf.d/munin.conf mode=0644 owner=root group=root
notify:
- reload nginx
tags: nginx
- name: Generate 2048-bit dhparam
command: openssl dhparam -out dhparam.pem 2048 chdir=/etc/ssl/certs creates=dhparam.pem
tags: nginx
- name: Start & enable nginx service
service: name=nginx state=started enabled=yes
tags: nginx