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