You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-22Lines changed: 24 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,28 @@ The rules you create here are helpful if you don’t have any existing rules; th
127
127
128
128
Rules are persisted automatically between reboots, although there are known issues with ip6tables on older Debian/Ubuntu distributions. There are also known issues with ebtables.
129
129
130
-
1. In site.pp or another top-scope file, add the following code to set up a metatype to purge unmanaged firewall resources. This will clear any existing rules and make sure that only rules defined in Puppet exist on the machine.
130
+
1. Use the following code to set up the default parameters for all of the firewall rules that you will establish later. These defaults will ensure that the `pre` and `post` classes are run in the correct order and avoid locking you out of your box during the first Puppet run.
131
+
132
+
```puppet
133
+
Firewall {
134
+
before => Class['my_fw::post'],
135
+
require => Class['my_fw::pre'],
136
+
}
137
+
```
138
+
139
+
2. Declare the `my_fw::pre` and `my_fw::post` classes to satisfy dependencies. You can declare these classes using an external node classifier or the following code:
140
+
141
+
```puppet
142
+
class { ['my_fw::pre', 'my_fw::post']: }
143
+
```
144
+
145
+
3. Include the `firewall` class to ensure the correct packages are installed:
146
+
147
+
```puppet
148
+
class { 'firewall': }
149
+
```
150
+
151
+
4. If you want to remove unmanaged firewall rules, add the following code to set up a metatype to purge unmanaged firewall resources in your site.pp or another top-scope file. This will clear any existing rules and make sure that only rules defined in Puppet exist on the machine.
131
152
132
153
```puppet
133
154
resources { 'firewall':
@@ -168,28 +189,9 @@ resources { 'firewallchain':
168
189
}
169
190
```
170
191
171
-
**Note**- If there are unmanaged rules in unmanaged chains, it will take two Puppet runs for the firewall chain to be purged. This is different than the `purge` parameter available in `firewallchain`.
192
+
> **Note:** If there are unmanaged rules in unmanaged chains, it will take a second Puppet run for the firewall chain to be purged.
172
193
173
-
2. Use the following code to set up the default parameters for all of the firewall rules that you will establish later. These defaults will ensure that the `pre` and `post` classes are run in the correct order and avoid locking you out of your box during the first Puppet run.
174
-
175
-
```puppet
176
-
Firewall {
177
-
before => Class['my_fw::post'],
178
-
require => Class['my_fw::pre'],
179
-
}
180
-
```
181
-
182
-
3. Declare the `my_fw::pre` and `my_fw::post` classes to satisfy dependencies. You can declare these classes using an external node classifier or the following code:
183
-
184
-
```puppet
185
-
class { ['my_fw::pre', 'my_fw::post']: }
186
-
```
187
-
188
-
4. Include the `firewall` class to ensure the correct packages are installed:
189
-
190
-
```puppet
191
-
class { 'firewall': }
192
-
```
194
+
> **Note:** If you need more fine-grained control about which unmananged rules get removed, investigate the `purge` and `ignore_foreign` parameters available in `firewallchain`.
Copy file name to clipboardExpand all lines: lib/puppet/type/firewallchain.rb
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -163,6 +163,15 @@
163
163
end
164
164
end
165
165
166
+
newparam(:ignore_foreign,boolean: true)do
167
+
desc<<-PUPPETCODE
168
+
Ignore rules that do not match the puppet title pattern "^\d+[[:graph:][:space:]]" when purging unmanaged firewall rules in this chain.
169
+
This can be used to ignore rules that were not put in by puppet. Beware that nothing keeps other systems from configuring firewall rules with a comment that starts with digits, and is indistinguishable from puppet-configured rules.
0 commit comments