Puppet Class: ipa::server::replica::peering

Defined in:
manifests/server/replica/peering.pp

Overview

Parameters:

  • uuid (Any) (defaults to: '')


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
# File 'manifests/server/replica/peering.pp', line 18

class ipa::server::replica::peering(
	# NOTE: these are *time* based uuid's, eg as generated with: uuidgen -t
	$uuid = '',	# if empty, puppet will attempt to use the uuidgen fact
) {

	include ipa::server::replica::peering::base
	include ipa::vardir
	#$vardir = $::ipa::vardir::module_vardir	# with trailing slash
	$vardir = regsubst($::ipa::vardir::module_vardir, '\/$', '')

	if ("${uuid}" != '') and (! ("${uuid}" =~ /^[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12}$/)) {
		fail("The chosen UUID: '${uuid}' is not valid.")
	}

	# if we manually *pick* a uuid, then store it too, so that it
	# sticks if we ever go back to using automatic uuids. this is
	# useful if a user wants to initially import uuids by picking
	# them manually, and then letting puppet take over afterwards
	file { "${vardir}/replica/peering/uuid":
		# this file object needs to always exist to avoid us purging...
		content => "${uuid}" ? {
			'' => undef,
			default => "${uuid}\n",
		},
		owner => root,
		group => nobody,
		mode => 600,	# might as well...
		ensure => present,
		require => File["${vardir}/replica/peering/"],
	}

	$valid_uuid = "${uuid}" ? {
		# fact from data generated in: ${vardir}/replica/peering/uuid
		'' => "${::ipa_server_replica_uuid}",
		default => "${uuid}",
	}

	@@file { "${vardir}/replica/peering/peer_${::fqdn}":
		content => "${valid_uuid}\n",
		tag => 'ipa-server-replica-peering',
		owner => root,
		group => nobody,
		mode => 600,
		ensure => present,
	}

	# collect to make facts
	File <<| tag == 'ipa-server-replica-peering' |>> {
	}
}