@@ -0,0 +1,1323 @@
+#!/usr/bin/env python%0A%0A# (c) 2013, Michael Scherer %3Cmisc@zarb.org%3E%0A#%0A# This file is part of Ansible,%0A#%0A# Ansible is free software: you can redistribute it and/or modify%0A# it under the terms of the GNU General Public License as published by%0A# the Free Software Foundation, either version 3 of the License, or%0A# (at your option) any later version.%0A#%0A# Ansible is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A# GNU General Public License for more details.%0A#%0A# You should have received a copy of the GNU General Public License%0A# along with Ansible.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0Afrom subprocess import Popen,PIPE%0Aimport sys%0Aimport json%0A%0Aresult = %7B%7D%0Aresult%5B'all'%5D = %7B%7D%0A%0Apipe = Popen(%5B'virsh', '-q', '-c', 'lxc:///', 'list', '--name', '--all'%5D, stdout=PIPE, universal_newlines=True)%0Aresult%5B'all'%5D%5B'hosts'%5D = %5Bx%5B:-1%5D for x in pipe.stdout.readlines()%5D%0Aresult%5B'all'%5D%5B'vars'%5D = %7B%7D%0Aresult%5B'all'%5D%5B'vars'%5D%5B'ansible_connection'%5D = 'lxc'%0A%0Aif len(sys.argv) == 2 and sys.argv%5B1%5D == '--list':%0A    print json.dumps(result)%0Aelif len(sys.argv) == 3 and sys.argv%5B1%5D == '--host':%0A    print json.dumps(%7B'ansible_connection': 'lxc'%7D)%0Aelse:%0A    print %22Need a argument, either --list or --host %3Chost%3E%22%0A

add a inventory script that go with the lxc connexion module