dmsimard / ansible-inventory-puppetdb Goto Github PK
View Code? Open in Web Editor NEWLeverage Puppet facts and PuppetDB to generate a dynamic Ansible inventory
License: Apache License 2.0
Leverage Puppet facts and PuppetDB to generate a dynamic Ansible inventory
License: Apache License 2.0
[root@puppetmaster ansible-inventory-puppetdb]# pip freeze | grep -i pypuppetdb
You are using pip version 8.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pypuppetdb==0.1.1
>>> from pypuppetdb import connect
>>> db = connect()
>>> nodes = db.nodes()
>>> for node in nodes:
... print(node)
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/pypuppetdb/api/v3.py", line 55, in nodes
nodes = self._query('nodes', path=name, query=query)
File "/usr/lib/python2.7/site-packages/pypuppetdb/api/__init__.py", line 267, in _query
r.raise_for_status()
File "/usr/lib/python2.7/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8080/v3/nodes
>>>
>>> exit()
[root@puppetmaster ansible-inventory-puppetdb]# pip install pypuppetdb==0.2.3
< long out put skipped >
Successfully installed pypuppetdb-0.2.3
You are using pip version 8.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@puppetmaster ansible-inventory-puppetdb]# python
Python 2.7.5 (default, Jun 24 2015, 00:41:19)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pypuppetdb import connect
>>> db = connect()
>>> nodes = db.nodes()
>>> for node in nodes:
... print(node)
...
puppetmaster
host1
host2
host3
<and so on>
and hence the with pypuppetdb
version 0.1.1
gives this error
[root@puppetmaster ansible-inventory-puppetdb]# ./puppetdb.py --list
Traceback (most recent call last):
File "./puppetdb.py", line 230, in <module>
main()
File "./puppetdb.py", line 224, in main
print(inventory.get_host_list())
File "./puppetdb.py", line 115, in get_host_list
groups = self.fetch_host_list()
File "./puppetdb.py", line 168, in fetch_host_list
for node in self.puppetdb.nodes():
File "/usr/lib/python2.7/site-packages/pypuppetdb/api/v3.py", line 55, in nodes
nodes = self._query('nodes', path=name, query=query)
File "/usr/lib/python2.7/site-packages/pypuppetdb/api/__init__.py", line 267, in _query
r.raise_for_status()
File "/usr/lib/python2.7/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://localhost:8080/v3/nodes
but with version 0.2.3, works just fine
[root@puppetmaster ansible-inventory-puppetdb]# ./puppetdb.py --list | jq '.all.hosts | length'
27
Thanks for your work on this and I'm hoping I can get it working. I updated puppetdb.yml with my info:
host: 10.2.0.10
api_version: 3
port: 8081
timeout: 10
ssl_verify: False
ssl_key:
ssl_cert:
cache_file: '/tmp/ansible-inventory-puppetdb.cache'
cache_duration: 30
group_by:
group_by_tag:
but when I run ./puppetdb.py --list
I get:
Traceback (most recent call last): File "./puppetdb.py", line 234, in <module> main() File "./puppetdb.py", line 226, in main inventory = PuppetdbInventory(args.refresh) File "./puppetdb.py", line 86, in __init__ self.puppetdb = connect(**puppetdb_config) TypeError: connect() got an unexpected keyword argument 'api_version'
Any ideas?
Do you still have plans to maintain this repository? There are 2 year old pull requests which need to be merged to enable connectivity with recent versions of puppetdb.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.