---
- name: 'Enable firewalld'
  service: name=firewalld state=started enabled=yes

- name: 'Open Apache firewall ports'
  firewalld:
    port: '{{ item }}'
    state: enabled
    permanent: yes
  with_items:
    - 443/tcp
    - 8443/tcp
  register: firewall

- name: 'Restart firewalld'
  service: name=firewalld state=restarted enabled=yes
  when: firewall.changed

- meta: flush_handlers


---
- name: 'Enable firewalld'
  service: name=firewalld state=started enabled=yes

- name: 'Open default Apache firewall ports'
  firewalld:
    port: '{{ item }}'
    state: enabled
    permanent: yes
  with_items:
    - 443/tcp
  register: firewall

- name: 'Open Apache firewall port 8443 for the Backchannel when enabled'
  firewalld:
    port: '{{ item }}'
    state: enabled
    permanent: yes
  with_items:
    - 8443/tcp
  register: firewall
  when: enable_backchannel is defined and enable_backchannel=="ture"

- name: 'Close Apache firewall port 8443 for the Backchannel when disabled'
  firewalld:
    port: '{{ item }}'
    state: disabled
    permanent: yes
  with_items:
    - 8443/tcp
  register: firewall
  when: enable_backchannel is defined and enable_backchannel=="false"

- name: 'Restart firewalld'
  service: name=firewalld state=restarted enabled=yes
  when: firewall.changed

- meta: flush_handlers


Enable or disable port 8443 based on enable_backchannel flag
Enable or disable port 8443 based on enable_backchannel flag
