---
- name: disable ipv6
  lineinfile: dest=/etc/sysctl.conf
    line="net.ipv6.conf.all.disable_ipv6 = 1"
  notify:
    - reload sysctl.conf
  tags:
    - firewall

- name: install iptables services
  yum: name=iptables-services state=present
  tags:
    - firewall
    - yum

- name: disable firewalld
  service: name=firewalld enabled=no state=stopped
  tags:
    - firewall

- name: enable iptables
  service: name=iptables enabled=yes state=started
  tags:
    - firewall

- name: copy iptables template
  template: src=iptables.j2
    dest={{ v_firewall_config }}
    owner=0 group=0 mode=0700
  notify:
    - restart iptables
  tags:
    - firewall

---
- name: disable ipv6 in /etc/sysctl.conf
  lineinfile: dest=/etc/sysctl.conf
    line="{{ item }}"
  with_items:
    - "net.ipv6.conf.all.disable_ipv6 = 1"
    - "net.ipv6.conf.default.disable_ipv6 = 1"
  notify:
    - reload sysctl.conf
  tags:
    - firewall
    - ipv6

- name: remove references to ipv6 in /etc/hosts
  replace: dest=/etc/hosts
    regexp='^(::1)(\s+.*)?$'
    replace='#\1\2'
    backup=yes
  tags:
    - firewall
    - ipv6

- name: install iptables services
  yum: name=iptables-services state=present
  tags:
    - firewall
    - yum

- name: disable firewalld
  service: name=firewalld enabled=no state=stopped
  tags:
    - firewall

- name: enable iptables
  service: name=iptables enabled=yes state=started
  tags:
    - firewall

- name: copy iptables template
  template: src=iptables.j2
    dest={{ v_firewall_config }}
    owner=0 group=0 mode=0700
  notify:
    - restart iptables
  tags:
    - firewall

Comment out ipv6 references in /etc/hosts as it causes postfix to fail when ipv6 is disabled in /etc/sysctl.conf.
Comment out ipv6 references in /etc/hosts as it causes postfix to fail when ipv6 is disabled in /etc/sysctl.conf.
