containers / ansible-podman-collections

Repository for Ansible content that can include playbooks, roles, modules, and plugins for use with the Podman tool
GNU General Public License v3.0
262 stars 142 forks source link

Enhance volume parameter #102

Open JensHeinrich opened 4 years ago

JensHeinrich commented 4 years ago

/kind feature

Description

Use same structure as docker_container for volumes

Additional information you deem important (e.g. issue happens only occasionally):

This should be done now, so users can switch from docker_container to podman_container with ease (#99 )

Changes

sshnaidm commented 4 years ago

@JensHeinrich what do you see different between docker_container and podman_container volume configuration?

JensHeinrich commented 4 years ago

At least in the documentation there is no mention of the :z etc parameters

JensHeinrich commented 4 years ago

Added a more or less copy pasted list of the flags from the podman doc; this should be supported, at least for creation of containers, if I read the code correctly, but I have no idea about the idempotency and how that snippet will look in the doc (I just typed it in the GitHub editor as a quick example)

JensHeinrich commented 4 years ago

This is how the official docker_container doc says it

List of volumes to mount within the container.
Use docker CLI-style syntax: /host:/container[:mode]
Mount modes can be a comma-separated list of various modes such as ro, rw, consistent, delegated, cached, rprivate, private, rshared, shared, rslave, slave, and nocopy. Note that the docker daemon might not support all modes and combinations of such modes.
SELinux hosts can additionally use z or Z to use a shared or private label for the volume.
Note that Ansible 2.7 and earlier only supported one mode, which had to be one of ro, rw, z, and Z.
JensHeinrich commented 4 years ago

I saw it breaks idempotency at the moment

Should I try to get it running without breaking the idempotency?

sshnaidm commented 4 years ago

@JensHeinrich if we are talking about pr #104 then the problem is not with idempotency, but wrong YAML format which fails the module. You can take a look at job logs: https://github.com/containers/ansible-podman-collections/pull/104/checks?check_run_id=997528180

MODULE_STDERR:

Traceback (most recent call last):
  File "/home/runner/.ansible/tmp/ansible-tmp-1597741479.9267676-12577-132977544453289/AnsiballZ_podman_container.py", line 102, in <module>
    _ansiballz_main()
  File "/home/runner/.ansible/tmp/ansible-tmp-1597741479.9267676-12577-132977544453289/AnsiballZ_podman_container.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/runner/.ansible/tmp/ansible-tmp-1597741479.9267676-12577-132977544453289/AnsiballZ_podman_container.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.containers.podman.plugins.modules.podman_container', init_globals=None, run_name='__main__', alter_sys=True)
  File "/opt/hostedtoolcache/Python/3.7.8/x64/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/opt/hostedtoolcache/Python/3.7.8/x64/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/opt/hostedtoolcache/Python/3.7.8/x64/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_containers.podman.podman_container_payload_8fh0256_/ansible_containers.podman.podman_container_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_container.py", line 2132, in <module>
  File "/tmp/ansible_containers.podman.podman_container_payload_8fh0256_/ansible_containers.podman.podman_container_payload.zip/ansible_collections/containers/podman/plugins/modules/podman_container.py", line 2115, in main
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/composer.py", line 110, in compose_sequence_node
    while not self.check_event(SequenceEndEvent):
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/parser.py", line 382, in parse_block_sequence_entry
    if self.check_token(BlockEntryToken):
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
  File "/home/runner/.local/lib/python3.7/site-packages/yaml/scanner.py", line 579, in fetch_value
    self.get_mark())
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 605, column 51:
     ...  a comma delimited list of these: 
                                         ^
ericzolf commented 3 years ago

I see that the podman_volume does two inconsistent things:

  1. "label" option is partially documented as being a list of var=value but is actually a dict of var: value according to the example (and is also a dictionary in the other modules)
  2. "options" is a list of var=value strings whereas it is a dictionary of var: value in docker_volume