to_pson does not produce 100% correct JSON
Closed this issue · 7 comments
When setting a configuration variable (f.e. downloadSourcePackages
) which Aptly expects to be boolean, the function to_pson
generates a string. Aptly then complains about a bad configuration: ERROR: error loading config file /etc/aptly.conf: json: cannot unmarshal string into Go value of type bool
. Maybe to_json
would be better, but I have not checked it.
Thanks for reporting this @tobru, one of our team will look at this as soon as we can.
This is also busted for the int's.
The following produces bad json as well:
config => {
'rootDir' => '/srv/aptly/.aptly',
'downloadConcurrency' => 8,
}
Doesn't matter if I quote, the 8 or not, it still adds quotes... If I remove the quotes in the /etc/aptly.conf produced I can run the exec commands manually just fine...
+{"rootDir":"/srv/aptly/.aptly","downloadConcurrency":"8"}
ERROR: error loading config file /etc/aptly.conf: json: cannot unmarshal string into Go value of type int
I ended up having to rip out the downloadConcurrency setting as it simply outputs a corrupt config no matter how I do it.
This works:
class { '::aptly':
package_ensure => latest,
repo => false,
user => 'aptly',
config => {
'rootDir' => '/srv/aptly/.aptly',
}
}
There seems to be an easy fix:
to_pson
{"rootDir":"/var/lib/aptly","architectures":["i386","amd64","all"],"ppaDistributorID":"ubuntu","downloadSourcePackages":"false","downloadConcurrency":"8"}
to_json
{"rootDir":"/var/lib/aptly","architectures":["i386","amd64","all"],"ppaDistributorID":"ubuntu","downloadSourcePackages":false,"downloadConcurrency":8}
Closing this issue, as it looks resolved. If I have this wrong, or you need to re-open, please do!
Re-opened this after discussion with @mattbostock because we think this is still a legitimate bug that needs resolving at some stage.
I'm unable to reproduce this bug using version 0.3.0 of this module.
This hieradata:
aptly::config:
foo: true
bar: 999
baz: 'hello'
Produces this config file on disk:
$ cat /etc/aptly.conf | python -m json.tool
{
"bar": 999,
"baz": "hello",
"foo": true
}
I wonder if this is related to everything in Puppet 3 being a string. It's not a problem using hiera and I wonder whether it will be resolved by using Puppet 4 too. This Puppet 3.8 class has an interesting result:
class { 'aptly':
config => {
'foo' => true,
'bar' => 999,
'baz' => 'hello',
},
}
$ cat /etc/aptly.conf | python -m json.tool
{
"bar": "999",
"baz": "hello",
"foo": true
}
Hi there, folks. Apologies for the thread necromancy — I'm closing this out so you don't get stuck with an unresolvable issue when this repo is archived.
We don't have anyone maintaining this repo any more as we no longer run Puppet. I'm about to archive this and a bunch of other Puppet-related repos that we haven't touched in a long time.
Thanks for taking the time to report and work on this issue ❤️