2020-02-05 08:15:57 +00:00
- hosts : "{{ variable_host }}"
become : yes
become_method : sudo
tasks :
2020-03-15 10:52:29 +00:00
- name : Set SSH port
set_fact :
ansible_port : "{{SSH_PORT}}"
2020-04-07 18:16:12 +00:00
2020-02-05 08:15:57 +00:00
- name : check if Nginx is installed
package_facts :
manager : "auto"
- name : populate service facts
service_facts :
2020-04-07 18:16:12 +00:00
2020-02-05 08:15:57 +00:00
- name : Creates directory
file :
path : /etc/nginx
state : directory
when : "'nginx' not in ansible_facts.packages"
2020-04-07 18:16:12 +00:00
2020-02-05 08:15:57 +00:00
- name : Creates directory
file :
path : /etc/nginx/conf.d
state : directory
when : "'nginx' not in ansible_facts.packages"
2020-08-14 15:00:58 +00:00
- name : Set passlib version
set_fact :
passlib_ver : "python3-passlib"
2021-08-03 06:30:47 +00:00
when : (ansible_facts['distribution_major_version'] == '8' and (ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS')) or (ansible_facts['os_family'] == 'Debian' or ansible_facts['os_family'] == 'Ubuntu')
2020-08-14 15:00:58 +00:00
ignore_errors : True
- name : Set passlib version
set_fact :
2020-08-16 07:22:09 +00:00
passlib_ver : "python-passlib"
2021-08-03 06:30:47 +00:00
when : ansible_facts['distribution_major_version'] == '7'
2020-08-14 15:00:58 +00:00
ignore_errors : True
2020-02-05 08:15:57 +00:00
- name : Install passlib
package :
2020-08-14 15:00:58 +00:00
name : "{{passlib_ver}}"
2020-02-05 08:15:57 +00:00
state : present
when : "'nginx' not in ansible_facts.packages"
environment :
http_proxy : "{{PROXY}}"
https_proxy : "{{PROXY}}"
2020-04-07 18:16:12 +00:00
2020-02-05 08:15:57 +00:00
- name : Copy Nginx configuration in place.
template :
2020-06-13 13:29:47 +00:00
src : /var/www/haproxy-wi/app/scripts/ansible/roles/default.conf.j2
2020-02-05 08:15:57 +00:00
dest : "{{CONFIG_PATH}}"
mode : 0644
when : "'nginx' not in ansible_facts.packages"
2020-03-24 13:00:09 +00:00
ignore_errors : yes
2020-04-07 18:16:12 +00:00
2020-03-24 13:00:09 +00:00
- name : Open stat port for firewalld
firewalld :
port : "{{ STAT_PORT }}/tcp"
state : enabled
permanent : yes
immediate : yes
2020-03-24 09:45:44 +00:00
ignore_errors : yes
2020-03-24 13:00:09 +00:00
no_log : True
debugger : never
2021-03-04 05:53:27 +00:00
when :
- '"firewalld" in ansible_facts.packages'
- ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS'
- ansible_facts.services["firewalld.service"]['state'] == "running"
2020-04-07 18:16:12 +00:00
2020-02-05 08:15:57 +00:00
2020-04-07 18:16:12 +00:00
- name : Open stat port for iptables
iptables :
chain : INPUT
destination_port : "{{ STAT_PORT }}"
jump : ACCEPT
protocol : tcp
ignore_errors : yes
2020-02-05 08:15:57 +00:00
- htpasswd :
path : /etc/nginx/status_page_passwdfile
name : "{{STATS_USER}}"
password : "{{STATS_PASS}}"
when : "'nginx' not in ansible_facts.packages"
2020-04-05 10:08:15 +00:00
- name : test to see if selinux is running
command : getenforce
register : sestatus
changed_when : false
2021-08-03 06:30:47 +00:00
when : ansible_facts['os_family'] == "RedHat" or ansible_facts['os_family'] == 'CentOS'
2020-04-05 10:08:15 +00:00
2020-03-23 18:56:09 +00:00
2020-03-17 18:20:59 +00:00
- name : Disble SELINUX in config
2020-03-23 18:56:09 +00:00
template :
src : /var/www/haproxy-wi/app/scripts/ansible/roles/haproxy/templates/selinux.j2
dest : /etc/selinux/config
2020-03-24 09:45:44 +00:00
ignore_errors : yes
2021-08-03 06:30:47 +00:00
when :
- sestatus.stdout is defined
- '"Enforcing" in sestatus.stdout'
2020-04-05 10:08:15 +00:00
2020-03-17 18:20:59 +00:00
- name : Disble SELINUX in env
2020-04-05 10:08:15 +00:00
shell : setenforce 0
2020-03-24 09:45:44 +00:00
ignore_errors : yes
2020-03-24 13:00:09 +00:00
debugger : never
2021-08-03 06:30:47 +00:00
when :
- sestatus.stdout is defined
- '"Enforcing" in sestatus.stdout'
2020-04-05 10:08:15 +00:00
2020-03-17 18:20:59 +00:00
2020-02-05 08:15:57 +00:00
- hosts : "{{ variable_host }}"
become : yes
become_method : sudo
tasks :
- name : Add syn_flood tasks
include : haproxy/tasks/syn_flood.yml
when : (SYN_FLOOD is defined) and (SYN_FLOOD|length > 0)
roles :
- role : nginxinc.nginx
environment :
http_proxy : "{{PROXY}}"
https_proxy : "{{PROXY}}"