internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: ansible/molecule

Issue:
_print_valid_platforms() throws stack trace
```
molecule status --platform=ubuntu

Invalid platform 'ubuntu'

AVAILABLE PLATFORMS
Traceback (most recent call last):
  File "/usr/local/bin/molecule", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/molecule/cli.py", line 86, in main
    CLI().main()
  File "/Library/Python/2.7/site-packages/molecule/cli.py", line 81, in main
    c = command_class(args)
  File "/Library/Python/2.7/site-packages/molecule/commands.py", line 55, in __init__
    self.molecule.main()
  File "/Library/Python/2.7/site-packages/molecule/core.py", line 75, in main
    self._print_valid_platforms()
  File "/Library/Python/2.7/site-packages/molecule/core.py", line 118, in _print_valid_platforms
    default_platform = self._provisioner.default_platform
AttributeError: 'NoneType' object has no attribute 'default_platform'
```

_print_valid_platforms() throws stack trace
```
molecule status --platform=ubuntu

Invalid platform 'ubuntu'

AVAILABLE PLATFORMS
Traceback (most recent call last):
  File "/usr/local/bin/molecule", line 11, in <module>
    sys.exit(main())
  File "/Library/Python/2.7/site-packages/molecule/cli.py", line 86, in main
    CLI().main()
  File "/Library/Python/2.7/site-packages/molecule/cli.py", line 81, in main
    c = command_class(args)
  File "/Library/Python/2.7/site-packages/molecule/commands.py", line 55, in __init__
    self.molecule.main()
  File "/Library/Python/2.7/site-packages/molecule/core.py", line 75, in main
    self._print_valid_platforms()
  File "/Library/Python/2.7/site-packages/molecule/core.py", line 118, in _print_valid_platforms
    default_platform = self._provisioner.default_platform
AttributeError: 'NoneType' object has no attribute 'default_platform'
```



Discussion:

Resolving patch:
diff --git a/molecule/core.py b/molecule/core.py
--- a/molecule/core.py
+++ b/molecule/core.py
@@ -68,10 +68,14 @@ def main(self):
             self._provisioner = provisioners.get_provisioner(self)
         except provisioners.InvalidProviderSpecified:
             print("\n{}Invalid provider '{}'\n".format(Fore.RED, self._args['--provider'], Fore.RESET))
+            self._args['--provider'] = None
+            self._provisioner = provisioners.get_provisioner(self)
             self._print_valid_providers()
             sys.exit(1)
         except provisioners.InvalidPlatformSpecified:
             print("\n{}Invalid platform '{}'\n".format(Fore.RED, self._args['--platform'], Fore.RESET))
+            self._args['--platform'] = None
+            self._provisioner = provisioners.get_provisioner(self)
             self._print_valid_platforms()
             sys.exit(1)
 


Test patch:
Repository: ansible/molecule

Issue:
molecule converge --tags <tags> fails if not created
`molecule converge` will first call `molecule create` if instances haven't been created. This causes an error when passing --tags to `molecule converge` since `create` doesn't support tags.



Discussion:

