cloud-mu 3.6.10 → 3.6.12

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 +3 -3
  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 -68
  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,200 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Cookbook:: firewall
4
- # Resource:: default
5
- #
6
- # Copyright:: 2011-2019, Chef Software, Inc.
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
- class Chef
21
- class Provider::FirewallIptablesUbuntu1404 < Chef::Provider::LWRPBase
22
- include FirewallCookbook::Helpers
23
- include FirewallCookbook::Helpers::Iptables
24
-
25
- provides :firewall, os: 'linux', platform_family: %w(debian) do |node|
26
- node['firewall'] && node['firewall']['ubuntu_iptables'] &&
27
- node['platform_version'].to_f <= (node['platform'] == 'ubuntu' ? 14.04 : 7)
28
- end
29
-
30
- def whyrun_supported?
31
- false
32
- end
33
-
34
- action :install do
35
- return if disabled?(new_resource)
36
-
37
- # Ensure the package is installed
38
- pkg = package 'iptables-persistent' do
39
- action :nothing
40
- end
41
- pkg.run_action(:install)
42
- new_resource.updated_by_last_action(true) if pkg.updated_by_last_action?
43
-
44
- rule_files = %w(rules.v4)
45
- rule_files << 'rules.v6' if ipv6_enabled?(new_resource)
46
- rule_files.each do |svc|
47
- next if ::File.exist?("/etc/iptables/#{svc}")
48
-
49
- # must create empty file for service to start
50
- f = lookup_or_create_rulesfile(svc)
51
- f.content '# created by chef to allow service to start'
52
- f.run_action(:create)
53
-
54
- new_resource.updated_by_last_action(true) if f.updated_by_last_action?
55
- end
56
-
57
- iptables_service = lookup_or_create_service('iptables-persistent')
58
- [:enable, :start].each do |act|
59
- # iptables-persistent isn't a real service
60
- iptables_service.status_command 'true'
61
-
62
- iptables_service.run_action(act)
63
- new_resource.updated_by_last_action(true) if iptables_service.updated_by_last_action?
64
- end
65
- end
66
-
67
- action :restart do
68
- return if disabled?(new_resource)
69
-
70
- # prints all the firewall rules
71
- log_iptables(new_resource)
72
-
73
- # ensure it's initialized
74
- new_resource.rules({}) unless new_resource.rules
75
- ensure_default_rules_exist(node, new_resource)
76
-
77
- # this populates the hash of rules from firewall_rule resources
78
- firewall_rules = Chef.run_context.resource_collection.select { |item| item.is_a?(Chef::Resource::FirewallRule) }
79
- firewall_rules.each do |firewall_rule|
80
- next unless firewall_rule.action.include?(:create) && !firewall_rule.should_skip?(:create)
81
-
82
- types = if ipv6_rule?(firewall_rule) # an ip4 specific rule
83
- %w(ip6tables)
84
- elsif ipv4_rule?(firewall_rule) # an ip6 specific rule
85
- %w(iptables)
86
- else # or not specific
87
- %w(iptables ip6tables)
88
- end
89
-
90
- types.each do |iptables_type|
91
- # build rules to apply with weight
92
- k = build_firewall_rule(node, firewall_rule, iptables_type == 'ip6tables')
93
- v = firewall_rule.position
94
-
95
- # unless we're adding them for the first time.... bail out.
96
- next if new_resource.rules[iptables_type].key?(k) && new_resource.rules[iptables_type][k] == v
97
- new_resource.rules[iptables_type][k] = v
98
- end
99
- end
100
-
101
- restart_service = false
102
-
103
- rule_files = %w(iptables)
104
- rule_files << 'ip6tables' if ipv6_enabled?(new_resource)
105
-
106
- rule_files.each do |iptables_type|
107
- iptables_filename = if iptables_type == 'ip6tables'
108
- '/etc/iptables/rules.v6'
109
- else
110
- '/etc/iptables/rules.v4'
111
- end
112
-
113
- # ensure a file resource exists with the current iptables rules
114
- begin
115
- iptables_file = Chef.run_context.resource_collection.find(file: iptables_filename)
116
- rescue
117
- iptables_file = file iptables_filename do
118
- action :nothing
119
- end
120
- end
121
- iptables_file.content build_rule_file(new_resource.rules[iptables_type])
122
- iptables_file.run_action(:create)
123
-
124
- # if the file was changed, restart iptables
125
- restart_service = true if iptables_file.updated_by_last_action?
126
- end
127
-
128
- if restart_service
129
- service_affected = service 'iptables-persistent' do
130
- action :nothing
131
- end
132
- service_affected.run_action(:restart)
133
- new_resource.updated_by_last_action(true)
134
- end
135
- end
136
-
137
- action :disable do
138
- return if disabled?(new_resource)
139
-
140
- iptables_flush!(new_resource)
141
- iptables_default_allow!(new_resource)
142
- new_resource.updated_by_last_action(true)
143
-
144
- iptables_service = lookup_or_create_service('iptables-persistent')
145
- [:disable, :stop].each do |act|
146
- iptables_service.run_action(act)
147
- new_resource.updated_by_last_action(true) if iptables_service.updated_by_last_action?
148
- end
149
-
150
- %w(rules.v4 rules.v6).each do |svc|
151
- # must create empty file for service to start
152
- f = lookup_or_create_rulesfile(svc)
153
- f.content '# created by chef to allow service to start'
154
- f.run_action(:create)
155
-
156
- new_resource.updated_by_last_action(true) if f.updated_by_last_action?
157
- end
158
- end
159
-
160
- action :flush do
161
- return if disabled?(new_resource)
162
-
163
- iptables_flush!(new_resource)
164
- new_resource.updated_by_last_action(true)
165
-
166
- rule_files = %w(rules.v4)
167
- rule_files << 'rules.v6' if ipv6_enabled?(new_resource)
168
- rule_files.each do |svc|
169
- # must create empty file for service to start
170
- f = lookup_or_create_rulesfile(svc)
171
- f.content '# created by chef to allow service to start'
172
- f.run_action(:create)
173
-
174
- new_resource.updated_by_last_action(true) if f.updated_by_last_action?
175
- end
176
- end
177
-
178
- def lookup_or_create_service(name)
179
- begin
180
- iptables_service = Chef.run_context.resource_collection.find(service: svc)
181
- rescue
182
- iptables_service = service name do
183
- action :nothing
184
- end
185
- end
186
- iptables_service
187
- end
188
-
189
- def lookup_or_create_rulesfile(name)
190
- begin
191
- iptables_file = Chef.run_context.resource_collection.find(file: name)
192
- rescue
193
- iptables_file = file "/etc/iptables/#{name}" do
194
- action :nothing
195
- end
196
- end
197
- iptables_file
198
- end
199
- end
200
- end
@@ -1,34 +0,0 @@
1
- #
2
- # Author:: Ronald Doorn (<rdoorn@schubergphilis.com>)
3
- # Cookbook:: firewall
4
- # Provider:: rule_iptables
5
- #
6
- # Copyright:: 2015-2016, computerlyrik
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
- class Chef
21
- class Provider::FirewallRuleGeneric < Chef::Provider::LWRPBase
22
- provides :firewall_rule
23
-
24
- action :create do
25
- return unless new_resource.notify_firewall
26
-
27
- firewall_resource = Chef.run_context.resource_collection.find(firewall: new_resource.firewall_name)
28
- raise 'could not find a firewall resource' unless firewall_resource
29
-
30
- new_resource.notifies(:restart, firewall_resource, :delayed)
31
- new_resource.updated_by_last_action(true)
32
- end
33
- end
34
- end
@@ -1,138 +0,0 @@
1
- #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Cookbook:: firewall
4
- # Resource:: default
5
- #
6
- # Copyright:: 2011-2019, Chef Software, Inc.
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
- class Chef
21
- class Provider::FirewallUfw < Chef::Provider::LWRPBase
22
- include FirewallCookbook::Helpers::Ufw
23
-
24
- provides :firewall, os: 'linux', platform_family: %w(debian) do |node|
25
- !(node['firewall'] && node['firewall']['ubuntu_iptables'])
26
- end
27
-
28
- def whyrun_supported?
29
- false
30
- end
31
-
32
- action :install do
33
- return if disabled?(new_resource)
34
-
35
- pkg_ufw = package 'ufw' do
36
- action :nothing
37
- end
38
- pkg_ufw.run_action(:install)
39
- new_resource.updated_by_last_action(true) if pkg_ufw.updated_by_last_action?
40
-
41
- defaults_ufw = template '/etc/default/ufw' do
42
- action :nothing
43
- owner 'root'
44
- group 'root'
45
- mode '0644'
46
- source 'ufw/default.erb'
47
- cookbook 'firewall'
48
- end
49
- defaults_ufw.run_action(:create)
50
- new_resource.updated_by_last_action(true) if defaults_ufw.updated_by_last_action?
51
-
52
- return if ::File.exist?(ufw_rules_filename)
53
-
54
- ufw_file = lookup_or_create_rulesfile
55
- ufw_file.content '# created by chef to allow service to start'
56
- ufw_file.run_action(:create)
57
-
58
- new_resource.updated_by_last_action(true) if ufw_file.updated_by_last_action?
59
- end
60
-
61
- action :restart do
62
- return if disabled?(new_resource)
63
-
64
- # ensure it's initialized
65
- new_resource.rules({}) unless new_resource.rules
66
- new_resource.rules['ufw'] = {} unless new_resource.rules['ufw']
67
-
68
- # this populates the hash of rules from firewall_rule resources
69
- firewall_rules = Chef.run_context.resource_collection.select { |item| item.is_a?(Chef::Resource::FirewallRule) }
70
- firewall_rules.each do |firewall_rule|
71
- next unless firewall_rule.action.include?(:create) && !firewall_rule.should_skip?(:create)
72
-
73
- # build rules to apply with weight
74
- k = build_rule(firewall_rule)
75
- v = firewall_rule.position
76
-
77
- # unless we're adding them for the first time.... bail out.
78
- unless new_resource.rules['ufw'].key?(k) && new_resource.rules['ufw'][k] == v
79
- new_resource.rules['ufw'][k] = v
80
- end
81
- end
82
-
83
- # ensure a file resource exists with the current ufw rules
84
- ufw_file = lookup_or_create_rulesfile
85
- ufw_file.content build_rule_file(new_resource.rules['ufw'])
86
- ufw_file.run_action(:create)
87
-
88
- # if the file was changed, restart iptables
89
- return unless ufw_file.updated_by_last_action?
90
- ufw_reset!
91
- ufw_logging!(new_resource.log_level) if new_resource.log_level
92
-
93
- new_resource.rules['ufw'].sort_by { |_k, v| v }.map { |k, _v| k }.each do |cmd|
94
- ufw_rule!(cmd)
95
- end
96
-
97
- # ensure it's enabled _after_ rules are inputted, to catch malformed rules
98
- ufw_enable! unless ufw_active?
99
- new_resource.updated_by_last_action(true)
100
- end
101
-
102
- action :disable do
103
- return if disabled?(new_resource)
104
-
105
- ufw_file = lookup_or_create_rulesfile
106
- ufw_file.content '# created by chef to allow service to start'
107
- ufw_file.run_action(:create)
108
- new_resource.updated_by_last_action(true) if ufw_file.updated_by_last_action?
109
-
110
- return unless ufw_active?
111
- ufw_disable!
112
- new_resource.updated_by_last_action(true)
113
- end
114
-
115
- action :flush do
116
- return if disabled?(new_resource)
117
-
118
- ufw_reset!
119
- new_resource.updated_by_last_action(true)
120
-
121
- ufw_file = lookup_or_create_rulesfile
122
- ufw_file.content '# created by chef to allow service to start'
123
- ufw_file.run_action(:create)
124
- new_resource.updated_by_last_action(true) if ufw_file.updated_by_last_action?
125
- end
126
-
127
- def lookup_or_create_rulesfile
128
- begin
129
- ufw_file = Chef.run_context.resource_collection.find(file: ufw_rules_filename)
130
- rescue
131
- ufw_file = file ufw_rules_filename do
132
- action :nothing
133
- end
134
- end
135
- ufw_file
136
- end
137
- end
138
- end
@@ -1,126 +0,0 @@
1
- #
2
- # Author:: Sander van Harmelen (<svanharmelen@schubergphilis.com>)
3
- # Cookbook:: firewall
4
- # Provider:: windows
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- class Chef
20
- class Provider::FirewallWindows < Chef::Provider::LWRPBase
21
- include FirewallCookbook::Helpers::Windows
22
-
23
- provides :firewall, os: 'windows'
24
-
25
- def whyrun_supported?
26
- false
27
- end
28
-
29
- action :install do
30
- return if disabled?(new_resource)
31
-
32
- svc = service 'MpsSvc' do
33
- action :nothing
34
- end
35
-
36
- [:enable, :start].each do |act|
37
- svc.run_action(act)
38
- new_resource.updated_by_last_action(true) if svc.updated_by_last_action?
39
- end
40
- end
41
-
42
- action :restart do
43
- return if disabled?(new_resource)
44
-
45
- # ensure it's initialized
46
- new_resource.rules({}) unless new_resource.rules
47
- new_resource.rules['windows'] = {} unless new_resource.rules['windows']
48
-
49
- firewall_rules = Chef.run_context.resource_collection.select { |item| item.is_a?(Chef::Resource::FirewallRule) }
50
- firewall_rules.each do |firewall_rule|
51
- next unless firewall_rule.action.include?(:create) && !firewall_rule.should_skip?(:create)
52
-
53
- # build rules to apply with weight
54
- k = build_rule(firewall_rule)
55
- v = firewall_rule.position
56
-
57
- # unless we're adding them for the first time.... bail out.
58
- unless new_resource.rules['windows'].key?(k) && new_resource.rules['windows'][k] == v
59
- new_resource.rules['windows'][k] = v
60
- end
61
- end
62
-
63
- input_policy = node['firewall']['windows']['defaults']['policy']['input']
64
- output_policy = node['firewall']['windows']['defaults']['policy']['output']
65
- unless new_resource.rules['windows'].key?("set currentprofile firewallpolicy #{input_policy},#{output_policy}")
66
- # Make this the possible last rule in the list
67
- new_resource.rules['windows']["set currentprofile firewallpolicy #{input_policy},#{output_policy}"] = 99999
68
- end
69
-
70
- # ensure a file resource exists with the current rules
71
- begin
72
- windows_file = Chef.run_context.resource_collection.find(file: windows_rules_filename)
73
- rescue
74
- windows_file = file windows_rules_filename do
75
- action :nothing
76
- end
77
- end
78
- windows_file.content build_rule_file(new_resource.rules['windows'])
79
- windows_file.run_action(:create)
80
-
81
- # if the file was changed, restart iptables
82
- return unless windows_file.updated_by_last_action?
83
-
84
- disable! if active?
85
- delete_all_rules! # clear entirely
86
- reset! # populate default rules
87
-
88
- new_resource.rules['windows'].sort_by { |_k, v| v }.map { |k, _v| k }.each do |cmd|
89
- add_rule!(cmd)
90
- end
91
- # ensure it's enabled _after_ rules are inputted, to catch malformed rules
92
- enable! unless active?
93
-
94
- new_resource.updated_by_last_action(true)
95
- end
96
-
97
- action :disable do
98
- return if disabled?(new_resource)
99
-
100
- if active?
101
- disable!
102
- Chef::Log.info("#{new_resource} disabled.")
103
- new_resource.updated_by_last_action(true)
104
- else
105
- Chef::Log.debug("#{new_resource} already disabled.")
106
- end
107
-
108
- svc = service 'MpsSvc' do
109
- action :nothing
110
- end
111
-
112
- [:disable, :stop].each do |act|
113
- svc.run_action(act)
114
- new_resource.updated_by_last_action(true) if svc.updated_by_last_action?
115
- end
116
- end
117
-
118
- action :flush do
119
- return if disabled?(new_resource)
120
-
121
- reset!
122
- Chef::Log.info("#{new_resource} reset.")
123
- new_resource.updated_by_last_action(true)
124
- end
125
- end
126
- end
@@ -1,26 +0,0 @@
1
- class Chef
2
- class Resource::Firewall < Chef::Resource::LWRPBase
3
- resource_name(:firewall)
4
- provides(:firewall)
5
- actions(:install, :restart, :disable, :flush, :save)
6
- default_action(:install)
7
-
8
- # allow both kinds of logic -- eventually remove the :disabled one.
9
- # the positive logic is much easier to follow.
10
- attribute(:disabled, kind_of: [TrueClass, FalseClass], default: false)
11
- attribute(:enabled, kind_of: [TrueClass, FalseClass], default: true)
12
-
13
- attribute(:log_level, kind_of: Symbol, equal_to: [:low, :medium, :high, :full, :off], default: :low)
14
- attribute(:rules, kind_of: Hash)
15
-
16
- # for firewalld, specify the zone when firewall is disable and enabled
17
- attribute(:disabled_zone, kind_of: Symbol, default: :public)
18
- attribute(:enabled_zone, kind_of: Symbol, default: :drop)
19
-
20
- # for firewall implementations where ipv6 can be skipped (currently iptables-specific)
21
- attribute(:ipv6_enabled, kind_of: [TrueClass, FalseClass], default: true)
22
-
23
- # allow override of package options for firewalld package
24
- attribute(:package_options, kind_of: String, default: nil)
25
- end
26
- end
@@ -1,52 +0,0 @@
1
- require 'ipaddr'
2
-
3
- class Chef
4
- class Resource::FirewallRule < Chef::Resource::LWRPBase
5
- include FirewallCookbook::Helpers
6
-
7
- resource_name(:firewall_rule)
8
- provides(:firewall_rule)
9
- default_action(:create)
10
-
11
- attribute(:firewall_name, kind_of: String, default: 'default')
12
-
13
- attribute(:command, kind_of: Symbol, equal_to: [:reject, :allow, :deny, :masquerade, :redirect, :log], default: :allow)
14
-
15
- attribute(:protocol, kind_of: [Integer, Symbol], default: :tcp,
16
- callbacks: { 'must be either :tcp, :udp, :icmp, :\'ipv6-icmp\', :icmpv6, :none, or a valid IP protocol number' => lambda do |p|
17
- !!(p.to_s =~ /(udp|tcp|icmp|icmpv6|ipv6-icmp|esp|ah|ipv6|none)/ || (p.to_s =~ /^\d+$/ && p.between?(0, 142)))
18
- end })
19
- attribute(:direction, kind_of: Symbol, equal_to: [:in, :out, :pre, :post], default: :in)
20
- attribute(:logging, kind_of: Symbol, equal_to: [:connections, :packets])
21
-
22
- attribute(:source, kind_of: String, callbacks: { 'must be a valid ip address' => ->(ip) { !!IPAddr.new(ip) } })
23
- attribute(:source_port, kind_of: [Integer, Array, Range]) # source port
24
- attribute(:interface, kind_of: String)
25
-
26
- attribute(:port, kind_of: [Integer, Array, Range]) # shorthand for dest_port
27
- attribute(:destination, kind_of: String, callbacks: { 'must be a valid ip address' => ->(ip) { !!IPAddr.new(ip) } })
28
- attribute(:dest_port, kind_of: [Integer, Array, Range])
29
- attribute(:dest_interface, kind_of: String)
30
-
31
- attribute(:position, kind_of: Integer, default: 50)
32
- attribute(:stateful, kind_of: [Symbol, Array])
33
- attribute(:redirect_port, kind_of: Integer)
34
- attribute(:description, kind_of: String, name_attribute: true)
35
- attribute(:include_comment, kind_of: [TrueClass, FalseClass], default: true)
36
-
37
- # only used for firewalld
38
- attribute(:permanent, kind_of: [TrueClass, FalseClass], default: false)
39
- attribute(:zone, kind_of: String, default: 'drop')
40
-
41
- # only used for Windows Firewalls
42
- attribute(:program, kind_of: String)
43
- attribute(:service, kind_of: String)
44
-
45
- # for when you just want to pass a raw rule
46
- attribute(:raw, kind_of: String)
47
-
48
- # do you want this rule to notify the firewall to recalculate
49
- # (and potentially reapply) the firewall_rule(s) it finds?
50
- attribute(:notify_firewall, kind_of: [TrueClass, FalseClass], default: true)
51
- end
52
- end
@@ -1,40 +0,0 @@
1
- {
2
- "name": "firewall",
3
- "description": "Provides a set of primitives for managing firewalls and associated rules.",
4
- "long_description": "",
5
- "maintainer": "Sous Chefs",
6
- "maintainer_email": "help@sous-chefs.org",
7
- "license": "Apache-2.0",
8
- "platforms": {
9
- "amazon": ">= 0.0.0",
10
- "centos": ">= 0.0.0",
11
- "debian": ">= 0.0.0",
12
- "ubuntu": ">= 0.0.0",
13
- "windows": ">= 0.0.0"
14
- },
15
- "dependencies": {
16
-
17
- },
18
- "providing": {
19
-
20
- },
21
- "recipes": {
22
-
23
- },
24
- "version": "6.3.7",
25
- "source_url": "https://github.com/sous-chefs/firewall",
26
- "issues_url": "https://github.com/sous-chefs/firewall/issues",
27
- "privacy": false,
28
- "chef_versions": [
29
- [
30
- ">= 15.5"
31
- ]
32
- ],
33
- "ohai_versions": [
34
-
35
- ],
36
- "gems": [
37
-
38
- ],
39
- "eager_load_libraries": true
40
- }
@@ -1,15 +0,0 @@
1
- name 'firewall'
2
- maintainer 'Sous Chefs'
3
- maintainer_email 'help@sous-chefs.org'
4
- license 'Apache-2.0'
5
- description 'Provides a set of primitives for managing firewalls and associated rules.'
6
- version '6.3.7'
7
- source_url 'https://github.com/sous-chefs/firewall'
8
- issues_url 'https://github.com/sous-chefs/firewall/issues'
9
- chef_version '>= 15.5'
10
-
11
- supports 'amazon'
12
- supports 'centos'
13
- supports 'debian'
14
- supports 'ubuntu'
15
- supports 'windows'