2017-07-15 15:45:46 +02:00
|
|
|
---
|
|
|
|
- name: Enable nginx service
|
|
|
|
service:
|
|
|
|
name: nginx
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
2017-07-15 17:24:48 +02:00
|
|
|
|
|
|
|
- name: Prepare directories
|
|
|
|
file:
|
2017-07-15 17:55:20 +02:00
|
|
|
path: '{{ item }}'
|
2017-07-15 17:24:48 +02:00
|
|
|
state: directory
|
|
|
|
owner: nginx
|
|
|
|
group: nginx
|
|
|
|
mode: 0750
|
2017-07-15 17:54:35 +02:00
|
|
|
with_items:
|
|
|
|
- /var/www/vhosts
|
|
|
|
- /var/www/vhosts/default
|
2017-07-15 17:24:48 +02:00
|
|
|
|
2017-07-15 17:49:44 +02:00
|
|
|
- name: Add default page
|
|
|
|
template:
|
2017-07-15 17:52:19 +02:00
|
|
|
src: 'var/www/vhosts/default/index.html.j2'
|
2017-07-15 17:56:47 +02:00
|
|
|
dest: '/var/www/vhosts/default/index.html'
|
2017-07-15 17:49:44 +02:00
|
|
|
owner: nginx
|
|
|
|
group: nginx
|
|
|
|
mode: 0750
|
|
|
|
|
2017-07-15 17:24:48 +02:00
|
|
|
- name: Update nginx.conf
|
|
|
|
template:
|
|
|
|
src: 'etc/nginx/nginx.conf.j2'
|
|
|
|
dest: '/etc/nginx/nginx.conf'
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0640
|
|
|
|
notify:
|
|
|
|
- nginx_restart
|
|
|
|
|
|
|
|
- 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:
|
2017-07-15 17:26:42 +02:00
|
|
|
- default.conf
|
2017-07-15 17:24:48 +02:00
|
|
|
- header.conf
|
|
|
|
notify:
|
|
|
|
- nginx_restart
|
2017-07-15 17:39:52 +02: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'
|
|
|
|
tags: iptables
|