PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/attributes/default.rb

https://github.com/sewer2/cb-iptables-ng
Ruby | 76 lines | 43 code | 8 blank | 25 comment | 1 complexity | 935e43b19afdeb98f300a7c279f1766d MD5 | raw file
  1. #
  2. # Cookbook Name:: iptables-ng
  3. # Attributes:: default
  4. #
  5. # Copyright 2012, Chris Aumann
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. # Packages to install
  21. default['iptables-ng']['packages'] = case node['platform_family']
  22. when 'debian'
  23. %w{iptables iptables-persistent}
  24. when 'rhel'
  25. %w{iptables iptables-ipv6}
  26. else
  27. %w{iptables}
  28. end
  29. # Where the rules are stored and how they are executed
  30. case node['platform']
  31. when 'debian'
  32. # Debian squeeze (and before) only support an outdated version
  33. # of iptables-persistent, which is not capable of ipv6.
  34. # Furthermore, restarting the service doesn't properly reload the rules
  35. if node['platform_version'].to_f < 7.0
  36. # default['iptables-ng']['service_ipv4'] = 'iptables-persistent'
  37. default['iptables-ng']['script_ipv4'] = '/etc/iptables/rules'
  38. default['iptables-ng']['script_ipv6'] = '/etc/iptables/rules.v6'
  39. else
  40. default['iptables-ng']['service_ipv4'] = 'iptables-persistent'
  41. default['iptables-ng']['service_ipv6'] = 'iptables-persistent'
  42. default['iptables-ng']['script_ipv4'] = '/etc/iptables/rules.v4'
  43. default['iptables-ng']['script_ipv6'] = '/etc/iptables/rules.v6'
  44. end
  45. when 'ubuntu'
  46. default['iptables-ng']['service_ipv4'] = 'iptables-persistent'
  47. default['iptables-ng']['service_ipv6'] = 'iptables-persistent'
  48. default['iptables-ng']['script_ipv4'] = '/etc/iptables/rules.v4'
  49. default['iptables-ng']['script_ipv6'] = '/etc/iptables/rules.v6'
  50. when 'redhat', 'centos', 'scientific', 'amazon', 'fedora'
  51. default['iptables-ng']['service_ipv4'] = 'iptables'
  52. default['iptables-ng']['service_ipv6'] = 'ip6tables'
  53. default['iptables-ng']['script_ipv4'] = '/etc/sysconfig/iptables'
  54. default['iptables-ng']['script_ipv6'] = '/etc/sysconfig/ip6tables'
  55. when 'gentoo'
  56. default['iptables-ng']['service_ipv4'] = 'iptables'
  57. default['iptables-ng']['service_ipv6'] = 'ip6tables'
  58. default['iptables-ng']['script_ipv4'] = '/var/lib/iptables/rules-save'
  59. default['iptables-ng']['script_ipv6'] = '/var/lib/ip6tables/rules-save'
  60. when 'arch'
  61. default['iptables-ng']['service_ipv4'] = 'iptables'
  62. default['iptables-ng']['service_ipv6'] = 'ip6tables'
  63. default['iptables-ng']['script_ipv4'] = '/etc/iptables/iptables.rules'
  64. default['iptables-ng']['script_ipv6'] = '/etc/iptables/ip6tables.rules'
  65. else
  66. default['iptables-ng']['script_ipv4'] = '/etc/iptables-rules.ipt'
  67. default['iptables-ng']['script_ipv6'] = '/etc/ip6tables-rules.ipt'
  68. end