-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
init.pp
80 lines (75 loc) · 1.68 KB
/
init.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
76
77
78
79
80
# == Class: rhsm
#
# Subscribe the node to the RHSM
#
# === Parameters
#
# Document parameters here.
#
# [*rh_user*]
# User for the Customer Portal
# [*rh_password*]
# Password for the rh_user account
# [*servername*]
# Servername, default is provided.
# [*proxy_hostname*]
# Proxy hostname
# [*proxy_port*]
# Proxy port
# [*proxy_user*]
# Proxy user
# [*proxy_password*]
# Proxy password
# [*baseurl*]
# Base URL for rhsm, default provided.
# [*manage_repos*]
# Manage the repositories
#
# === Examples
#
# include rhsm
#
# Hierafile:
# ---
# rhsm::rh_user: myuser
# rhsm::rh_password: mypassword
#
# === Authors
#
# Ger Apeldoorn <info@gerapeldoorn.nl>
#
# === Copyright
#
# Copyright 2014 Ger Apeldoorn, unless otherwise noted.
#
class rhsm (
$rh_user,
$rh_password,
$servername = 'subscription.rhn.redhat.com',
$proxy_hostname = undef,
$proxy_port = undef,
$proxy_user = undef,
$proxy_password = undef,
$baseurl= 'https://cdn.redhat.com',
$manage_repos = 1,
) {
if $proxy_hostname {
$proxycli = "--proxy=http://${proxy_hostname}:${proxy_port} --proxyuser=${proxy_user} --proxypass=${proxy_password}"
}
$command = "/usr/sbin/subscription-manager register --force --name=\"${::fqdn}\" --username=\"${rh_user}\" --password=\"${rh_password}\" --auto-attach ${proxycli}"
package { 'subscription-manager':
ensure => latest,
}
exec {'sm yum clean all':
command => '/usr/bin/yum clean all',
refreshonly => true,
subscribe => Package['subscription-manager'],
}
file { '/etc/rhsm/rhsm.conf':
ensure => file,
}
exec { 'RHNSM-register':
command => $command,
unless => '/usr/sbin/subscription-manager status | grep Current',
}
}