Closed gdlx closed 3 years ago
I'm not sure it's related but running v3.6.0
I am not able to create any docker files, whether by hiera data or manifests.
The following is how I tested via hiera
classes:
- docker::images
- docker::volumes
docker::volumes::volumes:
mayan-edms:
ensure: present
driver: local
mayan-edms-postgres:
ensure: present
driver: local
And here is how I tested the classic way
node 'foo' {
include docker::volumes
docker_volume { 'mayan-edms2':
ensure => present
}
}
I'm probably doing something stupid and missing something but I don't see it docker::volumes run at all with either method. Same version of docker as the OP though
I did the PR 2 month ago to change the documentation from array to hash format. That looked to me what the module expects. But the volume provider seems to have a different logic for creating and modifying the resource. Existing configuration is retrieved by inspect in json format resulting in the configuration to be a hash while the create() is expecting array format.
As @gdlx wrote there is a notice to change the resource on every puppet run. This is because the provider detects the difference but does not support applying changes to the existing resource. Afaik this is also not supported by docker.
May be its best to flatten the hash to an array in case:
--- a/lib/puppet/provider/docker_volume/ruby.rb
+++ b/lib/puppet/provider/docker_volume/ruby.rb
@@ -11,6 +11,7 @@ Puppet::Type.type(:docker_volume).provide(:ruby) do
def volume_conf
flags = ['volume', 'create']
multi_flags = ->(values, format) {
+ values = values.map! { |k,v| "#{k}=#{v}" } if values.is_a? Hash
filtered = [values].flatten.compact
filtered.map { |val| format % val }
}
The provider should also add at least some warning in case of changes he is unable to apply.
I did the PR 2 month ago to change the documentation from array to hash format. That looked to me what the module expects.
I wish it really becomes the expected format, because it's the most convenient one, but I don't know if there's a technical constraint forcing to use this double nested array format...
Closing issue as PR was merged
What you expected to happen?
Filling Docker_Volume options with a Hash, as defines in the doc: https://forge.puppet.com/puppetlabs/docker#volumes
What happened?
I get the following error:
The options hash is sent to the docker command as a json strin instead of multiple
--opt
parameters.Please note I've already seen #197, there's still an issue.
How to reproduce it?
Define a docker volume with multiple options like this:
Anything else we need to know?
Looking at #197, the only way I've been able to define the volume options, is not in an array, but in 2 arrays, like this:
It's working fine, even if the syntax is a bit odd, but each time I run Puppet then I get this notice:
So there is clearly something wrong with the way volume options is handled: The syntax is not the same than in the docs, and the current state doesn't give the same result, leading to a detected difference on each Puppet run.
Versions:
But here's my
Puppetfile.lock
: