Commit graph

421 commits

Author SHA1 Message Date
Alvaro Aleman
fe5e1a4bc4 OS dynamic inventory: respect OS_CLOUD env var 2017-08-10 12:43:16 -07:00
Do Hoang Khiem
3b12a85750 Add node private & public ips to gce groups (#12539) 2017-08-09 12:45:00 -06:00
Sebastian Cruz
223f94ec56 Fix missing option in #27848 (#27892) 2017-08-09 08:41:12 -04:00
Sebastian Cruz
ce5e4dfc38 Add option to group ec2 instances by platform. (#27848)
All credits to https://github.com/felipecvo

See PR: https://github.com/ansible/ansible/pull/14246
2017-08-07 12:45:04 -06:00
Eric L
1fe14da226 Add possibility to interpret global parameters value as JSON with rich_params flag (#26180) 2017-08-07 12:41:41 -06:00
Adam Johnson
3f85aa3abd Use a real list comprehension rather than list() around a generator (#25594)
It's faster and more idiomatic.
2017-08-07 12:30:01 -06:00
Tian You
9364fa202f [cloud] Group RDS instances by tag keys in ec2 dynamic inventory (#24763) 2017-08-04 14:38:04 -04:00
jctanner
3b20585ada Fix 23417 (#27770)
* Expose user_metadat to ansible

* Fixed exception when no userData
2017-08-04 13:28:40 -04:00
Will Weber
bfbdb3f3f0 assumption made that dopy only dep in dopy (#27536) 2017-08-03 13:44:07 -07:00
Nick Ball
edf31f56af Linode inventory improvements: Add _meta/hostvars to inventory output. Add a 'linode' host group with all the hosts (#19329) 2017-08-02 13:26:30 -04:00
Toshio Kuratomi
225fa5d092 Fix undefined variables, basestring usage, and some associated python3 issues 2017-07-25 15:58:23 -07:00
Brian Coca
8f8e53acbe updated readme with vault and 2.4 inv plugins (#26361)
* updated readme with vault and 2.4 inv plugins

* fixed as per feedback

* Edits

Need clarification for lines 10 and 11.
2017-07-24 16:37:59 -04:00
Toshio Kuratomi
edccfd5908 Fix undefined variable in libcloud dyn inv script
References #27193
2017-07-23 12:01:57 -07:00
Greg Dahlman
1d8854b045 Python 3 fix for consul_io inventory (#26510)
* Python 3 fix for consul_io inventory

* Remove configparser CamelCase try statement

* revert to python2.6 compatible try;except

* Fix pip8 error E302
2017-07-20 10:35:17 -07:00
Tomáš Karásek
a5c41dcd49 Add grouping by hostname for the Packet inventory (#21069)
* Add grouping by hostname for the Packet inventory

* remove space after eol
2017-07-18 09:31:42 -04:00
Abhijeet Kasurde
f7c8e7bdab Update vmware_inventory (#26308)
Fix adds
* Exception handling
* Unit tests

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-07-18 07:20:23 -04:00
Josh Smift
290d84f904 Update ansible_ssh_host->ansible_host in ec2.py dynamic inventory (#17113) 2017-07-17 15:30:11 -04:00
Toshio Kuratomi
ff22528b07 Consolidate boolean/mk_boolean conversion functions into a single location
Consolidate the module_utils, constants, and config functions that
convert values into booleans into a single function in module_utils.

Port code to use the module_utils.validate.convert_bool.boolean function
isntead of mk_boolean.
2017-07-17 11:48:05 -07:00
Alejandro Bednarik
2420bca0b5 Add GPl License header to rackhd inventory file. (#24354) 2017-07-10 08:09:29 +01:00
Ryan S. Brown
7cee903118 [cluster] Name Consul dynamic inventory config consistently w/ the script 2017-07-05 11:24:21 -04:00
Brian Coca
365f3dc9d9 switched to elif 2017-07-05 11:02:47 -04:00
Lorin Hochstein
b17da1fae9 ec2.py: Better error messages for OptInRequired
Improve error messages for RDS and ElastiCache failures for code OptInRequired.
2017-07-05 11:02:10 -04:00
Matt Clay
2e85272cd5 PEP 8 fixes. 2017-06-28 09:41:03 -07:00
Ronny
955f8923e7 Update dynamic inventory zabbix.py (#19862)
Added _meta to improve the speed when using this dynamic inventory file
2017-06-28 11:48:27 -04:00
Toshio Kuratomi
e238ae999b Cyptography pr 20566 rebase (#25560)
Make pyca/cryptography the preferred backend for cryptographic needs (mainly vault) falling back to pycrypto

pyca/cryptography is already implicitly a dependency in many cases
through paramiko (2.0+) as well as the new openssl_publickey module,
which requires pyOpenSSL 16.0+. Additionally, pyca/cryptography is
an optional dep for better performance with vault already.

This commit leverages cryptography's padding, constant time comparisons,
and CBC/CTR modes to reduce the amount of code ansible needs to
maintain.

* Handle wrong password given for VaultAES format

* Do not display deprecation warning for cryptography on python-2.6

* Namespace all of the pycrypto imports and always import them

  Makes unittests better and the code less likely to get stupid mistakes
  (like using HMAC from cryptogrpahy when the one from pycrypto is needed)

* Add back in atfork since we need pycrypto to reinitialize its RNG just in case we're being used with old paramiko

* contrib/inventory/gce: Remove spurious require on pycrypto

(cherry picked from commit 9e16b9db275263b3ea8d1b124966fdebfc9ab271)

* Add cryptography to ec2_win_password module requirements
  * Fix python3 bug which would pass text strings to a function which
    requires byte strings.

* Attempt to add pycrypto version to setup deps

* Change hacking README for dual pycrypto/cryptography

* update dependencies for various CI scripts

* additional CI dockerfile/script updates

* add paramiko to the windows and sanity requirement set

  This is needed because ansible lists it as a requirement. Previously
  the missing dep wasn't enforced, but cryptography imports pkg_resources
  so you can't ignore a requirement any more

* Add integration test cases for old vault and for wrong passwords

* helper script for manual testing of pycrypto/cryptography

* Skip the pycrypto tests so that users without it installed can still run the unittests

* Run unittests for vault with both cryptography and pycrypto backend
2017-06-27 06:00:15 -07:00
loqutus
8edcef7a84 fix comment in inventory/digital_ocean.py (#25828) 2017-06-18 10:51:42 +02:00
Abhijeet Kasurde
b89cb95609 Fix spelling mistakes (comments only) (#25564)
Original Author : klemens <ka7@github.com>

Taking over previous PR as per
https://github.com/ansible/ansible/pull/23644#issuecomment-307334525

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-06-12 07:55:19 +01:00
Carsten Clasohm
cd31f4a102 foreman.py: create Ansible groups from Satellite 6 host collections (#25269)
* create Ansible groups from host collections

* fix paging logic in _get_json

* replace Satellite with Foreman

* improve comment for environment variables

* enable host collections by default

* use requests params instead of urllib.quote_plus

* disable host collections by default

* change organization filter

* clean up load_cache methods

* remove usage of function defaults

* replace environment variables with host_filters
2017-06-09 17:10:55 -07:00
James Elford
bc9dbf38b0 python 3 compatibility: import guard around ConfigParser
In python3 `ConfigParser` has become `configparser`. Added
an import guard that aliases it back to the old name.
2017-06-03 13:56:10 -07:00
Eric L
eb53f3c129 Fix inventory script for Foreman where group by pattern are not prope… (#25173)
* Fix inventory script for Foreman where group by pattern are not properly safe-guarded.

* Fix pep8 error about tab mixed with blanks.
2017-05-31 16:35:28 -04:00
Sloane Hertel
e67cdd448e [cloud] EC2 dynamic inventory default filename is documented as ec2.ini - fixes #24396 (#24515)
* the default filename is ec2.ini

(to override that use the env var EC2_INI_PATH)

* allow fallback to ec2.ini
2017-05-31 14:59:55 -04:00
Dag Wieers
758cfeb73e contrib: PEP8 compliancy (#24680)
- Make PEP8 compliant
2017-05-30 21:08:09 +01:00
Abhijeet Kasurde
3a82246d82 Misc typo fix in fleet inventory (#25174)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-05-30 13:31:35 -04:00
Michael
b65ebf3519 Fixed import of urlencode and pathname2url from urllib for python3 (#24424) 2017-05-19 12:22:16 -05:00
Jorge Quintás
d3c94e82a5 take into account if cache file exists when loading data from digitalocean even with --force-cache 2017-05-17 10:45:54 -04:00
Matt Martz
d3249e7875 pep8 fixes for contrib (#24344) 2017-05-09 16:38:08 -05:00
Elijah Lynn
c7ae6b9fd5 [cloud][inventory] Get tags for RDS instances. (#23989)
* Get tags for RDS instances.

Boto3 only at this time.

Relates to #11569, #14464.

* Add a check for boto3

* Fix HAS_BOTO3 error
2017-05-09 16:56:54 -04:00
Ondra Machacek
2c58ac1833 inventory: ovirt4: Add support for devices without IP (#24287) 2017-05-04 12:22:48 -07:00
Tom Melendez
9d5c399313 Added subnetwork parameter to inventory instance dictionary. (#23984) 2017-04-26 12:44:58 +01:00
Matt Clay
48eeab8a53 Fix errors reported by pylint. (#23282)
* Fix pylint misplaced-bare-raise errors.
* Fix pylint return-in-init error.
* Fix pylint bad-format-character error.
* Fix pylint too-many-format-args errors.
* Fix pylint too-few-format-args errors.
* Fix pylint truncated-format-string error.
2017-04-06 16:58:16 -07:00
Toshio Kuratomi
6bad4e57bd Migrate most uses of if type() to if isinstance()
Also convert those checks to use abcs instead of dict and list.

Make a sentinel class for strategies to report when they've reache the end
2017-04-04 08:17:20 -07:00
Wayne Witzel III
1a1e12cf46 fetch spacewalk.ini from the environment if set 2017-04-03 21:22:29 -07:00
Tim Rupp
2d8c5e6b8f [openstack] Adds the non-deprecated ansible_host var (#23153)
OpenStack dynamic inventory is still using the deprecated
ansible_ssh_host. This patch adds ansible_host until such
time as ansible_ssh_host is removed
2017-04-03 16:02:54 -04:00
rafstef
25019fe70c Fix vmware property filter (#23228)
Fixes errors on properties that do not exist.
2017-04-03 15:22:58 -04:00
Matt Martz
495a1340a6 Address lxd inventory pep8 error (#23021) 2017-03-27 20:12:17 -05:00
Francisco Ros
0fa797030e Brook inventory (#16122)
* Do not ask for templates in Brook inventory if they do not exist

* Add availability zone variable to Brook inventory

* Add provider id variable to Brook inventory

* Error output sent to stderr in Brook inventory
2017-03-27 14:54:33 -04:00
Andrew Clarke
73438de862 A basic lxd dynamic inventory script (#15848)
* A basic start on an lxd dynamic inventory script

The script is a fairly basic start on an lxd dynamic inventory script. Only tested on ubuntu 16.04 and currently only reports ipv4 container addresses. Improvements to come.

* Updated formatting, indenting and python3 support

Updated to work on python3

* Additional options read from the ini file

Added options for connection and group to the ini file and modified to use these.

Host returned is now the name by default. For non-lxd connection, the ansible_host var is populated with the ip address.

* Additional options for group and connection

* Minor change to re-run tests
2017-03-27 14:52:23 -04:00
Toshio Kuratomi
2fff690caa Update module_utils.six to latest (#22855)
* Update module_utils.six to latest

We've been held back on the version of six we could use on the module
side to 1.4.x because of python-2.4 compatibility.  Now that our minimum
is Python-2.6, we can update to the latest version of six in
module_utils and get rid of the second copy in lib/ansible/compat.
2017-03-23 13:35:05 -07:00
Steve Kuznetsov
6318229bc4 Only read EC2 regions_exclude list if necessary (#18720)
When specifying a literal whitelist of AWS EC2 regions in the dynamic
inventory configuration file, it should not be necessary to also include
a literal blacklist, especially as the blacklist is not honored in this
case anyway. By reading the literal blacklist only when necessary, it is
possible for a user to provide a more minimal EC2 configuration file.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
2017-03-22 09:31:58 -04:00
Rune T. Sorensen
6804d69557 [cloud][contrib] IAM role support for EC2 dynamic inventory (#15196)
* EC2 inventory can now connect using an IAM role

* Fix comment indentation

* Make sure that Ec2Inventory.iam_role is always defined

* Add missing import
2017-03-20 17:19:40 -04:00
jctanner
447bb2b150 Add a custom regex_match filter to the vmware_inventory script (#21488) 2017-03-17 21:25:00 -04:00
Markus Liljedahl
67dc8c146e Added support for specifying zone for gce dynamic inventory (#20938) 2017-03-16 08:28:30 -04:00
William Holroyd
4ca7726e75 Fix Elasticcache issue where ec2 script would fail on finding lack of primary endpoint address on Redis cluster (#20190) 2017-03-10 13:08:54 -05:00
Ondra Machacek
0433be33bd ovirt: dyn_inventory fix Python2 and Python3 compat (#22453) 2017-03-10 08:48:29 -05:00
Matt Davis
cbedc4a12a azure_rm inventory version comparison fix (#22341) 2017-03-06 15:44:42 -08:00
Damien
2376d891c7 [inventory/aos] Few fixes and small tweaks (#22259)
* Add ads server itself as an host in the inventory

* Comment all value in example

* Add Id in variable list per device

* Centralize code to add device status to variables

* Fix device variable name for blueprint
2017-03-03 19:38:46 +00:00
Damien
8032c9a715 Clean up group name before creation to remove spaces etc .. (#22020) 2017-03-01 11:20:28 +00:00
René Moser
87119479d8 cloudstack: fix pep8 cloudstack inventory (#22092) 2017-02-28 19:14:03 +01:00
Matt Clay
dd9a39b27b Make sure all inventory scripts are executable. 2017-02-22 20:31:28 -08:00
Damien
0141c0c336 inventory/Aos - Add session information to group all variables (#21719)
* Add aos.session information to group all variables

* Revert IP address change

* Remove space in empty line for PEP8
2017-02-22 16:45:49 -05:00
Brian Coca
5258e6d52a use safe load instead
fixes #21724
2017-02-21 17:45:46 -05:00
Daniel Lobato García
01436cf186 Add Foreman inventory (#19510)
This commit adds the foreman inventory based on
https://github.com/theforeman/foreman_ansible_inventory
and its configuration file.
2017-02-21 09:21:22 -08:00
Roman Belyakovsky
aa6585942e Fix for crash on missing privileges, closes #21051 (#21518) 2017-02-21 08:53:40 -05:00
Loïc Blot
d144cf9c27 vmware_inventory: permit to skip nopermission error on host subkeys (notify user in debug mode) (#21663)
example use case: you have rights on guest but you cannot see the VMWare host

Signed-off-by: nerzhul <loic.blot@unix-experience.fr>
2017-02-21 08:51:23 -05:00
Alex Trevino
0d060a185f Allow ec2.py to be imported (#21637) 2017-02-20 15:19:05 -05:00
Matt Clay
3f91e3531a Fix py3 issue in nagios_livestatus inv script. (#21687)
* Fix py3 issue in nagios_livestatus inv script.
* Fix PEP 8 issues.
2017-02-20 11:52:47 -08:00
Yannig
5d0805b25a Add Nagios livestatus inventory plugin. (#12342)
* Add Nagios livestatus inventory plugin.

* Add new capabilities for the nagios_livestatus inventory:
- host_field: set the name returned (default: 'name')
- group_field: set the field used for group (default: 'groups')
- host_filter: filter host using this filter (default: None)

To be more consistent, prefix was renamed into var_prefix.

* Fix py34 runtests errors against print call.
2017-02-20 13:44:07 -05:00
rafstef
8acb6417cb [cloud][inventory] Let ec2.py be renamed and search for a matching .ini file (#21567)
With this proposed PR, we want to make the use of many ec2 dynamic inventory files more flexible.
We are using multiple AWS accounts. We want to use different ini file (one for every account) and only one ec2.py.
2017-02-20 13:38:41 -05:00
Brian Coca
e4022906d3 manually integrated from PR #10350 2017-02-20 13:36:58 -05:00
Damien
4d4fdb3500 inventory/apstra_aos - Add a new output format when a blueprint name is provided (#21434)
* Add a new output format when a blueprint name is provided

* Add author name
2017-02-17 20:26:53 -05:00
Ryan S. Brown
3c25a39b3e [cloud][aws] Use binary read for inventory cache file 2017-02-16 09:42:46 -05:00
Alex Trevino
413dfa7273 [cloud][aws] Use with statement for file rw in EC2 dynamic inventory (#21390)
* Use with statement when doing rw on files

* Deserialize file-like object directly instead of a string

For python 2/3 compatibility reasons, per PR feedback.
2017-02-16 09:41:55 -05:00
Jonathan McCall
047ed2728c Pass boto_profile to get_route53_records (#14354)
* Pass boto_profile to get_route53_records

* Add conditional around r53_conn to check for boto_profile
2017-02-16 08:49:47 -05:00
Ian White
80bc7048bd Feature: adding route53_hostnames option to set the hostnames from route 53 (#20909)
* adding route53_hostnames option to set the hostnames from route 53

* checking whether the route53_hostnames option is present as suggested by @s-hertel

* setting route53_hostnames to None when config option not present

* skip the to_safe only when using route53_hostnames option, as suggested by @ryansb

* skipping the to_safe strip only for the hostnames that came from route53 as suggested by @ryansb
2017-02-14 10:50:41 -05:00
gregorydulin
cf424f0413 [cloud] Add group_by_instance_state to EC2 Dynamic Inventory (#20430) 2017-02-14 10:27:19 -05:00
Allan
e246bd10ac Update nsot.py (#19421)
To make this compatible with NSoT v1.x, removing ['data']['devices'].
2017-02-10 19:46:55 +00:00
Damien
a995fa43a6 New dynamic inventory for Apstra AOS (#21045)
* Initial release of dynamic inventory for AOS
2017-02-09 13:10:36 -05:00
Ryan S. Brown
9794bd8c35 [cloud][docs] Add more EC2 dynamic inventory stack_filter docs 2017-02-09 09:13:10 -05:00
Ilya Kalinin
259b05dd8e [cloud] Add stack_filters option to EC2 inventory script 2017-02-09 09:13:10 -05:00
Justin Mayer
fda131504b Support multiple vault passwords in keyring script
Allows users to specify a key name in a given project’s `ansible.cfg`
file and thus handle keyring integration with vaults with different
passwords. If no key name is specified, the original default `ansible`
key name will be used.

Other improvements:

* `username` is now optional; defaults to user that invokes the script
* change string interpolation to new `.format()` style
* clean up and expand upon documentation
* enforce PEP 8 compliance
2017-02-08 16:05:36 -05:00
Matt Martz
5942de603d Legacy pep8 clean fixes for contrib and hacking (#21081) 2017-02-07 09:49:55 -06:00
Matt Martz
39ea50b731 pep8 fixes for recent packet_net inventory (#21066) 2017-02-06 11:10:58 -05:00
Tomáš Karásek
db8fd95d68 Dynamic inventory for Packet host (https://packet.net) (#20635)
* Add dynamic inventory script and config for Packet.net

* The script and config have been shamelessly cargo
  culted from the `ec2.py` and `ec2.ini` dynamic inventory
  script.
* This is an initial version and could very well be
  enhanced and made better.

Examples:

`PACKET_NET_API_KEY=<MY_AUTH_TOKEN> --list` to get inventory for
all hosts in Packet.net in all projects (defaults to `--list`
if no argument provided).

`PACKET_NET_API_KEY=<MY_AUTH_TOKEN> --host HOST` to get variables
for a single host.

* improvements in Packet host dynamic inventory
2017-02-06 09:56:17 +00:00
Matt Clay
e401b4e424 PEP 8 fix. 2017-02-01 08:24:31 -08:00
Naoya Nakazawa
31db1bcd34 ec2.py support region auto (#15427) 2017-02-01 09:08:15 -05:00
Will Thames
d6ea400efb Improve boto profile handling for EC2 inventory (#20280)
Ensure command line profile argument and AWS_PROFILE environment variable
overrides config file
Remove unnecessary `lambda` function
Fix cache file path construction to be more pythonic (and windows-ready)
2017-01-31 09:35:45 -05:00
Matt Clay
f80224f828 PEP 8 E111 cleanup. 2017-01-30 20:18:50 -08:00
Matt Clay
cb76200c7d PEP 8 E111 & E114 cleanup. (#20838) 2017-01-30 15:01:47 -08:00
Matt Clay
10d9318de7 PEP 8 indent cleanup. (#20800)
* PEP 8 E121 cleanup.

* PEP 8 E126 cleanup.

* PEP 8 E122 cleanup.
2017-01-29 07:28:53 +00:00
Matt Clay
e2c0b375d3 PEP 8 cleanup. (#20790)
* PEP 8 E115 cleanup.
* PEP 8 E131 cleanup.
2017-01-28 01:39:40 -08:00
Matt Clay
d0d1158c5e PEP 8 cleanup. (#20789)
* PEP 8 E703 cleanup.
* PEP 8 E701 cleanup.
* PEP 8 E711 cleanup.
* PEP 8 W191 and E101 cleanup.
2017-01-28 00:12:11 -08:00
Matt Clay
d913f69ba1 PEP 8 W291 whitespace cleanup. 2017-01-27 17:08:02 -08:00
Matt Clay
95789f3949 PEP 8 whitespace cleanup. (#20783)
* PEP 8 E271 whitespace cleanup.
* PEP 8 W293 whitespace cleanup.
* Fix whitespace issue from recent PR.
2017-01-27 15:45:23 -08:00
Matt Clay
63b1e0c277 Fix infrequent PEP 8 issues. 2017-01-27 14:06:21 -08:00
Peter Hoffmann
d70b2c8afd fix typo 2017-01-27 12:17:33 +01:00
Matthew Wedgwood
3ab388f6dd Add account ID grouping and attribute to ease multi-account management 2017-01-23 13:49:02 -05:00
Laurent Mazuel
8b9ded3556 Fix bug 17934 : Azure register failure must not be blocking (#18695)
* Fix bug 17934

* Update link in Azure provider warning log
2017-01-18 14:28:36 -08:00
Loïc Blot
a3321d1074 vmware_inventory.py: skip_keys can use a full key path (#20389)
use inkey attribute in _process_object_types recursive loop to generate key name in skip_keys directive.

This permit to ignore nested variables, for example summary.vm to optimize inventory collect
2017-01-18 13:36:11 +00:00
Brian Coca
18214e5948 added metadata to vault scrypt 2017-01-17 14:37:06 -05:00
Hugh Ma
541d2e8820 Stacki inventory (#19608)
* adding inventory script for stacki

* clean-up for consistency and error check

* clean up imports and implement StrictVersion for requests
2017-01-17 14:01:58 -05:00
Loïc Blot
35f6fb1383 vmware_inventory: permit to group by custom field & customize skip_keys (#20125)
* vmware_inventory: permit to group by custom field

This permits to create instances, affect some custom fields like EC2 tags and then retrieve groups from custom fields like EC2 inventory

* vmware_inventory: Customize skip_keys & add resourceconfig to skip_keys

Verify if customfield is a str before processing custom fields for a host
2017-01-12 09:37:18 -05:00
TaoBeier
6ec0369c26 fix indent (#20071) 2017-01-10 18:47:03 -08:00
Ner'zhul
78ed9793fe Various VMWare inventory (pyvomi fixes) + ini doc (#19926)
* Fix many points reported by PyCharm as PEP 8 code style
* Improve inventory performance by dropping vim.HostSystem & vim.VirtualMachine collect when depth >= 2
* Declare some class variables properly
* Remove some unused variables
* Add documentation in vmware_inventory.ini for VMWARE_USERNAME & VMWARE_PASSWORD env vars
2017-01-10 09:09:11 -05:00
Art Matsak
e4c1eff52e Register host variables for the DigitalOcean dynamic inventory 2017-01-06 12:00:15 -05:00
Andrew Craft
44fb104da3 softlayer inventory include group by tags 2017-01-03 15:26:39 -08:00
Aleksey Shirokih
db1c3221a0 fix copy paste error 2016-12-22 17:06:18 -08:00
John R Barker
739a310382 Formatting (#19353) 2016-12-14 18:26:17 +00:00
Andrea Tartaglia
59227d8c31 Removed dict.iteritems() in several other files.
This is for py3 compatibility #18506
2016-12-14 08:01:45 -08:00
Carlos E. Garcia
0b8011436d minor spelling changes 2016-12-13 13:51:13 -05:00
Toshio Kuratomi
51491c9904 Remove itervalues (not available on py3) 2016-12-13 05:40:48 -08:00
Matt Clay
75c281debc Fix compile errors in scripts. 2016-12-08 11:35:20 -05:00
Tom Melendez
9400ba1728 [GCE] inventory script supports paginated API results. (#18554)
The inventory script now supports paginated results.  This means that inventory may exceed 500 instances.
2016-12-08 11:35:19 -05:00
Michael Schuett
21813ed83e Fix auth in collins.py inventory
This forces basic auth to be used. Using the normal HTTPPasswordMgrWithDefaultRealm
password manager from urllib2 fails since collins doesn't send a 401 retry on failure.
More about this can be seen here http://stackoverflow.com/questions/2407126/python-urllib2-basic-auth-problem.
I added a small comment about the format of the host so others don't waste time like i did.
2016-11-23 14:39:25 -05:00
Ryan Groten
f12d5b01c7 FreeIPA: Add support for nested hostgroups in FreeIPA (#14695) 2016-11-18 14:41:38 +01:00
Dag Wieers
1ca4add91c Performance improvement using in-operator on dicts
Just a small cleanup for the existing occurrences.

Using the in-operator for hash lookups is faster than using .keys()
http://stackoverflow.com/questions/29314269/why-do-key-in-dict-and-key-in-dict-keys-have-the-same-output
2016-11-17 12:33:04 -05:00
Ondra Machacek
563017f7ec Add dynamic inventory for oVirt version 4 and RHV version 4 (#17910)
* Add dynamic inventory for oVirt version 4 and RHV version 4

* Add affinity labels and groups to output
2016-11-17 09:18:46 -05:00
James Tanner
2d2bb626d4 Port has_key to python3 compatible syntax 2016-11-16 13:02:09 -08:00
David Moreau Simard
c53db300b8 Update the link to the os-client-config repository
This is a trivial change -- os-client-config has moved from /stackforge/ to /openstack/ a long time ago.
2016-11-08 10:41:38 -05:00
Toshio Kuratomi
03550caece Move mdt dynamic inventory plugin into contrib/inventory where it
belongs
2016-11-07 12:02:29 -08:00
Tony Kinsley
73da2663a3 Resolves #18312 python3 support for ec2.py 2016-11-03 11:46:50 -07:00
Matt Clay
0d46805979 Clean up shebangs for various files.
- Remove shebangs from:
  - ini files
  - unit tests
  - module_utils
  - plugins
  - module_docs_fragments
  - non-executable Makefiles
- Change non-modules from '/usr/bin/python' to '/usr/bin/env python'.
- Change '/bin/env' to '/usr/bin/env'.

Also removed main functions from unit tests (since they no longer
have a shebang) and fixed a python 3 compatibility issue with
update_bundled.py so it does not need to specify a python 2 shebang.

A script was added to check for unexpected shebangs in files.
This script is run during CI on Shippable.
2016-11-02 17:00:27 -07:00
Toshio Kuratomi
f7d9a734d5 Port rax dynamic inventory script to Ansible 2.3 get_config() (#18204)
* Port rax dynamic inventory script to Ansible 2.3 get_config()

Fixes #18203
2016-10-26 14:46:08 -07:00
Matt Davis
6b02d296d7 fix azure_rm.py to work with 2.0.0rc5 or rc6 2016-10-26 11:01:53 -07:00
John M. Carlin
a3f88eddad Documented configuration option for url 2016-10-24 20:30:31 -04:00
John M. Carlin
ef7fd10b15 Add SSL support to Consul inventory script
Change passes in the scheme argument to python-consul's Consul
initializer. Default scheme is set to http.
2016-10-24 20:30:31 -04:00
Thomas Sjögren
b35d4d7a19 add tag grouping
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2016-10-24 20:24:00 -04:00
Thomas Sjögren
d24bf49d3f typo, do_tags, do_volume_ids
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
2016-10-24 20:23:16 -04:00
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
René Moser
c588bade1f cloudstack: add domain, group per zone to dynamic inventory (#17792) 2016-10-24 18:53:34 +02:00
Daniel Yates
39e86ae2bc Correctly read use_private_network as boolean
This fixes the use of public IPs in the discovered hosts by
ensuring that the use_private_network check doesn't always evaluate
to False if the associated .ini file specifies this option.
2016-10-23 13:16:29 +02:00
Nijin Ashok
1f3d82dd18 Fix improper handling of machine_type in ovirt inventory (#16251)
Currently the machine_type will not work if the instance type is set in ovirt. In that case, inst.get_instance_type will be an object and will fails while converting to json. This only work if the instance type is not set in ovirt where inst.get_instance_type is a Null value. The current change make sure that correct "instance type" is passed when instance is set in ovirt and Null when it's not set in ovirt.
2016-10-23 02:14:09 +02:00
jctanner
05aed6e52e vmware_inventory: fix the --host and add 'properties' feature to ini (#18072)
* vmware_inventory: fix the --host option
* Fix skip_key evaluation
* Short circuit deep dives in datastores and resourcegroups
* Put timestamps in the debug output and add a few more
* Implement a user defined proplist to increase performance
* Make all props into dicts
* Update ini with example
* Fix tests
2016-10-18 16:21:37 -04:00
jctanner
8095c3951a vmware_inventory: Make the ceritifate check default, and create a config option (#17830)
Fixes #17811
2016-09-30 09:06:02 -04:00
jctanner
66426dcd38 vmware_inventory: decode strings to ascii if not alphanumeric (#17618)
Fixes #17281
2016-09-16 17:09:42 -04:00
Khushil Dep
08db04ccb6
Changes as per @abadger 2016-09-14 15:11:57 +01:00
Khushil Dep
054e640fba
Add enumeration of block devices to ec2_block_devices 2016-09-14 15:11:57 +01:00
Davis Phillips
4f177e623e Corrected port designation in INI file (#17543) 2016-09-13 09:58:06 -04:00
Robin Schneider
d76dd56ca3
Use addresses and names reserved for documentation
Trying to preserve the meaning of the examples. Not all occurrences in
`docsite/rst/playbooks_lookups.rst` have been changed for instance to
allow the unchanged examples to be used for testing.

Related to: #17479
2016-09-11 17:31:41 +02:00
Jared Sprague
23f78efd74 Add public_ip option to linode dynamic inventory (#17390)
* Add public_ip option to linode dynamic inventory

* Add an option to use public IP instead of label for linode hosts
2016-09-09 09:14:27 -04:00
Toshio Kuratomi
a22909c226 Migrate basestring to a python3 compatible type (#17199) 2016-08-23 13:13:44 -07:00
Adrian Likins
57a911e098 Use sys.exit(msg) i/o print() and sys.exit() (#15465)
Any non-0 exits should be showing an error message
to stderr instead of to stdout.
2016-08-23 11:09:23 -04:00
jctanner
a0a2e1509e vmware_inventory script improvements (#17142)
* vmware_inventory script improvements
* switch instance finding method to use containerview based searches
* overhaul the serialization method for objects
* Cleanup the debug outputs
* Add a warning about performance
2016-08-19 10:40:22 -04:00
nitzmahone
4fbd17d949 py3 print fix 2016-08-18 14:37:52 -07:00
Josh Preston
2a2d866c0d add cloudforms inventory script (#17037)
* add cloudforms inventory script

based on the foreman inventory script, features:

* cached results (default 600 seconds)
* paginated host results (default 100 hosts)
* ssl verification (default True)
* arguments to flush cache and run in debug mode

* suggested rework

* removed second cache / dict with duplicate info
* added purge_actions configuration option to remove the actions from a host (defaults to False)
* added prefer_ip_address configuration option so give the option of using ip address instead of name (defaults to True)
* removed self variables — just use the arguments directly
* added --pretty command line option to pretty print results
* renamed _resolve_params to _resolve_host

* implement suggestions

* removed not used import
* added warnings to help debug connection issues
* renamed self.cache to self.hosts for clarity
* now will use the first ip address as ansible_ssh_host
* flipped default for prefer_ip_address config option to false - preserve name, and specify ansible_ssh_host as ip address
* added checks and warnings to configuration options, sane defaults for all except required:
** `url` - the first part of the cloudforms server url (https://cfme.example.com)
** `username`  - the cloudforms username to log in with
** `password` - the password for the cloudforms user specified
* removed redundant call to fetch host information (since we’re paging results, no need to split the calls)
* added warning for unexpected responses from CloudForms
* debug for returned sting now prints the string instead of forcing to JSON
* removed no longer needed methods to fetch host information
* using ‘key in list’ instead of ‘list.has_key(key)’
* correctly formatted groups and allowed nested groups
* now create groups for `location`, `type` and `vendor`, with appropriate sub-groups and children
* made to_safe honor config option to clean group names for ansible consumption

* remove prefer_ip_address configuration option

no longer needed since we will specify `ansible_ssh_host` as the returned ip address.

* removed dns_name

no longer needed, will preserve `host[name]` as name in Ansible.

* purge actions from hostvars

changed purge_actions to True

* flake8 suggestion for whitespace

* fix undefined r variable in warning output

use the correct ret variable

* Default purge_actions to True

We probably don’t need them, but it is configurable, so just default to remove them.

* Add configuration option to nest cloudforms tags

disabled by default, the nest_tags option will expand cloudforms tags into a nested group/subgroup structure.  Otherwise, it will use the whole tag name.

* added purging the actions

removed in previous clean up in error.

* fixed undefined variable

specified the correct variable for logging.
2016-08-18 14:37:31 -07:00
jctanner
14da357feb vmware inventory script enhancements (#17106)
* Allow the user to disable certificate verification
* Allow the user to find VMs only in specific clusters
2016-08-17 17:44:15 -04:00
Ryan Brown
c5cc6edb93 Merge pull request #16606 from ryansb/rds-cluster-inventory-aioue
Support RDS clusters in AWS dynamic inventory script
2016-08-15 15:08:55 -04:00
Ryan S. Brown
0783c172d7 Paginate DB cluster responses in AWS RDS dynamic inventory 2016-08-15 14:27:48 -04:00
Andrew Dolby
cbbc643317 add default location and env override (#16854) 2016-08-04 09:54:44 -07:00
Oskar Wyciślak
8e956675f7 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
Dick Davies
fc6b841b2f correct ini variable name (#16901)
cache_path is used to calculate cache_dir , the script doesn't actually read cache_dir from this file.

This makes the setting work (otherwise it always uses the default).
2016-08-01 17:34:06 -04:00