Skip to content

Commit

Permalink
Enable arbitrary configuration, parameter cleanup. Fixes tubemogul#67.
Browse files Browse the repository at this point in the history
This commit enables arbitrary configuration via $properties.
It also cleans up the options that can be used as those have been moved
to $properties.
  • Loading branch information
Maurice Meyer committed Nov 15, 2018
1 parent 18b1acd commit dedc294
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 33 deletions.
6 changes: 4 additions & 2 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
group => $aptly::group,
}

$config = deep_merge($aptly::properties, $aptly::params::properties)

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 => $aptly::recurse_root_dir,
Expand Down
12 changes: 1 addition & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
$uid = $aptly::params::uid,
$group = $aptly::params::group,
$gid = $aptly::params::gid,
$root_dir = $aptly::params::root_dir,
$architectures = $aptly::params::architectures,
$ppa_dist = $aptly::params::ppa_dist,
$ppa_codename = $aptly::params::ppa_codename,
$properties = $aptly::params::properties,
$s3_publish_endpoints = $aptly::params::s3_publish_endpoints,
$swift_publish_endpoints = $aptly::params::swift_publish_endpoints,
$enable_api = $aptly::params::enable_api,
$api_port = $aptly::params::api_port,
$api_bind = $aptly::params::api_bind,
Expand All @@ -44,8 +38,7 @@
$repo_keyserver,
$config_filepath,
$user,
$group,
$root_dir)
$group)
if ! is_integer($uid) { fail("invalid ${uid} provided") }
if ! is_integer($gid) { fail("invalid ${gid} provided") }
validate_re($repo_key, '^[A-F0-9]+$')
Expand All @@ -55,10 +48,7 @@
$enable_api,
$api_nolock,
$recurse_root_dir)
validate_array($architectures)
validate_hash($properties)
validate_hash($s3_publish_endpoints)
validate_hash($swift_publish_endpoints)
validate_integer($port, 49150)
validate_integer($api_port, 49150)
validate_re(
Expand Down
23 changes: 7 additions & 16 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,14 @@
$uid = 450
$group = 'aptly'
$gid = 450
$root_dir = '/var/aptly'
$architectures = [$::architecture]
$ppa_dist = 'ubuntu'
$ppa_codename = ''
$properties = {
'downloadConcurrency' => 4,
'downloadSpeedLimit' => 0,
'dependencyFollowSuggests' => false,
'dependencyFollowRecommends' => false,
'dependencyFollowAllVariants' => false,
'dependencyFollowSource' => false,
'gpgDisableSign' => false,
'gpgDisableVerify' => false,
'downloadSourcePackages' => false,
}
$s3_publish_endpoints = {}
$swift_publish_endpoints = {}
'rootDir' => '/var/aptly',
'architectures' => [$::architecture],
'ppaDistributorID' => 'ubuntu',
'ppaCodename' => '',
'S3PublishEndpoints' => {},
'SwiftPublishEndpoints' => {},
}
$enable_api = false
$api_port = 8081
$api_bind = '0.0.0.0'
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions templates/aptly.conf.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"rootDir": "<%= scope.lookupvar('aptly::root_dir') -%>",
"architectures": ["<%= scope.lookupvar('aptly::architectures').join('", "') %>"],
<% scope.lookupvar('aptly::properties').each do |k, v| -%>
"<%= k -%>": <%= v %>,
<% end -%>
<%= scope.lookupvar('aptly::properties').to_pson -%>,
"ppaDistributorID": "<%= scope.lookupvar('aptly::ppa_dist') %>",
"ppaCodename": "<%= scope.lookupvar('aptly::ppa_codename') %>",
"S3PublishEndpoints": <%= scope.lookupvar('aptly::s3_publish_endpoints').to_pson %>,
Expand Down

0 comments on commit dedc294

Please sign in to comment.