|
15 | 15 | # @param repo_location |
16 | 16 | # Location of the upstream repository |
17 | 17 | # |
| 18 | +# @param keyring_location |
| 19 | +# Location of the upstream keyring |
| 20 | +# |
18 | 21 | # @param proxy |
19 | 22 | # Proxy hostnam |
20 | 23 | # |
|
24 | 27 | # @param proxy_password |
25 | 28 | # Proxy pasword |
26 | 29 | # |
27 | | -# @param aptkey_options |
28 | | -# Options for debian aptkey |
29 | | -# |
30 | 30 | class mongodb::repo ( |
31 | | - Enum['present', 'absent'] $ensure = 'present', |
32 | | - Optional[String] $version = undef, |
33 | | - Boolean $use_enterprise_repo = false, |
34 | | - Optional[String] $repo_location = undef, |
35 | | - Optional[String] $proxy = undef, |
36 | | - Optional[String] $proxy_username = undef, |
37 | | - Optional[String] $proxy_password = undef, |
38 | | - Optional[String[1]] $aptkey_options = undef, |
| 31 | + Enum['present', 'absent'] $ensure = 'present', |
| 32 | + Optional[String] $version = undef, |
| 33 | + Boolean $use_enterprise_repo = false, |
| 34 | + Optional[String[1]] $repo_location = undef, |
| 35 | + Optional[String[1]] $keyring_location = undef, |
| 36 | + Optional[String[1]] $proxy = undef, |
| 37 | + Optional[String[1]] $proxy_username = undef, |
| 38 | + Optional[String[1]] $proxy_password = undef, |
39 | 39 | ) { |
40 | 40 | if $version == undef and $repo_location == undef { |
41 | 41 | fail('`version` or `repo_location` is required') |
|
50 | 50 | case $facts['os']['family'] { |
51 | 51 | 'RedHat', 'Linux': { |
52 | 52 | if $repo_location != undef { |
53 | | - $location = $repo_location |
| 53 | + $_repo_location = $repo_location |
54 | 54 | $description = 'MongoDB Custom Repository' |
55 | 55 | } else { |
56 | 56 | if $use_enterprise_repo { |
57 | | - $location = "https://repo.mongodb.com/yum/redhat/\$releasever/mongodb-enterprise/${version}/\$basearch/" |
| 57 | + $_repo_location = "https://repo.mongodb.com/yum/redhat/\$releasever/mongodb-enterprise/${version}/\$basearch/" |
58 | 58 | $description = 'MongoDB Enterprise Repository' |
59 | 59 | } else { |
60 | | - $location = "https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/${version}/\$basearch/" |
| 60 | + $_repo_location = "https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/${version}/\$basearch/" |
61 | 61 | $description = 'MongoDB Repository' |
62 | 62 | } |
63 | 63 | } |
64 | 64 |
|
65 | | - contain mongodb::repo::yum |
| 65 | + class { 'mongodb::repo::yum': |
| 66 | + ensure => $ensure, |
| 67 | + repo_location => $_repo_location, |
| 68 | + description => $description, |
| 69 | + proxy => $proxy, |
| 70 | + proxy_username => $proxy_username, |
| 71 | + proxy_password => $proxy_password, |
| 72 | + } |
66 | 73 | } |
67 | 74 |
|
68 | 75 | 'Suse': { |
69 | 76 | if $repo_location { |
70 | | - $location = $repo_location |
| 77 | + $_repo_location = $repo_location |
71 | 78 | $description = 'MongoDB Custom Repository' |
72 | 79 | } else { |
73 | | - $location = "https://repo.mongodb.org/zypper/suse/\$releasever_major/mongodb-org/${version}/\$basearch/" |
| 80 | + $_repo_location = "https://repo.mongodb.org/zypper/suse/\$releasever_major/mongodb-org/${version}/\$basearch/" |
74 | 81 | $description = 'MongoDB Repository' |
75 | 82 | } |
76 | 83 |
|
77 | | - contain mongodb::repo::zypper |
| 84 | + class { 'mongodb::repo::zypper': |
| 85 | + ensure => $ensure, |
| 86 | + repo_location => $_repo_location, |
| 87 | + description => $description, |
| 88 | + } |
78 | 89 | } |
79 | 90 |
|
80 | 91 | 'Debian': { |
81 | 92 | if $repo_location != undef { |
82 | | - $location = $repo_location |
| 93 | + $_repo_location = $repo_location |
| 94 | + $_keyring_location = $keyring_location |
83 | 95 | } else { |
84 | 96 | if $use_enterprise_repo == true { |
85 | 97 | $repo_domain = 'repo.mongodb.com' |
|
89 | 101 | $repo_path = 'mongodb-org' |
90 | 102 | } |
91 | 103 |
|
92 | | - $location = $facts['os']['name'] ? { |
| 104 | + $_repo_location = $facts['os']['name'] ? { |
93 | 105 | 'Debian' => "https://${repo_domain}/apt/debian", |
94 | 106 | 'Ubuntu' => "https://${repo_domain}/apt/ubuntu", |
95 | 107 | default => undef |
96 | 108 | } |
| 109 | + $_keyring_location = "https://www.mongodb.org/static/pgp/server-${version}.asc" |
97 | 110 | $release = "${facts['os']['distro']['codename']}/${repo_path}/${version}" |
98 | 111 | $repos = $facts['os']['name'] ? { |
99 | 112 | 'Debian' => 'main', |
100 | 113 | 'Ubuntu' => 'multiverse', |
101 | 114 | default => undef |
102 | 115 | } |
103 | | - $key = $version ? { |
104 | | - '5.0' => 'F5679A222C647C87527C2F8CB00A0BD1E2C63C11', |
105 | | - '4.4' => '20691EEC35216C63CAF66CE1656408E390CFB1F5', |
106 | | - default => '20691EEC35216C63CAF66CE1656408E390CFB1F5' |
107 | | - } |
108 | | - $key_server = 'hkp://keyserver.ubuntu.com:80' |
| 116 | + $comment = 'MongoDB Repository' |
109 | 117 | } |
110 | 118 |
|
111 | | - contain mongodb::repo::apt |
| 119 | + class { 'mongodb::repo::apt': |
| 120 | + ensure => $ensure, |
| 121 | + repo_location => $_repo_location, |
| 122 | + keyring_location => $_keyring_location, |
| 123 | + release => $release, |
| 124 | + repos => $repos, |
| 125 | + comment => $comment, |
| 126 | + } |
112 | 127 | } |
113 | 128 |
|
114 | 129 | default: { |
115 | 130 | if($ensure == 'present') { |
116 | | - fail("Unsupported managed repository for osfamily: ${facts['os']['family']}, operatingsystem: ${facts['os']['name']}, module ${module_name} currently only supports managing repos for osfamily RedHat, Suse, Debian and Ubuntu") |
| 131 | + fail("Unsupported managed repository for osfamily: ${facts['os']['family']}, operatingsystem: ${facts['os']['name']}") |
117 | 132 | } |
118 | 133 | } |
119 | 134 | } |
|
0 commit comments