Resolving patch:
diff --git a/molecule/commands.py b/molecule/commands.py
--- a/molecule/commands.py
+++ b/molecule/commands.py
@@ -190,7 +190,22 @@ def execute(self, idempotent=False, create_instances=True, create_inventory=True
             create_inventory = False
 
         if create_instances and not idempotent:
-            c = Create(self.command_args, self.args, self.molecule)
+            # remove args Create doesn't support
+            command_args = []
+            skip_next = False
+            for item in self.command_args:
+                if skip_next:
+                    skip_next = False
+                    continue
+                if item.lower() == '--tags':
+                    skip_next = True
+                    continue
+                command_args.append(item)
+
+            args = dict(self.args)
+            del (args['--tags'])
+
+            c = Create(command_args, args, self.molecule)
             c.execute()
 
         if create_inventory:


Test patch:
Repository: ansible/molecule

Issue:
Verbose in molecule.yml should handle bool True
https://github.com/metacloud/molecule/blob/master/molecule/ansible_playbook.py#L104

```
clearly string +bool isn't gonna work. And it will have error like
Traceback (most recent call last):
File "/Users/zochao/.virtualenvs/metamole/bin/molecule", line 10, in <module>
sys.exit(main())
File "/Users/zochao/metamole/molecule/molecule/cli.py", line 66, in main
CLI().main()
File "/Users/zochao/metamole/molecule/molecule/cli.py", line 62, in main
sys.exit(c.execute())
File "/Users/zochao/metamole/molecule/molecule/commands.py", line 393, in execute
c.execute()
File "/Users/zochao/metamole/molecule/molecule/commands.py", line 224, in execute
ansible = AnsiblePlaybook(self.molecule._config.config['ansible'])
File "/Users/zochao/metamole/molecule/molecule/ansible_playbook.py", line 51, in _init_
self.parse_arg(k, v)
File "/Users/zochao/metamole/molecule/molecule/ansible_playbook.py", line 104, in parse_arg
self.cli_pos.append('-' + value)
TypeError: cannot concatenate 'str' and 'bool' objects
```



Discussion:
https://github.com/metacloud/molecule/pull/133

<img width="737" alt="screen shot 2016-03-08 at 3 43 54 pm" src="https://cloud.githubusercontent.com/assets/5855384/13620444/9e2f6c32-e544-11e5-91bc-4ea2da2e2262.png">

The documentation incorrectly references this.  It should be v - vvvv.  However I think we should also accept True and make it 'vvvv.'

``` python
# verbose is weird, must be -vvvv not verbose=vvvv
if name == 'verbose' and value:
    if value is True:
        value = 'vvvv'
    self.cli_pos.append('-' + value)
```


Resolving patch:
diff --git a/molecule/ansible_playbook.py b/molecule/ansible_playbook.py
--- a/molecule/ansible_playbook.py
+++ b/molecule/ansible_playbook.py
@@ -101,6 +101,9 @@ def parse_arg(self, name, value):
 
         # verbose is weird, must be -vvvv not verbose=vvvv
         if name == 'verbose' and value:
+            # for cases where someone passes in verbose: True
+            if value is True:
+                value = 'vvvv'
             self.cli_pos.append('-' + value)
             return
 


Test patch:
Repository: ansible/molecule

Issue:
Logger adding extra lines, prefixing them with -->
logger.warning now appends --> to every line. This causes the output of things like ansible-playbook to have normally blank lines prefixed with -->, causing a lot of extra noise during a converge.  The _out for the sh calls to various programs doesn't need anything appended to it. @kireledan 

<img width="986" alt="screen shot 2016-06-28 at 1 41 48 pm" src="https://cloud.githubusercontent.com/assets/5855384/16429848/1adebbcc-3d36-11e6-832b-4911c8db26dd.png">



Discussion:
I had it in there just for looks. I can take it out and make it only for molecule warnings. 

Yes, I've encountered this building from the latest master. @kireledan It's not so much the `-->` that bothers me, it's the blank lines. Without looking at the code, it seems that there's an extra newline appended to output lines that isn't necessary.

I'll make a PR with something not as noisy. 

@kireledan sounds good!


Resolving patch:
diff --git a/molecule/utilities.py b/molecule/utilities.py
--- a/molecule/utilities.py
+++ b/molecule/utilities.py
@@ -38,19 +38,21 @@ def filter(self, logRecord):
         return logRecord.levelno <= self.__level
 
 
+class TrailingNewlineFormatter(logging.Formatter):
+    def format(self, record):
+        record.msg = record.msg.rstrip()
+        return super(TrailingNewlineFormatter, self).format(record)
+
+
 logger = logging.getLogger(__name__)
 warn = logging.StreamHandler()
 warn.setLevel(logging.WARN)
 warn.addFilter(LogFilter(logging.WARN))
-warn.setFormatter(logging.Formatter('{}{} --> {}{} %(message)s'.format(
-    colorama.Style.BRIGHT, colorama.Fore.BLUE, colorama.Fore.RESET,
-    colorama.Style.RESET_ALL)))
+warn.setFormatter(TrailingNewlineFormatter('%(message)s'))
 
 error = logging.StreamHandler()
 error.setLevel(logging.ERROR)
-error.setFormatter(logging.Formatter('{}{} --> {}{} %(message)s'.format(
-    colorama.Style.BRIGHT, colorama.Fore.RED, colorama.Fore.RESET,
-    colorama.Style.RESET_ALL)))
+error.setFormatter(TrailingNewlineFormatter('%(message)s'))
 logger.addHandler(error)
 logger.addHandler(warn)
 


Test patch:
Repository: ansible/molecule

Issue:
No openstack floating ip support
# Issue Type

- Bug report

# Molecule and Ansible details

```
molecule, version 1.16.1
```

- Molecule installation method: pip

# Desired Behaviour

The openstack provider creates an openstack instance, associates a floating ip to it and connects to the instance using the floating ip.

# Actual Behaviour (Bug report only)

The openstack provider creates an openstack instance and tries to connects to the private ip which obviously doesn't work.


Discussion:
@alvaroaleman Please submit a PR for requested functionality.  The openstack driver is owned by the Molecule community.   Thanks!

Resolving patch:
diff --git a/molecule/driver/openstackdriver.py b/molecule/driver/openstackdriver.py
--- a/molecule/driver/openstackdriver.py
+++ b/molecule/driver/openstackdriver.py
@@ -50,6 +50,10 @@ def name(self):
     def instances(self):
         return self.molecule.config.config['openstack']['instances']
 
+    @property
+    def ip_pool(self):
+        return self.molecule.config.config['openstack'].get('ip_pool')
+
     @property
     def default_provider(self):
         return self._provider
@@ -120,6 +124,8 @@ def up(self, no_provision=True):
                     auto_ip=True,
                     wait=True,
                     key_name=kpn,
+                    ip_pool=instance.get('ip_pool')
+                    if instance.get('ip_pool') else self.ip_pool,
                     security_groups=instance['security_groups']
                     if 'security_groups' in instance else None)
                 self._reset_known_host_key(server['interface_ip'])


Test patch:
Repository: ansible/molecule

Issue:
Docs: Confusing advice on create vs converge playbooks
In the [docs for the Ansible provisioner](https://molecule.readthedocs.io/en/latest/configuration.html#id12) it says (emphasis mine):
> Reserve the create and destroy playbooks for provisioning. Do not attempt to gather facts or perform operations on the provisioned nodes inside these playbooks. Due to the gymnastics necessary to sync state between Ansible and Molecule, it is best to perform these tasks in the **converge** playbook.

Shouldn't it say
>... it is best to perform these tasks in the **prepare** playbook.

here instead? Or at least "prepare **or** converge playbooks"? See also #1351.

From what I understand, *converge* is meant for the actual execution of the role, isn't it? Of course, the cited paragraph makes sense if that's what "perform operations on the provisioned nodes" refers to, but then I don't think anyone would think to put this into *create*... confusion between *create* and *prepare*, on the other hand, seems more likely.


Discussion:
> ... it is best to perform these tasks in the **prepare** playbook.

It can be done in either.  Create or prepare.  The documentation was likely written before prepare existed.  However, either one is fine.
@retr0h Thanks for clearing that up! So I guess the documentation could be changed to recommend *prepare* here instead of *converge*? I agree that it sounds like it was written before *prepare* existed.
Yeah, you mind submitting a fix?

Resolving patch:
diff --git a/molecule/provisioner/ansible.py b/molecule/provisioner/ansible.py
--- a/molecule/provisioner/ansible.py
+++ b/molecule/provisioner/ansible.py
@@ -50,7 +50,7 @@ class Ansible(base.Base):
         attempt to gather facts or perform operations on the provisioned nodes
         inside these playbooks.  Due to the gymnastics necessary to sync state
         between Ansible and Molecule, it is best to perform these tasks in the
-        converge playbook.
+        prepare or converge playbooks.
 
         It is the developers responsiblity to properly map the modules's fact
         data into the instance_conf_dict fact in the create playbook.  This


Test patch:
Repository: ansible/molecule

Issue:
Docker provisioner enforces all uppercase env vars
# Issue Type

- Bug report


# Molecule and Ansible details


ansible --version
```
ansible 2.5.8 (stable-2.5 6321e70232) last updated 2018/09/04 11:40:53 (GMT +200)
  config file = None
  configured module search path = [u'...']
  ansible python module location = ...
  executable location = ...
  python version = 2.7.15 (default, Aug  9 2018, 09:11:52) [GCC 7.3.0]

```
molecule --version
```
molecule, version 2.17.0
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- source


# Desired Behavior

Upper or lower case for environment variables injected into the docker container should not matter.
Especially since i.e. systemd explicitly wants a lower case $container variable. Or think of $http_proxy.
(see https://www.freedesktop.org/wiki/Software/systemd/ContainerInterface under Environment Variables)

# Actual Behaviour (Bug report only)

```
dependency:
  name: gilt
driver:
  name: docker
lint:
  name: yamllint
platforms:
  - name: host.name
    hostname: host.name
    image: centos:latest
    command: /sbin/init
    env:
      container: docker
    security_opts:
      - apparmor=unconfined
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    capabilities:
      - SYS_ADMIN
      - SYSLOG
      - NET_ADMIN
provisioner:
  name: ansible
  config_options:
    defaults:
      jinja2_extensions: jinja2.ext.do
  lint:
    name: ansible-lint
scenario:
  name: default
verifier:
  name: testinfra
  lint:
    name: flake8
 

$ molecule --debug lint                                                                                                                                                                                                                        
--> Validating schema .../molecule/default/molecule.yml.
ERROR: Failed to validate.

{'platforms': [{0: [{'env': [{'container': ["value does not match regex '^[A-Z0-9_-]+$'"]}]}]}]}
```



Discussion:
Sounds reasonable, mind submitting a PR to correct this?

Resolving patch:
diff --git a/molecule/model/schema_v2.py b/molecule/model/schema_v2.py
--- a/molecule/model/schema_v2.py
+++ b/molecule/model/schema_v2.py
@@ -694,7 +694,7 @@ def pre_validate_base_schema(env, keep_string):
                     'type': 'dict',
                     'keyschema': {
                         'type': 'string',
-                        'regex': '^[A-Z0-9_-]+$',
+                        'regex': '^[a-zA-Z0-9_-]+$',
                     }
                 },
                 'restart_policy': {


Test patch:
diff --git a/test/unit/model/v2/test_platforms_section.py b/test/unit/model/v2/test_platforms_section.py
--- a/test/unit/model/v2/test_platforms_section.py
+++ b/test/unit/model/v2/test_platforms_section.py
@@ -81,6 +81,7 @@ def _model_platforms_docker_section_data():
             ],
             'env': {
                 'FOO': 'bar',
+                'foo': 'bar',
             },
             'restart_policy':
             'on-failure',
Repository: ansible/molecule

Issue:
CMD in pre-built docker image replaced with `while true; do sleep 10000; done`
# Issue Type

- Bug report

Was kind of reported in #1441 
# Molecule and Ansible details

```
ansible 2.7.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/fabian/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/fabian/.local/lib/python2.7/site-packages/ansible
  executable location = /home/fabian/.local/bin/ansible
  python version = 2.7.15 (default, May 15 2018, 15:37:31) [GCC 7.3.1 20180303 (Red Hat 7.3.1-5)]
molecule, version 2.19.1.dev54

```

Molecule installation method (one of):

- source

Ansible installation method (one of):

- pip

# Desired Behavior
If I don't specify a `command` or specify `null` as the value for `command`, the existing `CMD` on the image should be used.


# Actual Behaviour
When consuming an image with the docker driver, the existing `CMD` on the image is overwritten, even if `command` is unspecified or null. 

In order to get the behavior I desire from molecule, I currently need to copy-paste the content  of the `CMD` directive into the `command` section of the `molecule.yml`, but this is inherently fragile as every time the container used changes its `CMD` I would need to reflect that in every related molecule specification.


Discussion:

Resolving patch:
diff --git a/molecule/model/schema_v2.py b/molecule/model/schema_v2.py
--- a/molecule/model/schema_v2.py
+++ b/molecule/model/schema_v2.py
@@ -638,6 +638,7 @@ def pre_validate_base_schema(env, keep_string):
                 },
                 'command': {
                     'type': 'string',
+                    'nullable': True,
                 },
                 'privileged': {
                     'type': 'boolean',


Test patch:
diff --git a/test/resources/playbooks/docker/Dockerfile.j2 b/test/resources/playbooks/docker/Dockerfile.j2
--- a/test/resources/playbooks/docker/Dockerfile.j2
+++ b/test/resources/playbooks/docker/Dockerfile.j2
@@ -12,3 +12,5 @@ RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y pyth
     elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
     elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
     elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
+
+CMD ["sh", "-c", "while true; do sleep 10000; done"]
Repository: ansible/molecule

Issue:
ValueError: invalid literal for int() with base 10: 'post20190705'
It seems that code from setup.py is broken as it makes the wrong assumption that `setuptools.__version__.` will always return only integers:

https://github.com/ansible/molecule/blob/master/setup.py#L36

```
        RUNTIME_SETUPTOOLS_VERSION = tuple(map(int, setuptools.__version__.split('.')))
    ValueError: invalid literal for int() with base 10: 'post20190705'
```

As seen here the minor version can be a non numeric value. The quick workaround is to only look at the fist two elements.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -33,10 +33,11 @@
 
 
 ALL_STRING_TYPES = tuple(map(type, ('', b'', u'')))
-MIN_NATIVE_SETUPTOOLS_VERSION = 34, 4, 0
+MIN_NATIVE_SETUPTOOLS_VERSION = 34, 4
 """Minimal setuptools having good read_configuration implementation."""
 
-RUNTIME_SETUPTOOLS_VERSION = tuple(map(int, setuptools.__version__.split('.')))
+# Patch version can be a non integer value, like 'post20190705'
+RUNTIME_SETUPTOOLS_VERSION = tuple(map(int, setuptools.__version__.split('.')[:2]))
 """Setuptools imported now."""
 
 READ_CONFIG_SHIM_NEEDED = RUNTIME_SETUPTOOLS_VERSION < MIN_NATIVE_SETUPTOOLS_VERSION


Test patch:
Repository: ansible/molecule

Issue:
"devices" support in docker driver
# Issue Type

- Feature request

# Molecule and Ansible details

```
$ ansible --version && molecule --version
ansible 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sylvain/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/sylvain/venv/molecule/lib/python3.6/site-packages/ansible
  executable location = /home/sylvain/venv/molecule/bin/ansible
  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]
