---
- name: set OS dependent mysql-server variables
  include_vars: "{{ item }}"
  with_first_found:
    - "{{ ansible_distribution }}-{{ ansible_distribution_major_version | int}}.yml"
    - "{{ ansible_distribution }}.yml"
    - "{{ ansible_os_family }}.yml"
    - "default.yml"

- name: install nginx
  package: name=nginx state=installed

- name: disable default site
  file: path=/etc/nginx/sites-enabled/default state=absent
  notify: restart nginx

- name: enable nginx
  service:
    name: nginx
    enabled: yes

- name: configure nginx
  template:
    src: "{{ nginx_conf_template }}"
    dest: /etc/nginx/nginx.conf
    mode: 0644
    owner: root
    group: root
    backup: yes
  notify: restart nginx

- name: Open https port                                                    
  firewalld: service=https permanent=true immediate=true state=enabled     
  when: not close_https_port                                               

- name: Open http port                                                    
  firewalld: service=http permanent=true immediate=true state=enabled     
  when: not close_http_port                                               

- name: set SElinux flags on                                     
  seboolean: name={{ item }} state=yes persistent=yes            
  with_items: "{{ selinux_booleans_enable }}"
  when: ansible_distribution == "RedHat"
