summaryrefslogtreecommitdiffstats
path: root/vagrant/puppet/manifests/site.pp
blob: e0decc3ad7b1a0afec55bb5c18cd03a32425937c (plain)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
node default {
	# this will get put on every host...
	$url = 'https://ttboj.wordpress.com/'
	file { '/etc/motd':
		content => "This is Puppet-Gluster+Vagrant! (${url})\n",
	}
}

# puppetmaster
node puppet inherits default {

	if "${::vagrant_gluster_firewall}" != 'false' {
		include firewall
	}

	$allow = split("${::vagrant_gluster_allow}", ',')	# ip list fact

	class { '::puppet::server':
		pluginsync => true,	# do we want to enable pluginsync?
		storeconfigs => true,	# do we want to enable storeconfigs?
		autosign => [
			'*',		# FIXME: this is a temporary solution
			#"*.${domain}",	# FIXME: this is a temporary solution
		],
		#allow_duplicate_certs => true,	# redeploy without cert clean
		allow => $allow,	# also used in fileserver.conf
		repo => true,		# automatic repos
		shorewall => "${::vagrant_gluster_firewall}" ? {
			'false' => false,
			default => true,
		},
		start => true,
	}

	class { '::puppet::deploy':
		path => '/vagrant/puppet/',	# puppet folder is put here...
		backup => false,		# don't use puppet to backup...
	}
}

node /^annex\d+$/ inherits default {	# annex{1,2,..N}

	if "${::vagrant_gluster_firewall}" != 'false' {
		include firewall
	}

	class { '::puppet::client':
		#start => true,
		start => false,			# useful for testing manually...
	}

	# build a list of hashes with ordered vdX devices
	# (s='';q=i;(q, r = (q - 1).divmod(26)) && s.prepend(('a'..'z').to_a[r]) until q.zero?;'/dev/vd'+s)
	$skip = 1	# skip over 1 disk (eg: /dev/vda from the host)
	$disks = "${::vagrant_gluster_disks}"
	$disks_yaml = inline_template("<%= (1+@skip.to_i..@disks.to_i+@skip.to_i).collect { |i| { 'dev' => (s='';q=i;(q, r = (q - 1).divmod(26)) && s.insert(0, ('a'..'z').to_a[r]) until q.zero?;'/dev/vd'+s) } }.to_yaml %>")
	#$brick_params_defaults = [	# this is one possible example data set
	#	{'dev' => '/dev/vdb'},
	#	{'dev' => '/dev/vdc'},
	#	{'dev' => '/dev/vdd'},
	#	{'dev' => '/dev/vde'},
	#]
	$brick_params_defaults = parseyaml($disks_yaml)
	notice(inline_template('disks: <%= YAML::load(@disks_yaml).inspect %>'))
	#notify { 'disks':
	#	message => inline_template('disks: <%= YAML::load(@disks_yaml).inspect %>'),
	#}

	$brick_param_defaults = {
		# TODO: set these from vagrant variables...
		'lvm' => false,
		'fstype' => "${::vagrant_gluster_fstype}" ? {
			'' => undef,
			default => "${::vagrant_gluster_fstype}",
		},
		'xfs_inode64' => true,
		'force' => true,
	}

	# this is a simple way to setup gluster
	class { '::gluster::simple':
		volume => 'puppet',
		replica => "${::vagrant_gluster_replica}",
		count => "${::vagrant_gluster_bricks}",	# brick count
		layout => "${::vagrant_gluster_layout}",
		vip => "${::vagrant_gluster_vip}",	# from vagrant
		version => "${::vagrant_gluster_version}",
		vrrp => true,
		setgroup => "${::vagrant_gluster_setgroup}",
		shorewall => "${::vagrant_gluster_firewall}" ? {
			'false' => false,
			default => true,
		},
		# NOTE: this is brick_params_defaults NOT param! param is below
		brick_params_defaults => "${::vagrant_gluster_disks}" ? {
			'0' => undef,
			# NOTE: _each_ host will have N bricks with these devs!
			default => $brick_params_defaults,
		},
		brick_param_defaults => "${::vagrant_gluster_disks}" ? {
			'0' => undef,
			# NOTE: _each_ brick will use these...
			default => $brick_param_defaults,
		},
	}
}

node /^client\d+$/ inherits default {	# client{1,2,..N}

	if "${::vagrant_gluster_firewall}" != 'false' {
		include firewall
	}

	class { '::puppet::client':
		#start => true,
		start => false,	# useful for testing manually...
	}

	$host = "${::vagrant_gluster_vip_fqdn}" ? {
		'' => "${::vagrant_gluster_vip}",
		default => "${::vagrant_gluster_vip_fqdn}",
	}

	gluster::mount { '/mnt/gluster/puppet/':
		server => "${host}:/puppet",
		rw => true,
		version => "${::vagrant_gluster_version}",
		shorewall => "${::vagrant_gluster_firewall}" ? {
			'false' => false,
			default => true,
		},
	}
}

class firewall {

	$FW = '$FW'			# make using $FW in shorewall easier

	class { '::shorewall::configuration':
		# NOTE: no configuration specifics are needed at the moment
	}

	shorewall::zone { ['net', 'man']:
		type => 'ipv4',
		options => [],	# these aren't really needed right now
	}

	# management zone interface used by vagrant-libvirt
	shorewall::interface { 'man':
		interface => 'MAN_IF',
		broadcast => 'detect',
		physical => 'eth0',	# XXX: set manually!
		options => ['dhcp', 'tcpflags', 'routefilter', 'nosmurfs', 'logmartians'],
		comment => 'Management zone.',	# FIXME: verify options
	}

	# XXX: eth1 'dummy' zone to trick vagrant-libvirt into leaving me alone
	# <no interface definition needed>

	# net zone that gluster uses to communicate
	shorewall::interface { 'net':
		interface => 'NET_IF',
		broadcast => 'detect',
		physical => 'eth2',	# XXX: set manually!
		options => ['tcpflags', 'routefilter', 'nosmurfs', 'logmartians'],
		comment => 'Public internet zone.',	# FIXME: verify options
	}

	# TODO: is this policy really what we want ? can we try to limit this ?
	shorewall::policy { '$FW-net':
		policy => 'ACCEPT',		# TODO: shouldn't we whitelist?
	}

	shorewall::policy { '$FW-man':
		policy => 'ACCEPT',		# TODO: shouldn't we whitelist?
	}

	####################################################################
	#ACTION      SOURCE DEST                PROTO DEST  SOURCE  ORIGINAL
	#                                             PORT  PORT(S) DEST
	shorewall::rule { 'ssh': rule => "
	SSH/ACCEPT   net    $FW
	SSH/ACCEPT   man    $FW
	", comment => 'Allow SSH'}

	shorewall::rule { 'ping': rule => "
	#Ping/DROP    net    $FW
	Ping/ACCEPT  net    $FW
	Ping/ACCEPT  man    $FW
	", comment => 'Allow ping from the `bad` net zone'}

	shorewall::rule { 'icmp': rule => "
	ACCEPT       $FW    net                 icmp
	ACCEPT       $FW    man                 icmp
	", comment => 'Allow icmp from the firewall zone'}
}