From: Ingmar Steen Date: Mon, 8 Apr 2013 12:38:27 +0000 (+0200) Subject: (#20125) Add persistence support for Archlinux platform X-Git-Tag: 0.3.0~13^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=763bbd8c28cfde89f9e444f92f8c729619ff955f;p=puppet-modules%2Fpuppetlabs-firewall.git (#20125) Add persistence support for Archlinux platform This only works with facter 1.7.0-rc1 and up because os_key isn't properly defined in facter 1.6.18 on Archlinux (it's set to Linux). --- diff --git a/lib/puppet/util/firewall.rb b/lib/puppet/util/firewall.rb index 47ef27e..5de08c3 100644 --- a/lib/puppet/util/firewall.rb +++ b/lib/puppet/util/firewall.rb @@ -170,6 +170,13 @@ module Puppet::Util::Firewall when :IPv4 ["/bin/sh", "-c", "/sbin/iptables-save > /etc/iptables/rules"] end + when :Archlinux + case proto.to_sym + when :IPv4 + ["/bin/sh", "-c", "/usr/sbin/iptables-save > /etc/iptables/iptables.rules"] + when :IPv6 + ["/bin/sh", "-c", "/usr/sbin/ip6tables-save > /etc/iptables/ip6tables.rules"] + end end # Catch unsupported OSs from the case statement above. diff --git a/spec/unit/puppet/util/firewall_spec.rb b/spec/unit/puppet/util/firewall_spec.rb index 16ae82b..6345966 100644 --- a/spec/unit/puppet/util/firewall_spec.rb +++ b/spec/unit/puppet/util/firewall_spec.rb @@ -108,6 +108,12 @@ describe 'Puppet::Util::Firewall' do subject.persist_iptables(proto) end + it 'should exec for Archlinux identified from osfamily' do + Facter.fact(:osfamily).stubs(:value).returns('Archlinux') + subject.expects(:execute).with(['/bin/sh', '-c', '/usr/sbin/iptables-save > /etc/iptables/iptables.rules']) + subject.persist_iptables(proto) + end + it 'should raise a warning when exec fails' do Facter.fact(:osfamily).stubs(:value).returns('RedHat') subject.expects(:execute).with(%w{/sbin/service iptables save}).