|
15 | 15 | # @param aptkey_options |
16 | 16 | # |
17 | 17 | class mongodb::repo ( |
18 | | - Variant[Enum['present', 'absent'], Boolean] $ensure = 'present', |
19 | | - Optional[String] $version = undef, |
20 | | - Boolean $use_enterprise_repo = false, |
21 | | - Optional[String] $repo_location = undef, |
22 | | - Optional[String] $proxy = undef, |
23 | | - Optional[String] $proxy_username = undef, |
24 | | - Optional[String] $proxy_password = undef, |
25 | | - Optional[String[1]] $aptkey_options = undef, |
| 18 | + Enum['present', 'absent'] $ensure = 'present', |
| 19 | + Optional[String] $version = undef, |
| 20 | + Boolean $use_enterprise_repo = false, |
| 21 | + Optional[String] $repo_location = undef, |
| 22 | + Optional[String] $proxy = undef, |
| 23 | + Optional[String] $proxy_username = undef, |
| 24 | + Optional[String] $proxy_password = undef, |
| 25 | + Optional[String[1]] $aptkey_options = undef, |
26 | 26 | ) { |
| 27 | + if $version == undef and $repo_location == undef { |
| 28 | + fail('`version` or `repo_location` is required') |
| 29 | + } |
| 30 | + if $version != undef and $repo_location != undef { |
| 31 | + fail('`version` is not supported with `repo_location`') |
| 32 | + } |
| 33 | + if $version != undef and versioncmp($version, '4.4') < 0 { |
| 34 | + fail('Package repositories for versions older than 4.4 are unsupported') |
| 35 | + } |
| 36 | + |
27 | 37 | case $facts['os']['family'] { |
28 | 38 | 'RedHat', 'Linux': { |
29 | 39 | if $repo_location != undef { |
30 | 40 | $location = $repo_location |
31 | 41 | $description = 'MongoDB Custom Repository' |
32 | | - } elsif $version == undef or versioncmp($version, '3.0.0') < 0 { |
33 | | - fail('Package repositories for versions older than 3.0 are unsupported') |
34 | 42 | } else { |
35 | | - $mongover = split($version, '[.]') |
36 | 43 | if $use_enterprise_repo { |
37 | | - $location = "https://repo.mongodb.com/yum/redhat/\$releasever/mongodb-enterprise/${mongover[0]}.${mongover[1]}/\$basearch/" |
| 44 | + $location = "https://repo.mongodb.com/yum/redhat/\$releasever/mongodb-enterprise/${version}/\$basearch/" |
38 | 45 | $description = 'MongoDB Enterprise Repository' |
39 | 46 | } else { |
40 | | - $location = "https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/${mongover[0]}.${mongover[1]}/\$basearch/" |
| 47 | + $location = "https://repo.mongodb.org/yum/redhat/\$releasever/mongodb-org/${version}/\$basearch/" |
41 | 48 | $description = 'MongoDB Repository' |
42 | 49 | } |
43 | 50 | } |
|
49 | 56 | if $repo_location { |
50 | 57 | $location = $repo_location |
51 | 58 | $description = 'MongoDB Custom Repository' |
52 | | - } elsif $version == undef or versioncmp($version, '3.2.0') < 0 { |
53 | | - fail('Package repositories for versions older than 3.2 are unsupported') |
54 | 59 | } else { |
55 | | - $mongover = split($version, '[.]') |
56 | | - $location = "https://repo.mongodb.org/zypper/suse/\$releasever_major/mongodb-org/${mongover[0]}.${mongover[1]}/\$basearch/" |
| 60 | + $location = "https://repo.mongodb.org/zypper/suse/\$releasever_major/mongodb-org/${version}/\$basearch/" |
57 | 61 | $description = 'MongoDB Repository' |
58 | 62 | } |
59 | 63 |
|
|
63 | 67 | 'Debian': { |
64 | 68 | if $repo_location != undef { |
65 | 69 | $location = $repo_location |
66 | | - } elsif $version == undef or versioncmp($version, '3.0.0') < 0 { |
67 | | - fail('Package repositories for versions older than 3.0 are unsupported') |
68 | 70 | } else { |
69 | 71 | if $use_enterprise_repo == true { |
70 | 72 | $repo_domain = 'repo.mongodb.com' |
|
74 | 76 | $repo_path = 'mongodb-org' |
75 | 77 | } |
76 | 78 |
|
77 | | - $mongover = split($version, '[.]') |
78 | 79 | $location = $facts['os']['name'] ? { |
79 | 80 | 'Debian' => "https://${repo_domain}/apt/debian", |
80 | 81 | 'Ubuntu' => "https://${repo_domain}/apt/ubuntu", |
81 | 82 | default => undef |
82 | 83 | } |
83 | | - $release = "${facts['os']['distro']['codename']}/${repo_path}/${mongover[0]}.${mongover[1]}" |
| 84 | + $release = "${facts['os']['distro']['codename']}/${repo_path}/${version}" |
84 | 85 | $repos = $facts['os']['name'] ? { |
85 | 86 | 'Debian' => 'main', |
86 | 87 | 'Ubuntu' => 'multiverse', |
87 | 88 | default => undef |
88 | 89 | } |
89 | | - $key = "${mongover[0]}.${mongover[1]}" ? { |
| 90 | + $key = $version ? { |
90 | 91 | '5.0' => 'F5679A222C647C87527C2F8CB00A0BD1E2C63C11', |
91 | 92 | '4.4' => '20691EEC35216C63CAF66CE1656408E390CFB1F5', |
92 | | - '4.2' => 'E162F504A20CDF15827F718D4B7C549A058F8B6B', |
93 | | - '4.0' => '9DA31620334BD75D9DCB49F368818C72E52529D4', |
94 | | - '3.6' => '2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5', |
95 | | - '3.4' => '0C49F3730359A14518585931BC711F9BA15703C6', |
96 | | - '3.2' => '42F3E95A2C4F08279C4960ADD68FA50FEA312927', |
97 | | - default => '492EAFE8CD016A07919F1D2B9ECBEC467F0CEB10' |
| 93 | + default => '20691EEC35216C63CAF66CE1656408E390CFB1F5' |
98 | 94 | } |
99 | 95 | $key_server = 'hkp://keyserver.ubuntu.com:80' |
100 | 96 | } |
|
103 | 99 | } |
104 | 100 |
|
105 | 101 | default: { |
106 | | - if($ensure == 'present' or $ensure == true) { |
| 102 | + if($ensure == 'present') { |
107 | 103 | 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") |
108 | 104 | } |
109 | 105 | } |
|
0 commit comments