Repository: ansible/molecule

Issue:
Ansible inventory doesn't created during converge
Hi, it has been broken with 1.1.1.

```
$ molecule --version
1.1.1
$ molecule create
Bringing machine 'ansible-role-php-01' up with 'virtualbox' provider...
==> ansible-role-php-01: Importing base box 'bento/centos-6.7'...
==> ansible-role-php-01: Matching MAC address for NAT networking...
==> ansible-role-php-01: Checking if box 'bento/centos-6.7' is up to date...
==> ansible-role-php-01: Setting the name of the VM: ansible-role-php_ansible-role-php-01_1450454874140_66041
==> ansible-role-php-01: Fixed port collision for 22 => 2222. Now on port 2202.
==> ansible-role-php-01: Clearing any previously set network interfaces...
==> ansible-role-php-01: Preparing network interfaces based on configuration...
    ansible-role-php-01: Adapter 1: nat
    ansible-role-php-01: Adapter 2: hostonly
==> ansible-role-php-01: Forwarding ports...
    ansible-role-php-01: 22 => 2202 (adapter 1)
==> ansible-role-php-01: Running 'pre-boot' VM customizations...
==> ansible-role-php-01: Booting VM...
==> ansible-role-php-01: Waiting for machine to boot. This may take a few minutes...
    ansible-role-php-01: SSH address: 127.0.0.1:2202
    ansible-role-php-01: SSH username: vagrant
    ansible-role-php-01: SSH auth method: private key
    ansible-role-php-01: Warning: Connection timeout. Retrying...
    ansible-role-php-01: Warning: Remote connection disconnect. Retrying...
==> ansible-role-php-01: Machine booted and ready!
==> ansible-role-php-01: Checking for guest additions in VM...
==> ansible-role-php-01: Setting hostname...
==> ansible-role-php-01: Configuring and enabling network interfaces...
==> ansible-role-php-01: Mounting shared folders...
    ansible-role-php-01: /vagrant => /Users/bbo/src/gitlab.com/owox-ops-team/ansible-role-php
==> ansible-role-php-01: Machine not provisioned because `--no-provision` is specified.
$ molecule converge
ERROR: Unable to find an inventory file, specify one with -i ?
ERROR:

  RAN: '/Users/bbo/.local/bin/ansible-playbook playbook.yml --inventory-file=.molecule/ansible_inventory --sudo --connection=ssh --limit=all --user=vagrant --timeout=30 --diff'

  STDOUT:


  STDERR:
```

I suppose due to:

https://github.com/metacloud/molecule/blob/46a6e28/molecule/commands.py#L143



Discussion:
Ah, I see the issue. Create writes the state file showing the machines are running, but since it doesn't call  converge, the inventory file doesn't get created.  I'll get a fix out for this shortly.

In the meantime, if you create your machines on the first run by using `converge` instead of `create` it will work as expected.


Resolving patch:
diff --git a/molecule/commands.py b/molecule/commands.py
--- a/molecule/commands.py
+++ b/molecule/commands.py
@@ -140,6 +140,8 @@ def converge(self, idempotent=False, create_instances=True, create_inventory=Tru
 
         if self.molecule._state.get('created'):
             create_instances = False
+
+        if self.molecule._state.get('converged'):
             create_inventory = False
 
         if create_instances and not idempotent:
@@ -164,7 +166,13 @@ def converge(self, idempotent=False, create_instances=True, create_inventory=Tru
                 utilities.debug('OTHER ENVIRONMENT', yaml.dump(other_env, default_flow_style=False, indent=2))
                 utilities.debug('ANSIBLE ENVIRONMENT', yaml.dump(ansible_env, default_flow_style=False, indent=2))
                 utilities.debug('ANSIBLE PLAYBOOK', str(ansible))
+
             output = ansible()
+
+            if not self.molecule._state.get('converged'):
+                self.molecule._state['converged'] = True
+                self.molecule._write_state_file()
+
             return output
         except sh.ErrorReturnCode as e:
             print('ERROR: {}'.format(e))


Test patch: