Repository: ansible/molecule

Issue:
Provide a way to add podman arguments
# Issue Type

- Feature request

# Molecule and Ansible details

```
ansible --version && molecule --version
ansible 2.9.9
  config file = None
  configured module search path = ['/var/home/yajo/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /var/home/yajo/mydevel/mando/.venv/lib64/python3.8/site-packages/ansible
  executable location = /var/home/yajo/mydevel/mando/.venv/bin/ansible
  python version = 3.8.3 (default, May 15 2020, 00:00:00) [GCC 10.1.1 20200507 (Red Hat 10.1.1-1)]
molecule 3.0.4
   ansible==2.9.9 python==3.8
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- pip

# Desired Behavior

As you can see in https://github.com/containers/buildah/issues/2175#issuecomment-639296244, podman needs some specific arguments to be able to run inside a privileged docker container, [which is the executor enabled for free in gitlab.com](https://docs.gitlab.com/ee/user/gitlab_com/#shared-runners).

If I want to use podman to test my roles on https://gitlab.com without needing to use a custom executor, it would be very much easier if I had a way to configure podman args.

Specifically I'd need `--cgroup-manager cgroupfs --storage-opt overlay.mount_program=/usr/bin/fuse-overlayfs --storage-driver overlay` in this case, although I guess the possibilities are endless.


Discussion:
@Yajo Sure, no doubts about the need of allowing a way to specify extra arguments in a future proof way.

I still do have few questions around the subject:
- Are these arguments driver specific or container specific? Based on this we may know where we need to add them, maybe even at both levels.
- Do you know if podman ansible modules used do allow this or we need the modules to be improved first?

I did assign the ticket to @sshnaidm as he is the podman plugin author and have the best knowledge in that area.
El dom, 7 de jun de 2020 a las 02:32, Sorin Sbarnea 
<notifications@github.com> escribió:
> Are these arguments driver specific or container specific? Based on 
> this we may know where we need to add them, maybe even at both levels.
I think these are driver-specific. In the issue linked above you can 
see that these flags go between `podman` and `run` in the command, 
basically making them podman-wide flags.
> Do you know if podman ansible modules used do allow this or we need 
> the modules to be improved first?
It seems it is supported 
<https://github.com/containers/ansible-podman-collections/blob/80b2ae6abf87ea12c70440e04bfb15a9e76714c8/plugins/modules/podman_container.py#L146-L152> 
(without idempotence, though).



Resolving patch:
diff --git a/molecule/driver/podman.py b/molecule/driver/podman.py
--- a/molecule/driver/podman.py
+++ b/molecule/driver/podman.py
@@ -91,6 +91,9 @@ class Podman(Driver):
             restart_retries: 1
             buildargs:
               http_proxy: http://proxy.example.com:8080/
+            cgroup_manager: cgroupfs
+            storage_opt: overlay.mount_program=/usr/bin/fuse-overlayfs
+            storage_driver: overlay
 
     If specifying the `CMD`_ directive in your ``Dockerfile.j2`` or consuming a
     built image which declares a ``CMD`` directive, then you must set
diff --git a/molecule/model/schema_v3.py b/molecule/model/schema_v3.py
--- a/molecule/model/schema_v3.py
+++ b/molecule/model/schema_v3.py
@@ -355,6 +355,9 @@ def pre_validate_base_schema(env, keep_string):
                 "network": {"type": "string"},
                 "cert_path": {"type": "string"},
                 "tls_verify": {"type": "boolean"},
+                "cgroup_manager": {"type": "string"},
+                "storage_opt": {"type": "string"},
+                "storage_driver": {"type": "string"},
             },
         },
     }


Test patch:
diff --git a/molecule/test/resources/playbooks/podman/create.yml b/molecule/test/resources/playbooks/podman/create.yml
--- a/molecule/test/resources/playbooks/podman/create.yml
+++ b/molecule/test/resources/playbooks/podman/create.yml
@@ -80,6 +80,9 @@
         {% if item.network is defined %}--network={{ item.network }}{% endif %}
         {% if item.etc_hosts is defined %}{% for i,k in item.etc_hosts.items() %}--add-host {{ i }}:{{ k }} {% endfor %}{% endif %}
         {% if item.hostname is defined %}--hostname={{ item.hostname }}{% elif item.name is defined %}--hostname={{ item.name }}{% endif %}
+        {% if item.cgroup_manager is defined %}--cgroup-manager={{ item.cgroup_manager }}{% endif %}
+        {% if item.storage_opt is defined %}--storage-opt={{ item.storage_opt }}{% endif %}
+        {% if item.storage_driver is defined %}--storage-driver={{ item.storage_driver }}{% endif %}
         {{ item.pre_build_image | default(false) | ternary('', 'molecule_local/') }}{{ item.image }}
         {{ (command_directives_dict | default({}))[item.name] | default('') }}
       register: server