From 8aacbde53f1a20d6815c5e0b3fc11d2f0288dc01 Mon Sep 17 00:00:00 2001 From: Maurice Meyer Date: Thu, 15 Nov 2018 13:55:43 +0100 Subject: [PATCH] Enable arbitrary configuration, deprecate parameters This commit enables arbitrary configuration via $properties. It also deprecates the options that can be used as those have been moved to $properties. --- manifests/config.pp | 16 ++++++++++++++-- manifests/init.pp | 7 +++++++ manifests/params.pp | 18 ++++++++++++------ metadata.json | 2 +- templates/aptly.conf.erb | 11 ----------- 5 files changed, 34 insertions(+), 20 deletions(-) delete mode 100644 templates/aptly.conf.erb diff --git a/manifests/config.pp b/manifests/config.pp index 0a76005..51fbf3a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -11,12 +11,24 @@ group => $aptly::group, } + # This can be removed once the parameters in here are removed + $backwards_compatibility_config = { + 'rootDir' => $aptly::root_dir, + 'architectures' => $aptly::architectures, + 'ppaDistributorID' => $aptly::ppa_dist, + 'ppaCodename' => $aptly::ppa_codename, + 'S3PublishEndpoints' => $aptly::s3_publish_endpoints, + 'SwiftPublishEndpoints' => $aptly::swift_publish_endpoints, + } + + $config = deep_merge($aptly::params::properties, $aptly::properties, $backwards_compatibility_config) + file { $aptly::config_filepath: ensure => file, - content => template('aptly/aptly.conf.erb'), + content => to_json_pretty($config), } - file { $aptly::root_dir: + file { $config['rootDir']: ensure => directory, mode => '0644', recurse => true, diff --git a/manifests/init.pp b/manifests/init.pp index 87d7a55..d4d153a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -70,5 +70,12 @@ 'API Bind IP address is not correct' ) + deprecation('root_dir', 'Please configure this via properties => rootDir') + deprecation('architectures', 'Please configure this via properties => architectures') + deprecation('ppa_dist', 'Please configure this via properties => ppaDistributorID') + deprecation('ppa_codename', 'Please configure this via properties => ppaCodename') + deprecation('s3_publish_endpoints', 'Please configure this via properties => S3PublishEndpoints') + deprecation('swift_publish_endpoints', 'Please configure this via properties => SwiftPublishEndpoints') + class { '::aptly::install': } -> class { '::aptly::config': } ~> class { '::aptly::service': } -> Class['::aptly'] } diff --git a/manifests/params.pp b/manifests/params.pp index 8717831..7d9db65 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -20,10 +20,6 @@ $uid = 450 $group = 'aptly' $gid = 450 - $root_dir = '/var/aptly' - $architectures = [$::architecture] - $ppa_dist = 'ubuntu' - $ppa_codename = '' $properties = { 'downloadConcurrency' => 4, 'downloadSpeedLimit' => 0, @@ -34,9 +30,19 @@ 'gpgDisableSign' => false, 'gpgDisableVerify' => false, 'downloadSourcePackages' => false, + 'rootDir' => '/var/aptly', + 'architectures' => [$::architecture], + 'ppaDistributorID' => 'ubuntu', + 'ppaCodename' => '', + 'S3PublishEndpoints' => {}, + 'SwiftPublishEndpoints' => {}, } - $s3_publish_endpoints = {} - $swift_publish_endpoints = {} + $root_dir = $properties['rootDir'] + $architectures = $properties['architectures'] + $ppa_dist = $properties['ppaDistributorID'] + $ppa_codename = $properties['ppaCodename'] + $s3_publish_endpoints = $properties['S3PublishEndpoints'] + $swift_publish_endpoints = $properties['SwiftPublishEndpoints'] $enable_api = false $api_port = 8081 $api_bind = '0.0.0.0' diff --git a/metadata.json b/metadata.json index 2b61540..3862d50 100644 --- a/metadata.json +++ b/metadata.json @@ -25,7 +25,7 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">= 4.0.0 < 5.0.0" + "version_requirement": ">= 4.24.0 < 5.0.0" }, { "name": "puppetlabs/apt", diff --git a/templates/aptly.conf.erb b/templates/aptly.conf.erb deleted file mode 100644 index 5026c14..0000000 --- a/templates/aptly.conf.erb +++ /dev/null @@ -1,11 +0,0 @@ -{ - "rootDir": "<%= scope.lookupvar('aptly::root_dir') -%>", - "architectures": ["<%= scope.lookupvar('aptly::architectures').join('", "') %>"], -<% scope.lookupvar('aptly::properties').each do |k, v| -%> - "<%= k -%>": <%= v %>, -<% end -%> - "ppaDistributorID": "<%= scope.lookupvar('aptly::ppa_dist') %>", - "ppaCodename": "<%= scope.lookupvar('aptly::ppa_codename') %>", - "S3PublishEndpoints": <%= scope.lookupvar('aptly::s3_publish_endpoints').to_pson %>, - "SwiftPublishEndpoints": <%= scope.lookupvar('aptly::swift_publish_endpoints').to_pson %> -}