- name: FreePBX - Enable & (Re)start 'freepbx' systemd service (if pbx_enabled)
  systemd:
    daemon_reload: yes
    name: freepbx
    enabled: yes
    state: restarted
  when: pbx_enabled

- name: FreePBX - Disable & Stop 'freepbx' systemd service (if not pbx_enabled)
  systemd:
    daemon_reload: yes
    name: freepbx
    enabled: no
    state: stopped
  when: not pbx_enabled

- name: FreePBX - Enable http://box:{{ pbx_http_port }} via Apache, if pbx_enabled    # http://box:83
  command: a2ensite freepbx.conf
  when: pbx_enabled

- name: FreePBX - Disable http://box:{{ pbx_http_port }} via Apache, if not pbx_enabled    # http://box:83
  command: a2dissite freepbx.conf
  when: not pbx_enabled

- name: FreePBX - Restart Apache service ({{ apache_service }})
  systemd:
    name: "{{ apache_service }}"    # httpd or apache2
    state: restarted
