12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- ---
- - name: Install firewalld packages
- package: name=firewalld state=present
- when: not openshift.common.is_containerized | bool
- register: install_result
- - name: Check if iptables-services is installed
- command: rpm -q iptables-services
- register: pkg_check
- failed_when: pkg_check.rc > 1
- changed_when: no
- - name: Ensure iptables services are not enabled
- service:
- name: "{{ item }}"
- state: stopped
- enabled: no
- with_items:
- - iptables
- - ip6tables
- when: pkg_check.rc == 0
- - name: Reload systemd units
- command: systemctl daemon-reload
- when: install_result | changed
- - name: Determine if firewalld service masked
- command: >
- systemctl is-enabled firewalld
- register: os_firewall_firewalld_masked_output
- changed_when: false
- failed_when: false
- - name: Unmask firewalld service
- command: >
- systemctl unmask firewalld
- when: os_firewall_firewalld_masked_output.stdout == "masked"
- - name: Start and enable firewalld service
- service:
- name: firewalld
- state: started
- enabled: yes
- register: result
- - name: need to pause here, otherwise the firewalld service starting can sometimes cause ssh to fail
- pause: seconds=10
- when: result | changed
- - name: Mask iptables services
- command: systemctl mask "{{ item }}"
- register: result
- changed_when: "'iptables' in result.stdout"
- with_items:
- - iptables
- - ip6tables
- when: pkg_check.rc == 0
- ignore_errors: yes
- # TODO: Ansible 1.9 will eliminate the need for separate firewalld tasks for
- # enabling rules and making them permanent with the immediate flag
- - name: Add firewalld allow rules
- firewalld:
- port: "{{ item.port }}"
- permanent: false
- state: enabled
- with_items: "{{ os_firewall_allow }}"
- - name: Persist firewalld allow rules
- firewalld:
- port: "{{ item.port }}"
- permanent: true
- state: enabled
- with_items: "{{ os_firewall_allow }}"
- - name: Remove firewalld allow rules
- firewalld:
- port: "{{ item.port }}"
- permanent: false
- state: disabled
- with_items: "{{ os_firewall_deny }}"
- - name: Persist removal of firewalld allow rules
- firewalld:
- port: "{{ item.port }}"
- permanent: true
- state: disabled
- with_items: "{{ os_firewall_deny }}"
|