xoxys.nginx/tasks/config.yml

89 lines
1.8 KiB
YAML
Raw Normal View History

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:
- 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:
- header.conf
notify:
- nginx_restart
2017-07-15 15:39:52 +00:00
2017-07-15 16:45:21 +00:00
- name: Remove default.conf from conf.d
file:
path: /etc/conf.d/default.conf
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:
- nginx_restart
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'
tags: iptables