forked from waveclaw/puppet-subscription_manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.pp
75 lines (71 loc) · 2.85 KB
/
config.pp
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
# Class subscription_manager::config
# ==================================
#
# This class is called from subscription_manager for service config.
#
# Authors
# -------
#
# * Gaël Chamoulaud <gchamoul@redhat.com>
# * JD Powell <waveclaw@waveclaw.net>
#
# Copyright
# ---------
#
# Copyright 2016 JD Powell <waveclaw@waveclaw.net>
#
class subscription_manager::config {
# prefer activation keys to username. Then fail when neither are provided
if $::subscription_manager::activationkey != undef and
$::subscription_manager::activationkey != '' {
$_settings = {
'pool' => $::subscription_manager::pool,
'autosubscribe' => $::subscription_manager::autosubscribe,
'force' => $::subscription_manager::force,
'org' => $::subscription_manager::org,
'servicelevel' => $::subscription_manager::servicelevel,
'activationkey' => $::subscription_manager::activationkey,
}
} else {
if $::subscription_manager::username != undef and
$::subscription_manager::username !='' and
$::subscription_manager::password != undef and
$::subscription_manager::password != '' {
$_settings = {
'pool' => $::subscription_manager::pool,
'autosubscribe' => $::subscription_manager::autosubscribe,
'force' => $::subscription_manager::force,
'org' => $::subscription_manager::org,
'servicelevel' => $::subscription_manager::servicelevel,
'username' => $::subscription_manager::username,
'password' => $::subscription_manager::password,
'lifecycleenv' => $::subscription_manager::lifecycleenv, }
} else {
$_settings = {}
}
}
# this part can be used with a pulp server used to 'init' new servers
# if $::subscription_manager::config_hash['rhsm_baseurl'] == undef {
# $_conf_params['/etc/rhsm/rhsm.conf']['rhsm_baseurl'] =
# "https://${::subscription_manager::server_hostname}/pulp/repos"
# }
rhsm_config { '/etc/rhsm/rhsm.conf':
ensure => present,
* => $::subscription_manager::config_hash,
}
# Four cases
# I. never registered
# II. registered to correct server but forcing it
# III. registered to different server
# IV. registered to same server but forcing it
if ($::facts['rhsm_identity'] == '' or $::facts['rhsm_identity'] == undef or
($::facts['rhsm_ca_name'] != $::subscription_manager::server_hostname or
$::facts['rhsm_ca_name'] != 'Red Hat Entitlement Product Authority/emailAddress=ca-support@redhat.com') or
$::subscription_manager::force == true ) {
rhsm_register { $::subscription_manager::server_hostname:
ensure => present,
require => Rhsm_config['/etc/rhsm/rhsm.conf'],
* => $_settings,
}
}
}