Don't import tasks in iptables reload and use listen

This syntax doesn't work in Ansible 2.8.0.  Futher, we can use
"listen" to collapse the notify to a single item (at the
expense of duplicating the when clause in the handlers).

Change-Id: I05e2d32f4e1e692ac528a7254c6e3be2858ebacf
This commit is contained in:
James E. Blair 2018-12-03 08:59:30 -08:00
parent 330ffb394b
commit 3706754b6b
4 changed files with 15 additions and 15 deletions

View File

@ -1,11 +1,20 @@
- name: Reload iptables Debian - name: Reload iptables (Debian)
import_tasks: tasks/reload-debian.yaml command: '{{ reload_command }}'
when: when:
- not ansible_facts.is_chroot - not ansible_facts.is_chroot
- ansible_facts.os_family == 'Debian' - ansible_facts.os_family == 'Debian'
listen: "Reload iptables"
- name: Reload iptables RedHat - name: Reload iptables (RedHat)
import_tasks: tasks/reload-redhat.yaml command: 'systemctl reload iptables'
when: when:
- not ansible_facts.is_chroot - not ansible_facts.is_chroot
- ansible_facts.os_family == 'RedHat' - ansible_facts.os_family == 'RedHat'
listen: "Reload iptables"
- name: Reload ip6tables (Red Hat)
command: 'systemctl reload ip6tables'
when:
- not ansible_facts.is_chroot
- ansible_facts.os_family == 'RedHat'
listen: "Reload iptables"

View File

@ -25,8 +25,7 @@
mode: 0640 mode: 0640
setype: '{{ setype | default(omit) }}' setype: '{{ setype | default(omit) }}'
notify: notify:
- Reload iptables Debian - Reload iptables
- Reload iptables RedHat
- name: Install IPv6 rules files - name: Install IPv6 rules files
template: template:
@ -37,8 +36,7 @@
mode: 0640 mode: 0640
setype: '{{ setype | default(omit) }}' setype: '{{ setype | default(omit) }}'
notify: notify:
- Reload iptables Debian - Reload iptables
- Reload iptables RedHat
- name: Include OS specific tasks - name: Include OS specific tasks
include_tasks: "{{ item }}" include_tasks: "{{ item }}"

View File

@ -1,2 +0,0 @@
- name: Reload iptables (Debian)
command: '{{ reload_command }}'

View File

@ -1,5 +0,0 @@
- name: Reload iptables (Red Hat)
command: 'systemctl reload iptables'
- name: Reload ip6tables (Red Hat)
command: 'systemctl reload ip6tables'