Satisfies the ``--list`` portion of ansible's external inventory API.

        Allows ``bang`` to be used as an external inventory script, for example
        when running ad-hoc ops tasks.  For more details, see:
        http://ansible.cc/docs/api.html#external-inventory-scripts

def show_inventory(self, pretty=False):
        """
        Satisfies the ``--list`` portion of ansible's external inventory API.

        Allows ``bang`` to be used as an external inventory script, for example
        when running ad-hoc ops tasks.  For more details, see:
        http://ansible.cc/docs/api.html#external-inventory-scripts

        """
        inv_lists = copy.deepcopy(self.groups_and_vars.lists)
        # sort the host lists to help consumers of the inventory (e.g. ansible
        # playbooks)
        for l in inv_lists.values():
            l.sort()

        # new in ansible 1.3: add hostvars directly into ``--list`` output
        inv_lists['_meta'] = {
                'hostvars': self.groups_and_vars.dicts.copy()
                }

        if pretty:
            kwargs = {
                    'sort_keys': True,
                    'indent': 2,
                    'separators': (',', ': '),
                    }
        else:
            kwargs = {}
        print json.dumps(inv_lists, **kwargs)