File: test.pp

package info (click to toggle)
puppet-module-puppetlabs-firewall 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 972 kB
  • sloc: ruby: 11,399; sh: 29; makefile: 2
file content (112 lines) | stat: -rw-r--r-- 2,201 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
class profile::firewall {
  include ::firewall
  include ::fwrules
}
class fwrules {
  contain ::fwrules::ipv4
  contain ::fwrules::ipv6

  resources { 'firewall':
    purge => true,
  }

  resources { 'firewallchain':
    purge => true,
  }
}

class fwrules::ipv4 {
  Firewall {
    require => undef,
  }

  firewallchain { 'INPUT:filter:IPv4':
    ensure => present,
    policy => drop,
    before => undef,
  }

  # Default firewall rules
  firewall { "000 ${title} accept all icmp":
    proto  => 'icmp',
    action => 'accept',
  }
  ->
  firewall { "001 ${title} accept all to lo interface":
    proto   => 'all',
    iniface => 'lo',
    action  => 'accept',
  }
  ->
  firewall { "003 ${title} accept related established rules":
    proto  => 'all',
    state  => ['RELATED', 'ESTABLISHED'],
    action => 'accept',
  }
}

class fwrules::ipv6 {
  Firewall {
    require  => undef,
    provider => 'ip6tables'
  }

  firewallchain { 'INPUT:filter:IPv6':
    ensure => present,
    policy => drop,
    before => undef,
  }

  # Default firewall rules
  firewall { "000 ${title} accept all icmp":
    proto  => 'ipv6-icmp',
    action => 'accept',
  }
  ->
  firewall { "001 ${title} accept all to lo interface":
    proto   => 'all',
    iniface => 'lo',
    action  => 'accept',
  }
  ->
  firewall { "003 ${title} accept related established rules":
    proto  => 'all',
    state  => ['RELATED', 'ESTABLISHED'],
    action => 'accept',
  }
}

class profile::appserver {
  include ::firewall
  Firewall {
    require => Class['fwrules'],
  }

  firewall { "0100 ${title} Future-proof XMLRPC over UUCP over IPv6 appserver traffic":
    dport    => [540],
    proto    => tcp,
    action   => accept,
    source   => '2001:db8:de:caf::/64',
    provider => 'ip6tables',
  }

  firewall { "0101 ${name} legacy admin access":
    dport  => [80, 443],
    proto  => tcp,
    action => accept,
    source => '192.0.2.0/24',
  }

  firewall { "0101 ${name} admin access":
    dport    => [80, 443],
    proto    => tcp,
    action   => accept,
    provider => 'ip6tables',
    source   => '2001:db8:c0f:fee::/64',
  }

  # appserver things here
}

include profile::firewall
include profile::appserver