Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to restart iptables from ansible ( Interactive authentication required)

How to restart iptables service from Ansible (in order to reload config file /etc/sysconfig/iptables)

I have handler restart iptables defined as

service: name=iptables enabled=yes state=restarted

But it produces following error message:

fatal: [xx.xx.xx.xx]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to stop iptables.service: Interactive authentication required.\n Failed to start iptables.service: Interactive authentication required.\n"}

I am working with CentOS Linux release 7.2.1511 (Core)

like image 554
Bartosz Bilicki Avatar asked May 18 '16 12:05

Bartosz Bilicki


1 Answers

I was not running my handler command as root. If handler contains become: yes then handler works fine.

- name: restart iptables
  become: yes
  service: name=iptables enabled=yes state=restarted

Another way of refreshing iptables configuration, without restarting it is

- name: reload iptables
  become: yes
  shell: iptables-restore <  /etc/sysconfig/iptables
like image 124
Bartosz Bilicki Avatar answered Nov 04 '22 21:11

Bartosz Bilicki