From 763bbd8c28cfde89f9e444f92f8c729619ff955f Mon Sep 17 00:00:00 2001 From: Ingmar Steen Date: Mon, 8 Apr 2013 14:38:27 +0200 Subject: [PATCH] (#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). --- lib/puppet/util/firewall.rb | 7 +++++++ spec/unit/puppet/util/firewall_spec.rb | 6 ++++++ 2 files changed, 13 insertions(+) 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}). -- 2.45.2