executor: perl_iptables_restart 
input:
  backup_file: "/root/iptables.bak"
  i_retry: 5
  i_delay: 3
steps:
- type: pf_api_service_status
  service: "iptables"
  retry: "{{.input.i_retry}}"
  delay: "{{.input.i_delay}}"
  assertions:
    - result.pf_api_service_status_json.alive ShouldEqual 1

- type: exec
  script: /bin/perl -I/usr/local/pf/lib -I/usr/local/pf/lib_perl/lib/perl5 -Mpf::db -Mpf::services::manager::iptables -e 'pf::services::manager::iptables->getIptablesTechnique()->iptables_save("{{ input.backup_file }}")'
  
- type: exec
  script: /bin/perl -I/usr/local/pf/lib -I/usr/local/pf/lib_perl/lib/perl5 -Mpf::db -Mpf::services::manager::iptables -e 'pf::services::manager::iptables->generateConfig()'

- type: exec
  script: iptables-restore < /usr/local/pf/var/conf/iptables.conf
