2017-07-15 13:45:46 +00:00
|
|
|
---
|
|
|
|
- name: Enable nginx service
|
|
|
|
service:
|
|
|
|
name: nginx
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
2017-07-15 15:24:48 +00:00
|
|
|
|
2017-07-15 16:32:35 +00:00
|
|
|
- name: Prepare vhost directories
|
2017-07-15 15:24:48 +00:00
|
|
|
file:
|
2017-07-15 15:55:20 +00:00
|
|
|
path: '{{ item }}'
|
2017-07-15 15:24:48 +00:00
|
|
|
state: directory
|
|
|
|
owner: nginx
|
|
|
|
group: nginx
|
|
|
|
mode: 0750
|
2017-07-15 15:54:35 +00:00
|
|
|
with_items:
|
|
|
|
- /var/www/vhosts
|
|
|
|
- /var/www/vhosts/default
|
2017-07-15 15:24:48 +00:00
|
|
|
|
2017-07-15 16:32:35 +00:00
|
|
|
- name: Prepare nginx directories
|
|
|
|
file:
|
|
|
|
path: '{{ item }}'
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0640
|
|
|
|
with_items:
|
|
|
|
- /etc/nginx/sites-available
|
|
|
|
- /etc/nginx/sites-enabled
|
|
|
|
|
2017-07-15 15:49:44 +00:00
|
|
|
- name: Add default page
|
|
|
|
template:
|
2017-07-15 15:52:19 +00:00
|
|
|
src: 'var/www/vhosts/default/index.html.j2'
|
2017-07-15 15:56:47 +00:00
|
|
|
dest: '/var/www/vhosts/default/index.html'
|
2017-07-15 15:49:44 +00:00
|
|
|
owner: nginx
|
|
|
|
group: nginx
|
|
|
|
mode: 0750
|
|
|
|
|
2017-07-15 15:24:48 +00:00
|
|
|
- name: Update nginx.conf
|
|
|
|
template:
|
|
|
|
src: 'etc/nginx/nginx.conf.j2'
|
|
|
|
dest: '/etc/nginx/nginx.conf'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0640
|
|
|
|
notify:
|
2017-07-15 20:36:00 +00:00
|
|
|
- nginx_reload
|
2017-07-15 15:24:48 +00:00
|
|
|
|
|
|
|
- name: Update conf.d files
|
|
|
|
template:
|
|
|
|
src: 'etc/nginx/conf.d/{{ item }}.j2'
|
|
|
|
dest: '/etc/nginx/conf.d/{{ item }}'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0640
|
|
|
|
with_items:
|
|
|
|
- header.conf
|
2017-07-15 20:35:00 +00:00
|
|
|
- tls.conf
|
2017-07-15 15:24:48 +00:00
|
|
|
notify:
|
2017-07-15 20:36:00 +00:00
|
|
|
- nginx_reload
|
2017-07-15 15:39:52 +00:00
|
|
|
|
2017-07-15 16:45:21 +00:00
|
|
|
- name: Remove default.conf from conf.d
|
|
|
|
file:
|
2017-07-15 16:48:34 +00:00
|
|
|
path: /etc/nginx/conf.d/default.conf
|
2017-07-15 16:45:21 +00:00
|
|
|
state: absent
|
|
|
|
|
2017-07-15 16:32:35 +00:00
|
|
|
- name: Add default page config
|
|
|
|
template:
|
2017-07-15 16:34:48 +00:00
|
|
|
src: 'etc/nginx/sites-available/default.j2'
|
|
|
|
dest: '/etc/nginx/sites-available/default'
|
2017-07-15 16:32:35 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0640
|
|
|
|
|
|
|
|
- name: Enable default page
|
|
|
|
file:
|
|
|
|
src: /etc/nginx/sites-available/default
|
|
|
|
dest: /etc/nginx/sites-enabled/default
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
state: link
|
|
|
|
notify:
|
2017-07-15 20:36:00 +00:00
|
|
|
- nginx_reload
|
2017-07-15 16:32:35 +00:00
|
|
|
|
2017-07-15 20:33:16 +00:00
|
|
|
- name: Copy ssl chained certs
|
|
|
|
copy:
|
|
|
|
content: '{{ ssl_chained_cert }}'
|
|
|
|
dest: /etc/pki/tls/certs/my-chained.crt
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2017-07-15 20:35:00 +00:00
|
|
|
notify:
|
2017-07-15 20:36:00 +00:00
|
|
|
- nginx_reload
|
2017-07-15 20:33:16 +00:00
|
|
|
|
|
|
|
- name: Copy ssl intermediate cert
|
|
|
|
copy:
|
|
|
|
content: '{{ ssl_intermediate_cert }}'
|
|
|
|
dest: /etc/pki/tls/certs/my-intermediate.crt
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
2017-07-15 20:35:00 +00:00
|
|
|
notify:
|
2017-07-15 20:36:00 +00:00
|
|
|
- nginx_reload
|
2017-07-15 20:33:16 +00:00
|
|
|
|
|
|
|
- name: Copy ssl private key
|
|
|
|
copy:
|
|
|
|
content: '{{ ssl_priv_key }}'
|
|
|
|
dest: /etc/pki/tls/private/my-private.key
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0600
|
2017-07-15 20:35:00 +00:00
|
|
|
notify:
|
2017-07-15 20:36:00 +00:00
|
|
|
- nginx_reload
|
2017-07-15 20:33:16 +00:00
|
|
|
|
2017-07-15 15:39:52 +00:00
|
|
|
- name: Open ports in iptables
|
|
|
|
iptables_raw:
|
|
|
|
name: allow_nginx_ports
|
|
|
|
state: present
|
|
|
|
rules: '-A INPUT -p tcp -m multiport --dports {{ nginx_open_ports|join(",") }} -j ACCEPT'
|