refactoring and cleanup
This commit is contained in:
parent
d016e27874
commit
7bfd83f83d
@ -1,5 +1,6 @@
|
||||
---
|
||||
- name:
|
||||
- block:
|
||||
- name:
|
||||
yum_repository:
|
||||
name: nginx
|
||||
file: nginx
|
||||
@ -8,12 +9,12 @@
|
||||
gpgkey: https://nginx.org/keys/nginx_signing.key
|
||||
gpgcheck: yes
|
||||
|
||||
- name: Installing nginx
|
||||
- name: Installing nginx
|
||||
yum:
|
||||
name: nginx
|
||||
state: installed
|
||||
|
||||
- name: Prepare vhost directories
|
||||
- name: Prepare vhost directories
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: directory
|
||||
@ -24,7 +25,7 @@
|
||||
- /var/www/vhosts
|
||||
- /var/www/vhosts/default
|
||||
|
||||
- name: Prepare nginx directories
|
||||
- name: Prepare nginx directories
|
||||
file:
|
||||
path: '{{ item }}'
|
||||
state: directory
|
||||
@ -35,15 +36,7 @@
|
||||
- /etc/nginx/sites-available
|
||||
- /etc/nginx/sites-enabled
|
||||
|
||||
- name: Add default page
|
||||
template:
|
||||
src: 'var/www/vhosts/default/index.html.j2'
|
||||
dest: '/var/www/vhosts/default/index.html'
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: 0750
|
||||
|
||||
- name: Update nginx.conf
|
||||
- name: Update nginx.conf
|
||||
template:
|
||||
src: 'etc/nginx/nginx.conf.j2'
|
||||
dest: '/etc/nginx/nginx.conf'
|
||||
@ -53,7 +46,7 @@
|
||||
notify:
|
||||
- nginx_reload
|
||||
|
||||
- name: Update conf.d files
|
||||
- name: Update conf.d files
|
||||
template:
|
||||
src: 'etc/nginx/conf.d/{{ item }}.j2'
|
||||
dest: '/etc/nginx/conf.d/{{ item }}'
|
||||
@ -66,12 +59,12 @@
|
||||
notify:
|
||||
- nginx_reload
|
||||
|
||||
- name: Remove default.conf from conf.d
|
||||
- name: Remove default.conf from conf.d
|
||||
file:
|
||||
path: /etc/nginx/conf.d/default.conf
|
||||
state: absent
|
||||
|
||||
- name: Add default page config
|
||||
- name: Add default page config
|
||||
template:
|
||||
src: 'etc/nginx/sites-available/default.j2'
|
||||
dest: '/etc/nginx/sites-available/default'
|
||||
@ -81,7 +74,7 @@
|
||||
notify:
|
||||
- nginx_reload
|
||||
|
||||
- name: Enable default page
|
||||
- name: Enable default page
|
||||
file:
|
||||
src: /etc/nginx/sites-available/default
|
||||
dest: /etc/nginx/sites-enabled/default
|
||||
@ -91,6 +84,14 @@
|
||||
notify:
|
||||
- nginx_reload
|
||||
|
||||
- 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'
|
||||
become: True
|
||||
become_user: root
|
||||
|
||||
- block:
|
||||
- name: Copy tls certificate
|
||||
copy:
|
||||
@ -142,11 +143,16 @@
|
||||
become_user: root
|
||||
when: nginx_pfs_enabled
|
||||
|
||||
- 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'
|
||||
- block:
|
||||
- name: Add default page
|
||||
template:
|
||||
src: 'var/www/vhosts/default/index.html.j2'
|
||||
dest: '/var/www/vhosts/default/index.html'
|
||||
owner: nginx
|
||||
group: nginx
|
||||
mode: 0750
|
||||
become: True
|
||||
become_user: nginx
|
||||
|
||||
- name: Enable nginx service
|
||||
systemd:
|
||||
|
Loading…
Reference in New Issue
Block a user