ansible/contrib/inventory
Tom Melendez 54caf3c5d5 [GCE] Caching support for inventory script. (#18093)
* [GCE] Caching support for inventory script.

The GCE inventory script now supports reading from a cache rather than making the request each time.  The format of the list and host output have not changed.

On script execution, the cache is checked to see if it older than 'cache_max_age', and if so, it is rebuilt (it can also be explicity rebuilt).

To support this functionality, the following have been added.

* Config file (gce.ini) changes: A new 'cache' section has been added to the config file, with 'cache_path' and 'cache_max_age' options to allow for configuration.  There are intelligent defaults in place if that section and options are not found in the configuration file.

* Command line argument: A new --refresh-cache argument has been added to force the cache to be rebuild.

* A CloudInventoryCache class, contained in the same file has been added.  As a seperate class, it allowed for testing (unit tests not included in this PR) and hopefully could be re-used in the future (it contains borrowed code from other inventory scripts)

* load_inventory_from_cache and do_api_calls_and_update_cache methods (, which were largely lifted from other inventory scripts, in a hope to promote consistency in the future) to determine if the cache is fresh and rebuild if necessary.

* A 'main' check, to support the script being imported and testable.

A new dictionary has been added to the list output, located at ['_meta']['stats'] that informs if the cache was used and how long it took to load the inventory (in 'cache_used' and 'inventory_load_time', respectively).

* fixed default value error; change cache time to 300
2016-10-24 16:32:50 -04:00
..
abiquo.ini Fix some typos (#16498) 2016-06-29 14:31:25 -04:00
abiquo.py Fix urlopen usage to use open_url instead 2015-09-16 20:40:17 -07:00
apache-libcloud.py Replace type() checks with isinstance() 2015-09-04 09:47:17 +03:00
azure_rm.ini Upgrade to azure 2.0.0rc5 and add locations parameter. 2016-07-09 01:42:39 -04:00
azure_rm.py Use addresses and names reserved for documentation 2016-09-11 17:31:41 +02:00
brook.ini Brook inventory (#15264) 2016-04-25 11:42:57 -04:00
brook.py errors now print to stderr 2016-04-25 11:43:54 -04:00
cloudforms.ini add cloudforms inventory script (#17037) 2016-08-18 14:37:31 -07:00
cloudforms.py py3 print fix 2016-08-18 14:37:52 -07:00
cloudstack.ini poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
cloudstack.py cloudstack: add domain, group per zone to dynamic inventory (#17792) 2016-10-24 18:53:34 +02:00
cobbler.ini add cobbler api authentication options 2016-04-18 17:29:03 -04:00
cobbler.py add cobbler api authentication options 2016-04-18 17:29:03 -04:00
collins.ini poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
collins.py Fix urlopen usage to use open_url instead 2015-09-16 20:40:17 -07:00
consul.ini poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
consul_io.py Use sys.exit(msg) i/o print() and sys.exit() (#15465) 2016-08-23 11:09:23 -04:00
digital_ocean.ini [contrib] Add option to define group vars in DigitalOcean dynamic inventory script 2016-02-14 17:04:26 +01:00
digital_ocean.py Correctly read use_private_network as boolean 2016-10-23 13:16:29 +02:00
docker.py Update and fix typos in docker inventory docstrings. (#15616) 2016-04-27 17:17:34 -04:00
docker.yml Update and fix typos in docker inventory docstrings. (#15616) 2016-04-27 17:17:34 -04:00
ec2.ini Paginate DB cluster responses in AWS RDS dynamic inventory 2016-08-15 14:27:48 -04:00
ec2.py Changes as per @abadger 2016-09-14 15:11:57 +01:00
fleet.py Use print() as function under contrib/ 2015-08-28 09:18:13 +03:00
freeipa.py Use print() as function under contrib/ 2015-08-28 09:18:13 +03:00
gce.ini [GCE] Caching support for inventory script. (#18093) 2016-10-24 16:32:50 -04:00
gce.py [GCE] Caching support for inventory script. (#18093) 2016-10-24 16:32:50 -04:00
jail.py Use sys.exit(msg) i/o print() and sys.exit() (#15465) 2016-08-23 11:09:23 -04:00
landscape.py poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
libcloud.ini poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
libvirt_lxc.py Use sys.exit(msg) i/o print() and sys.exit() (#15465) 2016-08-23 11:09:23 -04:00
linode.ini Add public_ip option to linode dynamic inventory (#17390) 2016-09-09 09:14:27 -04:00
linode.py Add public_ip option to linode dynamic inventory (#17390) 2016-09-09 09:14:27 -04:00
lxc_inventory.py Add inventory script for LXC containers 2016-06-03 23:22:56 +03:00
nagios_ndo.ini Add Nagios NDO inventory plugin 2015-09-01 17:10:37 +02:00
nagios_ndo.py Add Nagios NDO inventory plugin 2015-09-01 17:10:37 +02:00
nova.ini poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
nova.py Use sys.exit(msg) i/o print() and sys.exit() (#15465) 2016-08-23 11:09:23 -04:00
nsot.py Migrate basestring to a python3 compatible type (#17199) 2016-08-23 13:13:44 -07:00
nsot.yaml Added NSoT Inventory script to pull from Device resources 2015-09-15 00:53:34 -07:00
openshift.py Use sys.exit(msg) i/o print() and sys.exit() (#15465) 2016-08-23 11:09:23 -04:00
openstack.py Strip group names of whitespaces, so we can use space after comma in openstack's groups metadata field. (#16843) 2016-08-04 09:45:15 -07:00
openstack.yml Allow fail_on_errors in openstack inventory 2016-04-05 20:31:54 +10:00
openvz.py Fixing typo 2015-10-26 17:13:00 -04:00
ovirt.ini poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
ovirt.py Fix improper handling of machine_type in ovirt inventory (#16251) 2016-10-23 02:14:09 +02:00
proxmox.py If the notes don't contain JSON, add the string to the notes key of _meta 2016-01-24 01:10:47 -08:00
rackhd.py Bug Fix 2016-03-14 16:40:39 -04:00
rax.ini Add rax cache age ini documentation 2016-01-20 15:27:06 -05:00
rax.py Use sys.exit(msg) i/o print() and sys.exit() (#15465) 2016-08-23 11:09:23 -04:00
rudder.ini Add Rudder inventory plugin 2015-08-28 10:25:18 +02:00
rudder.py made python 3 compatible 2015-11-13 21:57:28 -08:00
serf.py poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
softlayer.py Use print() as function under contrib/ 2015-08-28 09:18:13 +03:00
spacewalk.ini Added support for ini-file. 2015-07-31 14:18:59 +02:00
spacewalk.py Fix CACHE_DIR mode in contrib/inventory/spacewalk.py 2016-04-01 20:35:19 -04:00
ssh_config.py Use print() as function under contrib/ 2015-08-28 09:18:13 +03:00
vagrant.py Use print() as function under contrib/ 2015-08-28 09:18:13 +03:00
vbox.py Output proper JSON from vbox dynamic inventory contrib script 2015-09-26 18:25:58 +02:00
vmware.ini vmware inventory script enhancements (#17106) 2016-08-17 17:44:15 -04:00
vmware.py Migrate basestring to a python3 compatible type (#17199) 2016-08-23 13:13:44 -07:00
vmware_inventory.ini vmware_inventory: fix the --host and add 'properties' feature to ini (#18072) 2016-10-18 16:21:37 -04:00
vmware_inventory.py vmware_inventory: fix the --host and add 'properties' feature to ini (#18072) 2016-10-18 16:21:37 -04:00
windows_azure.ini Updates to Windows Azure inventory script from Tower. Includes changes from https://github.com/ansible/ansible/pull/8403. 2015-08-10 17:35:47 -04:00
windows_azure.py Allow to work with latest Azure Python SDK (#15467) 2016-04-21 23:18:45 -04:00
zabbix.ini poreted log_plays, syslog_json and osx_say callbacks to v2 2015-07-10 10:30:33 -04:00
zabbix.py Added additional ini file search path into contrib/inventory/zabbix.py 2015-10-08 11:44:27 +03:00
zone.py Use sys.exit(msg) i/o print() and sys.exit() (#15465) 2016-08-23 11:09:23 -04:00