cloud-mu 3.6.10 → 3.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Berksfile +2 -3
  3. data/Berksfile.lock +11 -14
  4. data/bin/mu-aws-setup +16 -4
  5. data/bin/mu-configure +2 -1
  6. data/cloud-mu.gemspec +2 -2
  7. data/cookbooks/mu-firewall/Berksfile +1 -1
  8. data/cookbooks/mu-firewall/attributes/default.rb +2 -2
  9. data/cookbooks/mu-firewall/metadata.rb +3 -3
  10. data/cookbooks/mu-firewall/recipes/default.rb +11 -2
  11. data/cookbooks/mu-master/Berksfile +1 -1
  12. data/cookbooks/mu-master/attributes/default.rb +14 -1
  13. data/cookbooks/mu-master/files/default/389ds-perl/ASDialogs.pm +173 -0
  14. data/cookbooks/mu-master/files/default/389ds-perl/AdminMigration.pm +569 -0
  15. data/cookbooks/mu-master/files/default/389ds-perl/AdminServer.pm +952 -0
  16. data/cookbooks/mu-master/files/default/389ds-perl/AdminUtil.pm +983 -0
  17. data/cookbooks/mu-master/files/default/389ds-perl/ConfigDSDialogs.pm +449 -0
  18. data/cookbooks/mu-master/files/default/389ds-perl/DSCreate.pm +1551 -0
  19. data/cookbooks/mu-master/files/default/389ds-perl/DSDialogs.pm +233 -0
  20. data/cookbooks/mu-master/files/default/389ds-perl/DSMigration.pm +1175 -0
  21. data/cookbooks/mu-master/files/default/389ds-perl/DSUpdate.pm +534 -0
  22. data/cookbooks/mu-master/files/default/389ds-perl/DSUpdateDialogs.pm +152 -0
  23. data/cookbooks/mu-master/files/default/389ds-perl/DSUtil.pm +1710 -0
  24. data/cookbooks/mu-master/files/default/389ds-perl/Dialog.pm +249 -0
  25. data/cookbooks/mu-master/files/default/389ds-perl/DialogManager.pm +212 -0
  26. data/cookbooks/mu-master/files/default/389ds-perl/FileConn.pm +461 -0
  27. data/cookbooks/mu-master/files/default/389ds-perl/Inf.pm +268 -0
  28. data/cookbooks/mu-master/files/default/389ds-perl/Migration.pm +327 -0
  29. data/cookbooks/mu-master/files/default/389ds-perl/RegDSDialogs.pm +94 -0
  30. data/cookbooks/mu-master/files/default/389ds-perl/Resource.pm +137 -0
  31. data/cookbooks/mu-master/files/default/389ds-perl/Setup.pm +240 -0
  32. data/cookbooks/mu-master/files/default/389ds-perl/SetupDialogs.pm +243 -0
  33. data/cookbooks/mu-master/files/default/389ds-perl/SetupLog.pm +82 -0
  34. data/cookbooks/mu-master/files/default/setCertName.ldif +4 -0
  35. data/cookbooks/mu-master/libraries/mu.rb +2 -2
  36. data/cookbooks/mu-master/metadata.rb +1 -1
  37. data/cookbooks/mu-master/recipes/389ds.rb +71 -32
  38. data/cookbooks/mu-master/recipes/basepackages.rb +5 -0
  39. data/cookbooks/mu-master/recipes/default.rb +16 -5
  40. data/cookbooks/mu-master/recipes/init.rb +36 -3
  41. data/cookbooks/mu-master/recipes/ssl-certs.rb +6 -0
  42. data/cookbooks/mu-master/recipes/sssd.rb +85 -62
  43. data/cookbooks/mu-master/recipes/update_nagios_only.rb +7 -1
  44. data/cookbooks/mu-master/templates/default/389-directory-setup.inf.erb +11 -26
  45. data/cookbooks/mu-master/templates/default/sssd.conf.erb +18 -8
  46. data/cookbooks/mu-tools/files/default/Mu_CA.pem +33 -0
  47. data/cookbooks/mu-tools/metadata.rb +0 -1
  48. data/cookbooks/mu-tools/recipes/set_local_fw.rb +7 -1
  49. data/cookbooks/mu-tools/templates/amazon/sshd_config.erb +5 -1
  50. data/cookbooks/nagios/CHANGELOG.md +679 -0
  51. data/cookbooks/nagios/LICENSE +201 -0
  52. data/cookbooks/nagios/README.md +340 -0
  53. data/cookbooks/nagios/attributes/config.rb +163 -0
  54. data/cookbooks/nagios/attributes/default.rb +204 -0
  55. data/cookbooks/nagios/libraries/base.rb +311 -0
  56. data/cookbooks/nagios/libraries/command.rb +68 -0
  57. data/cookbooks/nagios/libraries/contact.rb +229 -0
  58. data/cookbooks/nagios/libraries/contactgroup.rb +111 -0
  59. data/cookbooks/{firewall/recipes/disable_firewall.rb → nagios/libraries/custom_option.rb} +20 -7
  60. data/cookbooks/nagios/libraries/data_bag_helper.rb +23 -0
  61. data/cookbooks/nagios/libraries/default.rb +90 -0
  62. data/cookbooks/nagios/libraries/helpers.rb +229 -0
  63. data/cookbooks/nagios/libraries/host.rb +410 -0
  64. data/cookbooks/nagios/libraries/hostdependency.rb +178 -0
  65. data/cookbooks/nagios/libraries/hostescalation.rb +170 -0
  66. data/cookbooks/nagios/libraries/hostgroup.rb +117 -0
  67. data/cookbooks/nagios/libraries/nagios.rb +277 -0
  68. data/cookbooks/nagios/libraries/resource.rb +59 -0
  69. data/cookbooks/nagios/libraries/service.rb +449 -0
  70. data/cookbooks/nagios/libraries/servicedependency.rb +213 -0
  71. data/cookbooks/nagios/libraries/serviceescalation.rb +193 -0
  72. data/cookbooks/nagios/libraries/servicegroup.rb +142 -0
  73. data/cookbooks/nagios/libraries/timeperiod.rb +159 -0
  74. data/cookbooks/nagios/libraries/users_helper.rb +54 -0
  75. data/cookbooks/nagios/metadata.json +44 -0
  76. data/cookbooks/nagios/metadata.rb +22 -0
  77. data/cookbooks/nagios/recipes/_load_databag_config.rb +153 -0
  78. data/cookbooks/nagios/recipes/_load_default_config.rb +241 -0
  79. data/cookbooks/nagios/recipes/apache.rb +114 -0
  80. data/cookbooks/nagios/recipes/default.rb +41 -0
  81. data/cookbooks/nagios/recipes/nginx.rb +114 -0
  82. data/cookbooks/nagios/recipes/pagerduty.rb +95 -0
  83. data/cookbooks/nagios/recipes/server.rb +182 -0
  84. data/cookbooks/nagios/recipes/server_package.rb +85 -0
  85. data/cookbooks/nagios/recipes/server_source.rb +137 -0
  86. data/cookbooks/nagios/resources/command.rb +34 -0
  87. data/cookbooks/nagios/resources/conf.rb +52 -0
  88. data/cookbooks/nagios/resources/contact.rb +34 -0
  89. data/cookbooks/nagios/resources/contactgroup.rb +35 -0
  90. data/cookbooks/nagios/resources/host.rb +35 -0
  91. data/cookbooks/nagios/resources/hostdependency.rb +35 -0
  92. data/cookbooks/nagios/resources/hostescalation.rb +36 -0
  93. data/cookbooks/nagios/resources/hostgroup.rb +35 -0
  94. data/cookbooks/nagios/resources/resource.rb +34 -0
  95. data/cookbooks/nagios/resources/service.rb +35 -0
  96. data/cookbooks/nagios/resources/servicedependency.rb +35 -0
  97. data/cookbooks/nagios/resources/serviceescalation.rb +35 -0
  98. data/cookbooks/nagios/resources/servicegroup.rb +35 -0
  99. data/cookbooks/nagios/resources/timeperiod.rb +35 -0
  100. data/cookbooks/nagios/templates/apache2.conf.erb +102 -0
  101. data/cookbooks/nagios/templates/cgi.cfg.erb +266 -0
  102. data/cookbooks/nagios/templates/commands.cfg.erb +13 -0
  103. data/cookbooks/nagios/templates/contacts.cfg.erb +37 -0
  104. data/cookbooks/nagios/templates/hostgroups.cfg.erb +25 -0
  105. data/cookbooks/nagios/templates/hosts.cfg.erb +15 -0
  106. data/cookbooks/nagios/templates/htpasswd.users.erb +6 -0
  107. data/cookbooks/nagios/templates/nagios.cfg.erb +22 -0
  108. data/cookbooks/nagios/templates/nginx.conf.erb +80 -0
  109. data/cookbooks/nagios/templates/pagerduty.cgi.erb +185 -0
  110. data/cookbooks/nagios/templates/resource.cfg.erb +27 -0
  111. data/cookbooks/nagios/templates/servicedependencies.cfg.erb +15 -0
  112. data/cookbooks/nagios/templates/servicegroups.cfg.erb +14 -0
  113. data/cookbooks/nagios/templates/services.cfg.erb +14 -0
  114. data/cookbooks/nagios/templates/spawn-fcgi.erb +10 -0
  115. data/cookbooks/nagios/templates/templates.cfg.erb +31 -0
  116. data/cookbooks/nagios/templates/timeperiods.cfg.erb +13 -0
  117. data/extras/platform_berksfile_base +3 -3
  118. data/extras/python_rpm/build.sh +4 -4
  119. data/extras/python_rpm/muthon.spec +2 -4
  120. data/extras/vault_tools/export_vaults.sh +11 -1
  121. data/install/installer +1 -1
  122. data/modules/mu/kittens.rb +27523 -0
  123. data/modules/mu/master/ldap.rb +48 -31
  124. data/modules/mu/master.rb +69 -0
  125. data/modules/mu/mu.yaml.rb +351 -0
  126. data/modules/mu/providers/aws/firewall_rule.rb +3 -1
  127. data/modules/mu/providers/aws.rb +11 -5
  128. data/modules/mu.rb +5 -4
  129. metadata +99 -48
  130. data/cookbooks/firewall/CHANGELOG.md +0 -488
  131. data/cookbooks/firewall/LICENSE +0 -202
  132. data/cookbooks/firewall/README.md +0 -366
  133. data/cookbooks/firewall/TODO.md +0 -6
  134. data/cookbooks/firewall/attributes/default.rb +0 -5
  135. data/cookbooks/firewall/attributes/firewalld.rb +0 -8
  136. data/cookbooks/firewall/attributes/iptables.rb +0 -17
  137. data/cookbooks/firewall/attributes/ufw.rb +0 -12
  138. data/cookbooks/firewall/attributes/windows.rb +0 -8
  139. data/cookbooks/firewall/libraries/helpers.rb +0 -105
  140. data/cookbooks/firewall/libraries/helpers_firewalld.rb +0 -116
  141. data/cookbooks/firewall/libraries/helpers_firewalld_dbus.rb +0 -72
  142. data/cookbooks/firewall/libraries/helpers_iptables.rb +0 -112
  143. data/cookbooks/firewall/libraries/helpers_nftables.rb +0 -170
  144. data/cookbooks/firewall/libraries/helpers_ufw.rb +0 -142
  145. data/cookbooks/firewall/libraries/helpers_windows.rb +0 -129
  146. data/cookbooks/firewall/libraries/provider_firewall_firewalld.rb +0 -179
  147. data/cookbooks/firewall/libraries/provider_firewall_iptables.rb +0 -171
  148. data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu.rb +0 -200
  149. data/cookbooks/firewall/libraries/provider_firewall_iptables_ubuntu1404.rb +0 -200
  150. data/cookbooks/firewall/libraries/provider_firewall_rule.rb +0 -34
  151. data/cookbooks/firewall/libraries/provider_firewall_ufw.rb +0 -138
  152. data/cookbooks/firewall/libraries/provider_firewall_windows.rb +0 -126
  153. data/cookbooks/firewall/libraries/resource_firewall.rb +0 -26
  154. data/cookbooks/firewall/libraries/resource_firewall_rule.rb +0 -52
  155. data/cookbooks/firewall/metadata.json +0 -40
  156. data/cookbooks/firewall/metadata.rb +0 -15
  157. data/cookbooks/firewall/recipes/default.rb +0 -76
  158. data/cookbooks/firewall/recipes/firewalld.rb +0 -87
  159. data/cookbooks/firewall/resources/firewalld.rb +0 -28
  160. data/cookbooks/firewall/resources/firewalld_config.rb +0 -39
  161. data/cookbooks/firewall/resources/firewalld_helpers.rb +0 -106
  162. data/cookbooks/firewall/resources/firewalld_icmptype.rb +0 -88
  163. data/cookbooks/firewall/resources/firewalld_ipset.rb +0 -104
  164. data/cookbooks/firewall/resources/firewalld_policy.rb +0 -115
  165. data/cookbooks/firewall/resources/firewalld_service.rb +0 -98
  166. data/cookbooks/firewall/resources/firewalld_zone.rb +0 -118
  167. data/cookbooks/firewall/resources/nftables.rb +0 -71
  168. data/cookbooks/firewall/resources/nftables_rule.rb +0 -113
  169. data/cookbooks/firewall/templates/default/ufw/default.erb +0 -13
  170. /data/cookbooks/{firewall → nagios}/chefignore +0 -0
  171. /data/cookbooks/{firewall → nagios}/renovate.json +0 -0
