puppetlabs / puppetlabs-docker

The Puppet Docker repository
Apache License 2.0
91 stars 311 forks source link

docker_volume resource ignoring multiple options #197

Closed diegolima closed 6 years ago

diegolima commented 6 years ago

What you expected to happen?

Volume is created using multiple options provided as a list

What happened?

Volume gets created using only the first option

How to reproduce it?

I currently have this on a hiera file:

docker::volume:
  blueocean:
    driver: local
    options:
      - type=nfs
      - o=addr=%{custom_manager},rw
      - device=:/srv/blueocean

And this on the puppet manifest:

  $docker_volume = hiera('docker::volume', undef)
  if $docker_volume {
    create_resources('docker_volume', $docker_volume)
  }

Versions:

# puppet --version
4.10.10

# docker --version
Docker version 17.12.1-ce, build 7390fc6

# facter os
{
  architecture => "x86_64",
  family => "RedHat",
  hardware => "x86_64",
  name => "CentOS",
  release => {
    full => "7.4.1708",
    major => "7",
    minor => "4"
  },
  selinux => {
    config_mode => "enforcing",
    current_mode => "enforcing",
    enabled => true,
    enforced => true,
    policy_version => "28"
  }
}

$ puppet module list
/etc/puppetlabs/code/environments/orquestrador_prod/modules
├── derdanne-nfs (v2.0.7)
├── puppetlabs-apt (v4.5.1)
├── puppetlabs-concat (v4.2.0)
├── puppetlabs-docker (v1.0.5)
├── puppetlabs-stdlib (v4.24.0)
└── puppetlabs-translate (v1.0.0)
/etc/puppetlabs/code/environments/common
├── files (???)
├── hierdata (???)
├── manifests (???)
└── modules (???)
/etc/puppetlabs/code/modules (no modules installed)
/opt/puppetlabs/puppet/modules (no modules installed)
/etc/puppetlabs/code/environments/common/modules
└── stahnma-epel (v1.3.0)

Logs:

Debug: Executing: '/bin/docker volume ls'
Debug: Executing: '/bin/docker volume inspect a2e1d1a5e9561c58318c514934340f76705fc75dd8474c07e624af9c1262f83c'
Info: Checking if docker volume blueocean exists
Info: Creating docker volume blueocean
Debug: Executing: '/bin/docker volume create --driver=local --opt=type=nfs blueocean'
Notice: /Stage[main]/Main/Node[__node_regexp__swarm-.]/Docker_volume[blueocean]/ensure: created
davejrt commented 6 years ago

That type/provider expects an array for the options, not a hash.

I've tested successfully with the following hieara entry

docker::volume:
  blueocean:
    driver: local
    options:
      - ['type=nfs','o=addr=%{custom_manager},rw','device=:/srv/blueocean']
==> node-01: Debug: Executing: '/usr/bin/docker volume create --driver=local --opt=type=nfs --opt=o=addr=,rw --opt=device=:/srv/blueocean blueocean'
diegolima commented 6 years ago

Hi! Thanks for the input! I think that we could use some better documentation for the volume type, as currently there is once single example that doesn't even have multiple options. Declaring as an array got things working though.

davejrt commented 6 years ago

agreed, ill make sure it’s updated for the next release

davejrt commented 6 years ago

Updated in README PR #204

RussellMcOrmond commented 5 years ago

I'm wondering if a non-hieara example can be given, or tested?

I've not been able to get volume to work.

docker_volume { 'am-pipeline-data':
  ensure => present,
  driver => 'local',
  options => [ 'type=none',  'o=bind', 'device=/cihmz/am-pipeline-data']
}

is giving me:

russell@huntsman:~$ docker volume inspect am-pipeline-data
[
    {
        "CreatedAt": "2019-05-01T13:53:40-04:00",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/am-pipeline-data/_data",
        "Name": "am-pipeline-data",
        "Options": {
            "type": "none"
        },
        "Scope": "local"
    }
]