molecule, version 2.22
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- pip

# Desired Behavior

The docker driver does not support the `devices` option available in the `docker_container` ansible module, so we can't test roles that are using fuse for example, except by using `privileged` option which is quite dangerous. Can you please support for this option?

"devices" support in docker driver
# Issue Type

- Feature request

# Molecule and Ansible details

```
$ ansible --version && molecule --version
ansible 2.8.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/sylvain/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/sylvain/venv/molecule/lib/python3.6/site-packages/ansible
  executable location = /home/sylvain/venv/molecule/bin/ansible
  python version = 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0]
molecule, version 2.22
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- pip

# Desired Behavior

The docker driver does not support the `devices` option available in the `docker_container` ansible module, so we can't test roles that are using fuse for example, except by using `privileged` option which is quite dangerous. Can you please support for this option?



Discussion:

Resolving patch:
diff --git a/molecule/driver/docker.py b/molecule/driver/docker.py
--- a/molecule/driver/docker.py
+++ b/molecule/driver/docker.py
@@ -67,6 +67,8 @@ class Docker(Driver):
             privileged: True|False
             security_opts:
               - seccomp=unconfined
+            devices:
+              - /dev/fuse:/dev/fuse:rwm
             volumes:
               - /sys/fs/cgroup:/sys/fs/cgroup:ro
             keep_volumes: True|False


Test patch:
Repository: ansible/molecule

Issue:
Add a config option to run podman as root
# Issue Type

- Feature request

# Molecule and Ansible details

```
ansible 2.9.9
molecule 3.0.4
```

Molecule installation method (one of):

- pip

Ansible installation method (one of):

- OS package

# Desired Behavior

Podman allows running containers in a rootless mode, although this introduces some limitations.
For example this makes it difficult to test ansible roles which rely on a working systemd instance running in the container.

It would therefore be nice if it would be possible to specify whether podman should be executed as root or as the current user in the molecule config.


Discussion:

Resolving patch:
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
@@ -358,6 +358,7 @@ def pre_validate_base_schema(env, keep_string):
                 "cgroup_manager": {"type": "string"},
                 "storage_opt": {"type": "string"},
                 "storage_driver": {"type": "string"},
+                "rootless": {"type": "boolean"},
             },
         },
     }


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
@@ -3,6 +3,7 @@
   hosts: localhost
   connection: local
   gather_facts: false
+  become: "{{ not (item.rootless|default(true)) }}"
   tasks:
     - name: Log into a container registry
       command: >
diff --git a/molecule/test/resources/playbooks/podman/destroy.yml b/molecule/test/resources/playbooks/podman/destroy.yml
--- a/molecule/test/resources/playbooks/podman/destroy.yml
+++ b/molecule/test/resources/playbooks/podman/destroy.yml
@@ -4,6 +4,7 @@
   connection: local
   gather_facts: false
   no_log: "{{ molecule_no_log }}"
+  become: "{{ not (item.rootless|default(true)) }}"
   tasks:
     - name: Destroy molecule instance(s)
       shell: podman container exists {{ item.name }} && podman rm -f {{ item.name }} || true