@@ -1,366 +0,0 @@
1
- # firewall Cookbook
2
-
3
- [![Cookbook Version](https://img.shields.io/cookbook/v/firewall.svg)](https://supermarket.chef.io/cookbooks/firewall)
4
- [![CI State](https://github.com/sous-chefs/firewall/workflows/ci/badge.svg)](https://github.com/sous-chefs/firewall/actions?query=workflow%3Aci)
5
- [![OpenCollective](https://opencollective.com/sous-chefs/backers/badge.svg)](#backers)
6
- [![OpenCollective](https://opencollective.com/sous-chefs/sponsors/badge.svg)](#sponsors)
7
- [![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
8
-
9
- Provides a set of primitives for managing firewalls and associated rules.
10
-
11
- PLEASE NOTE - The resource/providers in this cookbook are under heavy development. An attempt is being made to keep the resource simple/stupid by starting with less sophisticated firewall implementations first and refactor/vet the resource definition with each successive provider.
12
-
13
- ## Maintainers
14
-
15
- This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit [sous-chefs.org](https://sous-chefs.org/) or come chat with us on the Chef Community Slack in [#sous-chefs](https://chefcommunity.slack.com/messages/C2V7B88SF).
16
-
17
- ## Requirements
18
-
19
- - Chef Infra Client 15.5+
20
-
21
- ```ruby
22
- depends 'firewall'
23
- ```
24
-
25
- ### Supported firewalls and platforms
26
-
27
- - UFW - Ubuntu, Debian (except 9)
28
- - IPTables - Red Hat & CentOS, Ubuntu
29
- - FirewallD - Red Hat & CentOS >= 7.0 (IPv4 only support, [needs contributions/testing](https://github.com/chef-cookbooks/firewall/issues/86))
30
- - Windows Advanced Firewall - 2012 R2
31
- - nftables
32
-
33
- Tested on:
34
-
35
- - Ubuntu 16.04 with iptables, ufw
36
- - Debian 9 with iptables
37
- - Debian 11 with nftables
38
- - Debian 11 with new resources for firewalld
39
- - CentOS 6 with iptables
40
- - CentOS 7.1 with firewalld
41
- - Oracle 8 with nftables
42
- - Windows Server 2012r2 with Windows Advanced Firewall
43
-
44
- By default, Ubuntu chooses ufw. To switch to iptables, set this in an attribute file:
45
-
46
- ```ruby
47
- default['firewall']['ubuntu_iptables'] = true
48
- ```
49
-
50
- By default, Red Hat & CentOS >= 7.0 chooses firewalld. To switch to iptables, set this in an attribute file:
51
-
52
- ```ruby
53
- default['firewall']['redhat7_iptables'] = true
54
- ```
55
-
56
- In order to use nftables, just use the resource `nftables` and
57
- `nftables_rule`. These resources are written in more modern design
58
- styles and are not configurable by node attributes.
59
-
60
- ## Considerations that apply to all firewall providers and resources
61
-
62
- This cookbook comes with two resources, firewall and firewall rule. The typical usage scenario is as follows:
63
-
64
- - run the `:install` action on the `firewall` resource named 'default', which installs appropriate packages and configures services to start on boot and starts them
65
- - run the `:create` action on every `firewall_rule` resource, which adds to the list of rules that should be configured on the firewall. `firewall_rule` then automatically sends a delayed notification to the `firewall['default']` resource to run the `:restart` action.
66
- - run the delayed notification with action `:restart` on the `firewall` resource. if any rules are different than the last run, the provider will update the current state of the firewall rules to match the expected rules.
67
-
68
- There is a fundamental mismatch between the idea of a chef action and the action that should be taken on a firewall rule. For this reason, the chef action for a firewall_rule may be `:nothing` (the rule should not be present in the firewall) or `:create` (the rule should be present in the firewall), but the action taken on a packet in a firewall (`DROP`, `ACCEPT`, etc) is denoted as a `command` parameter on the `firewall_rule` resource.
69
-
70
- The same points hold for the `nftables`- and `nftables_rule`-resources.
71
-
72
- ## iptables considerations
73
-
74
- If you need to use a table other than `*filter`, the best way to do so is like so:
75
-
76
- ```ruby
77
- node.default['firewall']['iptables']['defaults'][:ruleset] = {
78
- '*filter' => 1,
79
- ':INPUT DROP' => 2,
80
- ':FORWARD DROP' => 3,
81
- ':OUTPUT ACCEPT_FILTER' => 4,
82
- 'COMMIT_FILTER' => 100,
83
- '*nat' => 101,
84
- ':PREROUTING DROP' => 102,
85
- ':POSTROUTING DROP' => 103,
86
- ':OUTPUT ACCEPT_NAT' => 104,
87
- 'COMMIT_NAT' => 200
88
- }
89
- ```
90
-
91
- Note -- in order to support multiple hash keys containing the same rule, anything found after the underscore will be stripped for: `:OUTPUT :INPUT :POSTROUTING :PREROUTING COMMIT`. This allows an example like the above to be reduced to just repeated lines of `COMMIT` and `:OUTPUT ACCEPT` while still avoiding duplication of other things.
92
-
93
- Then it's trivial to add additional rules to the `*nat` table using the raw parameter:
94
-
95
- ```ruby
96
- firewall_rule "postroute" do
97
- raw "-A POSTROUTING -o eth1 -p tcp -d 172.28.128.21 -j SNAT --to-source 172.28.128.6"
98
- position 150
99
- end
100
- ```
101
-
102
- Note that any line starting with `COMMIT` will become just `COMMIT`, as hash
103
- keys must be unique but we need multiple commit lines.
104
-
105
- ## nftables
106
-
107
- Please read the documentation for the
108
- [`nftables` resource](documentation/resource_nftables.md) and the
109
- [`nftables_rule` resource](documentation/resource_nftables_rule.md)
110
-
111
- ### default
112
-
113
- The default recipe creates a firewall resource with action install.
114
-
115
- ### disable_firewall
116
-
117
- Used to disable platform specific firewall. Many clouds have their own firewall configured outside of the OS instance such as AWS Security Groups.
118
-
119
- ### firewalld
120
-
121
- A firewalld specific recipe creates a firewall resource with action install with the default zone (default: `drop`)
122
-
123
- ## Attributes
124
-
125
- - `default['firewall']['allow_ssh'] = false`, set true to open port 22 for SSH when the default recipe runs
126
- - `default['firewall']['allow_mosh'] = false`, set to true to open UDP ports 60000 - 61000 for [Mosh][0] when the default recipe runs
127
- - `default['firewall']['allow_winrm'] = false`, set true to open port 5989 for WinRM when the default recipe runs
128
- - `default['firewall']['allow_loopback'] = false`, set to true to allow all traffic on the loopback interface
129
- - `default['firewall']['allow_icmp'] = false`, set true to allow icmp protocol on supported OSes (note: ufw and windows implementations don't support this)
130
- - `default['firewall']['ubuntu_iptables'] = false`, set to true to use iptables on Ubuntu / Debian when using the default recipe
131
- - `default['firewall']['redhat7_iptables'] = false`, set to true to use iptables on Red Hat / CentOS 7 when using the default recipe
132
- - `default['firewall']['ufw']['defaults']` hash for template `/etc/default/ufw`
133
- - `default['firewall']['iptables']['defaults']` hash for default policies for 'filter' table's chains`
134
- - `default['firewall']['windows']['defaults']` hash to define inbound / outbound firewall policy on Windows platform
135
- - `default['firewall']['allow_established'] = true`, set to false if you don't want a related/established default rule on iptables
136
- - `default['firewall']['ipv6_enabled'] = true`, set to false if you don't want IPv6 related/established default rule on iptables (this enables ICMPv6, which is required for much of IPv6 communication)
137
- - `default['firewall']['firewalld']['permanent'] = false`, set to true if you want firewalld rules to be added with `--permanent` so they survive a reboot. This will be changed to `true` by default in a future major version release.
138
- - `default['firewall']['firewalld']['permanent'] = false`, set to true if you want firewalld rules to be added with `--permanent` so they survive a reboot. This will be changed to `true` by default in a future major version release.
139
- - `default['firewall']['firewalld']['zone'] = 'drop'`, Default zone for firewall
140
- - `default['firewall']['firewalld']['loopback_zone'] = 'trusted'`, zone for loopback to be enabled (using `allow_loopback`)
141
- - `default['firewall']['firewalld']['icmp_zone'] = 'public'`, zone for icmp to be enabled (using `allow_icmp`)
142
- - `default['firewall']['firewalld']['ssh_zone'] = 'public'`, zone for ssh to be enabled (using `allow_ssh`)
143
- - `default['firewall']['firewalld']['mosh_zone'] = 'public'`, zone for mosh to be enabled (using `allow_mosh`)
144
- - `default['firewall']['firewalld']['established_zone'] = 'public'`, zone for loopback to be enabled (using `allow_established`)
145
-
146
- ## Resources
147
-
148
- There is a separate folder for [`firewalld` resources](documentation/README.md).
149
-
150
- ### firewall
151
-
152
- ***NB***: The name 'default' of this resource is important as it is used for firewall_rule providers to locate the firewall resource. If you change it, you must also supply the same value to any firewall_rule resources using the `firewall_name` parameter.
153
-
154
- #### Actions
155
-
156
- - `:install` (*default action*): Install and Enable the firewall. This will ensure the appropriate packages are installed and that any services have been started.
157
- - `:disable`: Disable the firewall. Drop any rules and put the node in an unprotected state. Flush all current rules. Also erase any internal state used to detect when rules should be applied.
158
- - `:flush`: Flush all current rules. Also erase any internal state used to detect when rules should be applied.
159
- - `:save`: Ensure all rules are added permanently under firewalld using `--permanent`. Not supported on ufw, iptables. You must notify this action at the end of the chef run if you want permanent firewalld rules (they are not persistent by default).
160
-
161
- #### Parameters
162
-
163
- - `disabled` (default to `false`): If set to true, all actions will no-op on this resource. This is a way to prevent included cookbooks from configuring a firewall.
164
- - `ipv6_enabled` (default to `true`): If set to false, firewall will not perform any ipv6 related work. Currently only supported in iptables.
165
- - `log_level`: UFW only. Level of verbosity the firewall should log at. valid values are: :low, :medium, :high, :full, :off. default is :low.
166
- - `rules`: This is used internally for firewall_rule resources to append their rules. You should NOT touch this value unless you plan to supply an entire firewall ruleset at once, and skip using firewall_rule resources.
167
- - `disabled_zone` (firewalld only): The zone to set on firewalld when the firewall should be disabled. Can be any string in symbol form, e.g. :public, :drop, etc. Defaults to `:public.`
168
- - `enabled_zone` (firewalld only): The zone to set on firewalld when the firewall should be enabled. Can be any string in symbol form, e.g. :public, :drop, etc. Defaults to `:drop.`
169
- - `package_options`: Used to pass options to the package install of firewall
170
-
171
- ```ruby
172
- # all defaults
173
- firewall 'default'
174
-
175
- # enable platform default firewall
176
- firewall 'default' do
177
- action :install
178
- end
179
-
180
- # increase logging past default of 'low'
181
- firewall 'default' do
182
- log_level :high
183
- action :install
184
- end
185
- ```
186
-
187
- ### firewall_rule
188
-
189
- #### Actions
190
-
191
- - `:create` (*default action*): If a firewall_rule runs this action, the rule will be recorded in a chef resource's internal state, and applied when providers automatically notify the firewall resource with action `:reload`. The notification happens automatically.
192
-
193
- #### Parameters
194
-
195
- - `firewall_name`: the matching firewall resource that this rule applies to. Default value: `default`
196
- - `raw`: Used to pass an entire rule as a string, omitting all other parameters. This line will be directly loaded by `iptables-restore`, fed directly into `ufw` on the command line, or run using `firewall-cmd`.
197
- - `description` (*default: same as rule name*): Used to provide a comment that will be included when adding the firewall rule.
198
- - `include_comment` (*default: true*): Used to optionally exclude the comment in the rule.
199
- - `position` (*default: 50*): **relative** position to insert rule at. Position may be any integer between 0 < n < 100 (exclusive), and more than one rule may specify the same position.
200
- - `command`: What action to take on a particular packet
201
- - `:allow` (*default action*): the rule should allow matching packets
202
- - `:deny`: the rule should deny matching packets
203
- - `:reject`: the rule should reject matching packets
204
- - `:masquerade`: Masquerade the matching packets
205
- - `:redirect`: Redirect the matching packets
206
- - `:log`: Configure logging
207
- - `stateful`: a symbol or array of symbols, such as ``[:related, :established]` that will be passed to the state module in iptables or firewalld.
208
- - `zone`: (*firewalld only*), a string, such as `public` that the rule will be applied.
209
- - `protocol`: `:tcp` (*default*), `:udp`, `:icmp`, `:none` or protocol number. Using protocol numbers is not supported using the ufw provider (default for debian/ubuntu systems).
210
- - `direction`: For ufw, direction of the rule. valid values are: `:in` (*default*), `:out`, `:pre`, `:post`.
211
- - `source` (*Default is `0.0.0.0/0` or `Anywhere`*): source ip address or subnet to filter.
212
- - `source_port` (*Default is nil*): source port for filtering packets.
213
- - `destination`: ip address or subnet to filter on packet destination, must be a valid IP
214
- - `port` or `dest_port`: target port number (ie. 22 to allow inbound SSH), or an array of incoming port numbers (ie. [80,443] to allow inbound HTTP & HTTPS).
215
- NOTE: `protocol` attribute is required with multiple ports, or a range of incoming port numbers (ie. 60000..61000 to allow inbound mobile-shell. NOTE: `protocol`, or an attribute is required with a range of ports.
216
- - `interface`: (source) interface to apply rule (ie. `eth0`).
217
- - `dest_interface`: interface where packets may be destined to go
218
- - `redirect_port`: redirected port for rules with command `:redirect`
219
- - `logging`: may be added to enable logging for a particular rule. valid values are: `:connections`, `:packets`. In the ufw provider, `:connections` logs new connections while `:packets` logs all packets.
220
-
221
- ```ruby
222
- # open standard ssh port
223
- firewall_rule 'ssh' do
224
- port 22
225
- command :allow
226
- end
227
-
228
- # open standard http port to tcp traffic only; insert as first rule
229
- firewall_rule 'http' do
230
- port 80
231
- protocol :tcp
232
- position 1
233
- command :allow
234
- end
235
-
236
- # restrict port 13579 to 10.0.111.0/24 on eth0
237
- firewall_rule 'myapplication' do
238
- port 13579
239
- source '10.0.111.0/24'
240
- direction :in
241
- interface 'eth0'
242
- command :allow
243
- end
244
-
245
- # specify a protocol number (supported on centos/redhat)
246
- firewall_rule 'vrrp' do
247
- protocol 112
248
- command :allow
249
- end
250
-
251
- # use the iptables provider to specify protocol number on debian/ubuntu
252
- firewall_rule 'vrrp' do
253
- provider Chef::Provider::FirewallRuleIptables
254
- protocol 112
255
- command :allow
256
- end
257
-
258
- # can use :raw command with UFW provider for VRRP
259
- firewall_rule "VRRP" do
260
- command :allow
261
- raw "allow to 224.0.0.18"
262
- end
263
-
264
- # open UDP ports 60000..61000 for mobile shell (mosh.org), note
265
- # that the protocol attribute is required when using port_range
266
- firewall_rule 'mosh' do
267
- protocol :udp
268
- port 60000..61000
269
- command :allow
270
- end
271
-
272
- # open multiple ports for http/https, note that the protocol
273
- # attribute is required when using ports
274
- firewall_rule 'http/https' do
275
- protocol :tcp
276
- port [80, 443]
277
- command :allow
278
- end
279
-
280
- # firewalld example of opening port 22 on public zone
281
- firewall_rule 'ssh' do
282
- port 22
283
- zone "public"
284
- command :allow
285
- end
286
-
287
- firewall 'default' do
288
- enabled false
289
- action :nothing
290
- end
291
- ```
292
-
293
- #### Providers
294
-
295
- - See `libraries/z_provider_mapping.rb` for a full list of providers for each platform and version.
296
-
297
- Different providers will determine the current state of the rules differently -- parsing the output of a command, maintaining the state in a file, or some other way. If the firewall is adjusted from outside of chef (non-idempotent), it's possible that chef may be caught unaware of the current state of the firewall. The best workaround is to add a `:flush` action to the firewall resource as early as possible in the chef run, if you plan to modify the firewall state outside of chef.
298
-
299
- ## Troubleshooting
300
-
301
- To figure out what the position values are for current rules, print the hash that contains the weights:
302
-
303
- ```ruby
304
- require pp
305
- default_firewall = resources(:firewall, 'default')
306
- pp default_firewall.rules
307
- ```
308
-
309
- ## Development
310
-
311
- This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]].
312
-
313
- 1. Clone this repository from GitHub:
314
-
315
- `$ git clone git@github.com:chef-cookbooks/firewall.git`
316
-
317
- 1. Create a git branch
318
-
319
- `$ git checkout -b my_bug_fix`
320
-
321
- 1. Install dependencies:
322
-
323
- `$ bundle install`
324
-
325
- 1. Make your changes/patches/fixes, committing appropiately
326
- 1. **Write tests**
327
- 1. Run the tests:
328
-
329
- - `bundle exec foodcritic -f any .`
330
- - `bundle exec rspec`
331
- - `bundle exec rubocop`
332
- - `bundle exec kitchen test`
333
-
334
- In detail:
335
-
336
- - Foodcritic will catch any Chef-specific style errors
337
- - RSpec will run the unit tests
338
- - Rubocop will check for Ruby-specific style errors
339
- - Test Kitchen will run and converge the recipes
340
-
341
- ## Contributors
342
-
343
- This project exists thanks to all the people who [contribute.](https://opencollective.com/sous-chefs/contributors.svg?width=890&button=false)
344
-
345
- ### Backers
346
-
347
- Thank you to all our backers!
348
-
349
- ![https://opencollective.com/sous-chefs#backers](https://opencollective.com/sous-chefs/backers.svg?width=600&avatarHeight=40)
350
-
351
- ### Sponsors
352
-
353
- Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
354
-
355
- ![https://opencollective.com/sous-chefs/sponsor/0/website](https://opencollective.com/sous-chefs/sponsor/0/avatar.svg?avatarHeight=100)
356
- ![https://opencollective.com/sous-chefs/sponsor/1/website](https://opencollective.com/sous-chefs/sponsor/1/avatar.svg?avatarHeight=100)
357
- ![https://opencollective.com/sous-chefs/sponsor/2/website](https://opencollective.com/sous-chefs/sponsor/2/avatar.svg?avatarHeight=100)
358
- ![https://opencollective.com/sous-chefs/sponsor/3/website](https://opencollective.com/sous-chefs/sponsor/3/avatar.svg?avatarHeight=100)
359
- ![https://opencollective.com/sous-chefs/sponsor/4/website](https://opencollective.com/sous-chefs/sponsor/4/avatar.svg?avatarHeight=100)
360
- ![https://opencollective.com/sous-chefs/sponsor/5/website](https://opencollective.com/sous-chefs/sponsor/5/avatar.svg?avatarHeight=100)
361
- ![https://opencollective.com/sous-chefs/sponsor/6/website](https://opencollective.com/sous-chefs/sponsor/6/avatar.svg?avatarHeight=100)
362
- ![https://opencollective.com/sous-chefs/sponsor/7/website](https://opencollective.com/sous-chefs/sponsor/7/avatar.svg?avatarHeight=100)
363
- ![https://opencollective.com/sous-chefs/sponsor/8/website](https://opencollective.com/sous-chefs/sponsor/8/avatar.svg?avatarHeight=100)
364
- ![https://opencollective.com/sous-chefs/sponsor/9/website](https://opencollective.com/sous-chefs/sponsor/9/avatar.svg?avatarHeight=100)
365
-
366
- [0]: https://mosh.org
@@ -1,6 +0,0 @@
1
- # TODO
2
-
3
- - update for rhel-8+ nftables, RHEL docs recommend nftables for new firewalls <https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/getting-started-with-nftables_configuring-and-managing-networking>
4
- - fix windows tests
5
- - iptables' `-S` not supported in libraries/provider_firewall_iptables.rb
6
- - save action might not make sense for firewalls
@@ -1,5 +0,0 @@
1
- default['firewall']['allow_ssh'] = false
2
- default['firewall']['allow_winrm'] = false
3
- default['firewall']['allow_mosh'] = false
4
- default['firewall']['allow_loopback'] = false
5
- default['firewall']['allow_icmp'] = false
@@ -1,8 +0,0 @@
1
- default['firewall']['firewalld']['permanent'] = false
2
- default['firewall']['firewalld']['zone'] = 'drop'
3
-
4
- default['firewall']['firewalld']['loopback_zone'] = 'trusted'
5
- default['firewall']['firewalld']['icmp_zone'] = 'public'
6
- default['firewall']['firewalld']['ssh_zone'] = 'public'
7
- default['firewall']['firewalld']['mosh_zone'] = 'public'
8
- default['firewall']['firewalld']['established_zone'] = 'public'
@@ -1,17 +0,0 @@
1
- default['firewall']['iptables']['defaults'][:policy] = {
2
- input: 'DROP',
3
- forward: 'DROP',
4
- output: 'ACCEPT',
5
- }
6
- default['firewall']['iptables']['defaults'][:ruleset] = {
7
- '*filter' => 1,
8
- ":INPUT #{node['firewall']['iptables']['defaults']['policy']['input']}" => 2,
9
- ":FORWARD #{node['firewall']['iptables']['defaults']['policy']['forward']}" => 3,
10
- ":OUTPUT #{node['firewall']['iptables']['defaults']['policy']['output']}" => 4,
11
- 'COMMIT_FILTER' => 100,
12
- }
13
-
14
- default['firewall']['ubuntu_iptables'] = false
15
- default['firewall']['redhat7_iptables'] = false
16
- default['firewall']['allow_established'] = true
17
- default['firewall']['ipv6_enabled'] = true
@@ -1,12 +0,0 @@
1
- default['firewall']['ufw']['defaults'] = {
2
- ipv6: 'yes',
3
- manage_builtins: 'no',
4
- ipt_sysctl: '/etc/ufw/sysctl.conf',
5
- ipt_modules: 'nf_conntrack_ftp nf_nat_ftp nf_conntrack_netbios_ns',
6
- policy: {
7
- input: 'DROP',
8
- output: 'ACCEPT',
9
- forward: 'DROP',
10
- application: 'SKIP',
11
- },
12
- }
@@ -1,8 +0,0 @@
1
- # Windows platform defult settings: block undefined inbould traffic, allow all outgoing traffic
2
-
3
- default['firewall']['windows']['defaults'] = {
4
- policy: {
5
- input: 'blockinbound',
6
- output: 'allowoutbound',
7
- },
8
- }
@@ -1,105 +0,0 @@
1
- module FirewallCookbook
2
- module Helpers
3
- def dport_calc(new_resource)
4
- new_resource.dest_port || new_resource.port
5
- end
6
-
7
- def port_to_s(p)
8
- if p.is_a?(String)
9
- p
10
- elsif p && p.is_a?(Integer)
11
- p.to_s
12
- elsif p && p.is_a?(Array)
13
- p_strings = p.map { |o| port_to_s(o) }
14
- p_strings.sort.join(',')
15
- elsif p && p.is_a?(Range)
16
- if platform_family?('windows')
17
- "#{p.first}-#{p.last}"
18
- else
19
- "#{p.first}:#{p.last}"
20
- end
21
- end
22
- end
23
-
24
- def ipv6_enabled?(new_resource)
25
- new_resource.ipv6_enabled
26
- end
27
-
28
- def disabled?(new_resource)
29
- # if either flag is found in the non-default boolean state
30
- disable_flag = !(new_resource.enabled && !new_resource.disabled)
31
-
32
- Chef::Log.warn("#{new_resource} has been disabled, not proceeding") if disable_flag
33
- disable_flag
34
- end
35
-
36
- def ip_with_mask(new_resource, ip)
37
- if ip.include?('/')
38
- ip
39
- elsif ipv4_rule?(new_resource)
40
- "#{ip}/32"
41
- elsif ipv6_rule?(new_resource)
42
- "#{ip}/128"
43
- else
44
- ip
45
- end
46
- end
47
-
48
- # ipv4-specific rule?
49
- def ipv4_rule?(new_resource)
50
- if (new_resource.source && IPAddr.new(new_resource.source).ipv4?) ||
51
- (new_resource.destination && IPAddr.new(new_resource.destination).ipv4?)
52
- true
53
- else
54
- false
55
- end
56
- end
57
-
58
- # ipv6-specific rule?
59
- def ipv6_rule?(new_resource)
60
- if (new_resource.source && IPAddr.new(new_resource.source).ipv6?) ||
61
- (new_resource.destination && IPAddr.new(new_resource.destination).ipv6?) ||
62
- new_resource.protocol =~ /ipv6/ ||
63
- new_resource.protocol =~ /icmpv6/
64
- true
65
- else
66
- false
67
- end
68
- end
69
-
70
- def debian?(current_node)
71
- current_node['platform_family'] == 'debian'
72
- end
73
-
74
- def build_rule_file(rules)
75
- contents = []
76
- sorted_values = rules.values.sort.uniq
77
- sorted_values.each do |sorted_value|
78
- contents << "# position #{sorted_value}"
79
- rules.each do |k, v|
80
- next unless v == sorted_value
81
-
82
- contents << if repeatable_directives(k)
83
- k[/[^_]+/]
84
- else
85
- k
86
- end
87
- end
88
- end
89
- "#{contents.join("\n")}\n"
90
- end
91
-
92
- def repeatable_directives(s)
93
- %w(:OUTPUT :INPUT :POSTROUTING :PREROUTING COMMIT).each do |special|
94
- return true if s.start_with?(special)
95
- end
96
-
97
- false
98
- end
99
-
100
- def default_description(new_resource)
101
- new_resource.description ||
102
- "Generated by chef from #{cookbook_name}[#{recipe_name}] by #{new_resource}"
103
- end
104
- end
105
- end
@@ -1,116 +0,0 @@
1
- module FirewallCookbook
2
- module Helpers
3
- module Firewalld
4
- include FirewallCookbook::Helpers
5
- include Chef::Mixin::ShellOut
6
-
7
- def firewalld_rules_filename
8
- '/etc/sysconfig/firewalld-chef.rules'
9
- end
10
-
11
- def firewalld_rule!(cmd)
12
- shell_out!(cmd, input: 'yes')
13
- end
14
-
15
- def firewalld_active?
16
- cmd = shell_out('firewall-cmd', '--state')
17
- cmd.stdout =~ /^running$/
18
- end
19
-
20
- def firewalld_default_zone?(z)
21
- return false unless firewalld_active?
22
-
23
- cmd = shell_out('firewall-cmd', '--get-default-zone')
24
- cmd.stdout =~ /^#{z}$/
25
- end
26
-
27
- def firewalld_default_zone!(z)
28
- raise 'firewalld not active' unless firewalld_active?
29
-
30
- shell_out!('firewall-cmd', "--set-default-zone=#{z}")
31
- end
32
-
33
- def log_current_firewalld
34
- shell_out!('firewall-cmd --direct --get-all-rules')
35
- end
36
-
37
- def firewalld_flush!
38
- raise 'firewall not active' unless firewalld_active?
39
-
40
- shell_out!('firewall-cmd', '--direct', '--remove-rules', 'ipv4', 'filter', 'INPUT')
41
- shell_out!('firewall-cmd', '--direct', '--remove-rules', 'ipv4', 'filter', 'OUTPUT')
42
- shell_out!('firewall-cmd', '--direct', '--permanent', '--remove-rules', 'ipv4', 'filter', 'INPUT')
43
- shell_out!('firewall-cmd', '--direct', '--permanent', '--remove-rules', 'ipv4', 'filter', 'OUTPUT')
44
- end
45
-
46
- def firewalld_all_rules_permanent!
47
- raise 'firewall not active' unless firewalld_active?
48
-
49
- rules = shell_out!('firewall-cmd', '--direct', '--get-all-rules').stdout
50
- perm_rules = shell_out!('firewall-cmd', '--direct', '--permanent', '--get-all-rules').stdout
51
- rules == perm_rules
52
- end
53
-
54
- def firewalld_save!
55
- raise 'firewall not active' unless firewalld_active?
56
-
57
- shell_out!('firewall-cmd', '--direct', '--permanent', '--remove-rules', 'ipv4', 'filter', 'INPUT')
58
- shell_out!('firewall-cmd', '--direct', '--permanent', '--remove-rules', 'ipv4', 'filter', 'OUTPUT')
59
- shell_out!('firewall-cmd', '--direct', '--get-all-rules').stdout.lines do |line|
60
- shell_out!("firewall-cmd --direct --permanent --add-rule #{line}")
61
- end
62
- end
63
-
64
- def ip_versions(resource)
65
- if ipv4_rule?(resource)
66
- %w(ipv4)
67
- elsif ipv6_rule?(resource)
68
- %w(ipv6)
69
- else # no source or destination address, add rules for both ipv4 and ipv6
70
- %w(ipv4 ipv6)
71
- end
72
- end
73
-
74
- CHAIN = { in: 'INPUT', out: 'OUTPUT', pre: 'PREROUTING', post: 'POSTROUTING' }.freeze unless defined? CHAIN # , nil => "FORWARD"}
75
- TARGET = { allow: 'ACCEPT', reject: 'REJECT', deny: 'DROP', masquerade: 'MASQUERADE', redirect: 'REDIRECT', log: 'LOG --log-prefix \'iptables: \' --log-level 7' }.freeze unless defined? TARGET
76
-
77
- def build_firewall_rule(new_resource, ip_version = 'ipv4')
78
- return new_resource.raw.strip if new_resource.raw
79
-
80
- type = new_resource.command
81
- firewall_rule = if new_resource.direction
82
- "#{ip_version} filter #{CHAIN[new_resource.direction.to_sym]} "
83
- else
84
- "#{ip_version} filter FORWARD "
85
- end
86
- firewall_rule << "#{new_resource.position} "
87
-
88
- if [:pre, :post].include?(new_resource.direction)
89
- firewall_rule << '-t nat '
90
- end
91
-
92
- # Firewalld order of prameters is important here see example output below:
93
- # ipv4 filter INPUT 1 -s 1.2.3.4/32 -d 5.6.7.8/32 -i lo -p tcp -m tcp -m state --state NEW -m comment --comment "hello" -j DROP
94
- firewall_rule << "-s #{ip_with_mask(new_resource, new_resource.source)} " if new_resource.source && new_resource.source != '0.0.0.0/0'
95
- firewall_rule << "-d #{new_resource.destination} " if new_resource.destination
96
-
97
- firewall_rule << "-i #{new_resource.interface} " if new_resource.interface
98
- firewall_rule << "-o #{new_resource.dest_interface} " if new_resource.dest_interface
99
-
100
- firewall_rule << "-p #{new_resource.protocol} " if new_resource.protocol && new_resource.protocol.to_s.to_sym != :none
101
- firewall_rule << '-m tcp ' if new_resource.protocol && new_resource.protocol.to_s.to_sym == :tcp
102
-
103
- # using multiport here allows us to simplify our greps and rule building
104
- firewall_rule << "-m multiport --sports #{port_to_s(new_resource.source_port)} " if new_resource.source_port
105
- firewall_rule << "-m multiport --dports #{port_to_s(dport_calc(new_resource))} " if dport_calc(new_resource)
106
-
107
- firewall_rule << "-m state --state #{new_resource.stateful.is_a?(Array) ? new_resource.stateful.join(',').upcase : new_resource.stateful.to_s.upcase} " if new_resource.stateful
108
- firewall_rule << "-m comment --comment '#{new_resource.description}' " if new_resource.include_comment
109
- firewall_rule << "-j #{TARGET[type]} "
110
- firewall_rule << "--to-ports #{new_resource.redirect_port} " if type == :redirect
111
- firewall_rule.strip!
112
- firewall_rule
113
- end
114
- end
115
- end
116
- end