---
# tasks file

- name: Main... Show Selinux variable
  debug: var=ansible_selinux

- name: Main... collect facts about system services
  service_facts:
  register: services_state
  no_log: true

- name: Main... Set nb_web_servers based on web_servers group
  set_fact:
    nb_web_servers: "{{ groups['web_servers'] | length }}"
  when: "'web_servers' in groups.keys()"

- name: Main... Set nb_web_servers if no web_servers group
  set_fact:
    nb_web_servers: 1
  when: "'web_servers' not in groups.keys()"

- name: Set my_redis_service host variable
  set_fact:
    my_redis_service: "{{ ansible_facts.services['%s.service' % (redis_daemon)] }}"
  when: ('%s.service' % (redis_daemon)) in ansible_facts.services.keys()

- name: Check Redis status
  debug:
    var: my_redis_service
  when: ('%s.service' % (redis_daemon)) in ansible_facts.services.keys()

- include_tasks: "web/{{ ansible_distribution }}.yml"

- include_tasks: "php/{{ ansible_distribution }}.yml"

  #- include_tasks: "ssl.yml"

- name: Main... Check Selinux
  include_tasks: "selinux.yml"
  when: ansible_selinux.status == "enabled"

- name: Main... Restart {{ http_service_name }} service
  service:
    name: "{{ http_service_name }}"
    state: restarted
