Commit Graph

431 Commits (1400d161c042e3bb5ffc883e24c6268d18283324)

Author SHA1 Message Date
Abhijeet Kasurde 5ed81820c0
VMware: Custom Field in vmware_inventory (#39796)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Daryl Banttari e0893aacc5 [ec2 contrib script] Add ability to filter EC2 instances via shell environment (#39034) 7 years ago
Sylvain Rabot 521cc3d4e6 [contrib] azure_rm.py add mechanism to force use of private ip as ansible_host (#36109)
Signed-off-by: Sylvain Rabot <s.rabot@lectra.com>
7 years ago
Ondra Machacek fac7b2f1ca ovirt: Clarify secrets configuration (#39501)
Fixes: https://github.com/ansible/ansible/issues/39478
7 years ago
Matt Clay 32d786af65 Convert more http links to https. 7 years ago
Javier Beaumont 8faf9837d0 [cloud][aws] PEP8 renaming in EC2 dynamic inventory (#39164) 7 years ago
Abhijeet Kasurde 12431d23cd VMware: Support for multiple jinja filters in vmware_inventory (#38173)
This fix adds support for multiple jinja filters for groupby_patterns
and host_filters.

Fixes: #37961

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
John Roach 3f2c90914e Fixes Making sure that the key value returns a string to avoid concatenation issues (#37445) 7 years ago
Bill Nottingham 15b6ec66bb Set `raw=True` when reading passwords from ConfigParser files. (#35582)
* Set `raw=True` when reading passwords from ConfigParser files.

The assumption is that no one is actually doing interpolation on the
password value, even if they may for other configuration values, and
passwords are far more likely to contain '%'.

* Add vmware_inventory as well.
7 years ago
Hideki Saito 1b121fc9e4 Fix dynamic inventory for vagrant does not work on python3 (#37631)
* Fix dynamic inventory for vagrant does not work on python3 #35129
7 years ago
Patrick Marques d5cd10c214 Remove unused import from azure dyn inventory (#34980) 7 years ago
Jordan Borean 89a80e0591
Removed windows_azure inventory script to avoid confusion with azure_rm.py (#37439) 7 years ago
Tyler Gregory 6dfc82fe3e Set win_rm protocol to the name, not the full ProtocolTypes object (#37499) 7 years ago
Peter Schiffer 8c992ccbc7 Allow filtering of instances by tags in GCE dynamic inventory (#35770)
* Allow filtering of instances by tags in GCE dynamic inventory

* Optimize instance tags configuration

* Fix for PEP8
7 years ago
Pilou 1c43f7c482 FreeIPA inventory (ipalib 4.6.2): avoid exception (#34356)
Workaround for https://pagure.io/freeipa/issue/7345.

mentions:
- IPA_CONFDIR environment variable when directory doesn't exist
- domain, xmlrpc_uri or jsonrpc_uri parameters when one is missing

Exception was:
$ IPA_CONFDIR=/path/to/empty/dir ./ansible/contrib/inventory/freeipa.py --list
Traceback (most recent call last):
  File "./ansible/contrib/inventory/freeipa.py", line 95, in <module>
    api = initialize()
  File "./ansible/contrib/inventory/freeipa.py", line 18, in initialize
    api.finalize()
  File "local/lib/python2.7/site-packages/ipalib/plugable.py", line 738, in finalize
    self.__do_if_not_done('load_plugins')
  File "local/lib/python2.7/site-packages/ipalib/plugable.py", line 425, in __do_if_not_done
    getattr(self, name)()
  File "local/lib/python2.7/site-packages/ipalib/plugable.py", line 618, in load_plugins
    for package in self.packages:
  File "local/lib/python2.7/site-packages/ipalib/__init__.py", line 949, in packages
    ipaclient.remote_plugins.get_package(self),
  File "local/lib/python2.7/site-packages/ipaclient/remote_plugins/__init__.py", line 120, in get_package
    server_info = ServerInfo(api)
  File "local/lib/python2.7/site-packages/ipaclient/remote_plugins/__init__.py", line 26, in __init__
    hostname = DNSName(api.env.server).ToASCII()
AttributeError: 'Env' object has no attribute 'server'
7 years ago
Monty Taylor 0f893027c4 Add a module_utils OpenStack Cloud constructor (#20974)
Start using this to construct shade OpenStack Cloud objects in a
consistent manner. This will let us centralize things like dealing with
password arguments and whatnot. It also allows us to introduce the
ability to pass a fully formed config dict directly to the module.

Migrate all OpenStack modules to use openstack_cloud_from_module.

Have it return the shade library since it's responsible for
importing shade and shade is needed for the exceptions.

Only pull specific OpenStack arguments for the constructor

Rather than passing **module.params to the shade constructor, pull out
only the values that make sense. This should prevent the issues with
module parameters stepping on shade parameters.

Replace module.params.pop with module.params.get

We don't need to pop these anymore since the shade constructor is now
using opt-in values.

Using real urls is ungood. Use example.com domains. Also, get rid of the
antiquated port numbers.
7 years ago
ABond 2940b9d5bb Removed sort from json dump since response is a mix of strings and integers (#34217) 7 years ago
Simon Wydooghe c119f6e642 Add 'digital_ocean' as group (#21631) 7 years ago
Paul B ccdc93ab59 contrib(inventory): fix Scaleway inventory used w/env variable token (#35701)
In order to authenticate with the Scaleway API for the contrib dynamic
inventory Scaleway the environment variable SCALEWAY_TOKEN was read
only if a value was set in the configuration .ini file.

This PR fixes that allowing to read only the environment variable
without needing to set a token in the configuration file.

Closes #35693
7 years ago
Richard Bywater 7dbcf752c8 Add ability to select to prefer IPv4 addresses for ansible_ssh_host (#35584)
Currently Cloudforms can return a mix of IPv4 and IPv6 addresses in the
ipaddresses field and this mix comes in a "random" order (that is the
first entry may be IPv4 sometimes but IPv6 other times). If you wish to
always use IPv4 for the ansible_ssh_host value then this is problematic.

This change adds a new prefer_ipv4 flag which will look for the first
IPv4 address in the ipaddresses list and uses that instead of just the
first entry.
7 years ago
Clement Trebuchet 862c439223 Contrib infoblox exattrs Fixes #35409 (#35410)
* *FIX: re-create the exattrs dict into the hostvars[name] dict

* *FIX: remove unwanted files

* Fixes #35409: put an str instead of variable
7 years ago
Peter Sprygada c2d3b9cbd5
refactors nios api shared code to handle provider better (#35393)
* refactors nios api shared code to handle provider better

This change refactors the shared code to be easily shared between
modules, plugins and dynamic inventory scripts.  All parts now implement
the provider arguments uniformly.

This also provides a centralized fix to suppress urllib3 warnings coming
from the requests library implemented by infoblox_client

* fix up pep8 errors

* fix missing var name
7 years ago
Peter Sprygada 3f556f2e37
adds infoblox dynamic inventory script (#35328)
* adds infoblox dynamic inventory script

* fix up issues from sanity testing

* fix pep8 issues
7 years ago
Jonathan McCall cdf8f29e70 Add hash making inventory caches unique to inventory script ran (#34742) 7 years ago
Sam Edwards a1639abd71 Fix Digital Ocean inventory script pagination handling (#35153) 7 years ago
Kristóf Havasi 1c22d82c5e consul_io: fixed service availability check (#34293)
service is only up if the node publishing it is also available
7 years ago
Fabrice Flore-Thébault 5b52bfad6d azure_rm inventory should add "ansible_connection: winrm" in host_vars for windows hosts - fixes #34689 (#34691)
* fix for https://github.com/ansible/ansible/issues/34689
azure_rm inventory should add "ansible_connection: winrm" in host_vars for windows hosts

* add ansible_connection: winrm - fix for https://github.com/ansible/ansible/issues/34689
7 years ago
Richard Bywater a7e27b74c9 Add ability to append suffix to host names for Cloudforms Inventory (#33565)
* Add ability to append suffix to host names for Cloudforms Inventory

Allows for use of a suffix that will be appended to host names returned
from Cloudforms API if that suffix is not present.

For example with a suffix of 'example.org', the following results
would be shown for a particular Cloudforms host name:
someexample -> someexample.example.org
someexample.example.org -> someexample.example.org

The main use-case for this is when Cloudforms has short names rather
than FQDN and there is a desire to to use the FQDN as the name.

* Add example line into Cloudforms INI file

* Clarify that leading fullstop needed

* Add validation to ensure leading fullstop for suffix
7 years ago
Abhijeet Kasurde 191b934dbd
freeipa: support for host vars (#34535)
Adds method to return host vars related to FreeIPA hostname.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Danilo Riecken P. de Morais 5540e2f8a9 cloudstack: inventory: Added feature list by tag (#31319) 7 years ago
Paul B 9302e8d2a4 contrib(inventory): adds a dynamic inventory for Scaleway cloud (#30313)
provider

Provides a dynamic inventory plugin for Scaleway cloud provider with
the following features:

- Configurable scaleway.ini file
- Cache API responses
- Choose public or private IPs
- Create groups per Scaleway 'tags'
- Create groups per Scaleway regions
7 years ago
Matt Clay 797664d9cb Python 2.6 `str.format()` compatibility fixes. 7 years ago
Fedele Mantuano 70fd5d4caf More stable explicit file close. (#34303) 7 years ago
Abhijeet Kasurde 0eb2644c1c Fix redeclaration of get_host_info function (#33608)
This fix redeclaration of get_host_info method in linode
inventory.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Kristóf Havasi a05ed65295 consul_io.py: typo fixed in docs (#34292) 7 years ago
Kristóf Havasi 6ba6c7e67c contrib/inventory/consul_io: typo fixed in documentation (#34291) 7 years ago
Robert "Bo" Davis b5c0141fb0 Use hostname in group_by_aws_account to prevent duplicates. (#34053)
Fix typo. The use of `dest` for group_by_aws_account causes the group to be produced using IP and to duplicate the hosts in the inventory.

Fixes #23772

Signed-off-by: bo <robert@jbanetwork.com>
7 years ago
Ryan Groten b34d150bec Use hostgroup_find(all=True) returns member hosts of all hostgroups in a single call (#29106) 7 years ago
Abhijeet Kasurde 36f82ae8cc Replace exit() with sys.exit()
This fix adds replacement for exit() to sys.exit(), as
exit() is not recommended way to exit from the program.

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Giovanni Sciortino ff923fb6b0 Add scan_new_hosts feature in ansible foreman inventory (#33743) 7 years ago
pymag09 92c5b758f8 Improve consul_io.py execution speed (#33737)
* Improve execution speed

* fix missing whitespace
7 years ago
Abhijeet Kasurde ebd6db7a1c
Digital Ocean Inventory refactor (#29176)
* Remove 'dopy' dependency
* Update documentation
* Incorporate BondAnthony's IP address related code
* Incorporate andrewsomething's Pagination code
* Add Tags support

Fixes: #15752

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Ryan MacLean d7ca068c3f [cloud] Typo fixes for ec2 dynamic inventory (#32957) 7 years ago
Abhijeet Kasurde 449a0f33e1
Fix ConfigParser.set error in vmware_inventory (#31643)
Fix adds default 'vmware' section in configuration,
when this section is not found.

Fixes: #31549

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Matt Clay e45c763b64 Fix invalid string escape sequences. 7 years ago
Abhijeet Kasurde d372cea2f8
VMware: change default host_filter to gueststate (#32839)
This fix changes default value of host_filter in vmware_inventory.py
and vmware_inventory.ini to 'runtime.powerstate' from 'guest.gueststate'.
This change is added as 'guest.gueststate' requires vmware tools to be
installed on given VM, which may not be the case everytime.

Fixes: #25086

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
gamuniz 10866bfb8b Exception handling in vmware_inventory for vcsim (#32700)
* vmware_inventory changes to support vcsim
* updated debug message per maintainer request
7 years ago
Kenny Woodson c4af03118b Add support for tags and instance attributes for destination variable for the ec2 dynamic inventory. (#29033) 7 years ago
Ondra Machacek a7df2322e4 ovirt: Add env variables to dynamic inventory (#31821)
This patch add new environment variables to oVirt dynamic inventory
to be consistent with all other oVirt modules:

 OVIRT_URL
 OVIRT_USERNAME
 OVIRT_CAFILE
 OVIRT_PASSWORD

Those variables are used as fallback if user don't specify a ini file,
with appropriate variables there.
7 years ago
François Scala aade5234a9 Fix urlparse import for Python3 (#31240)
* Fix urlparse import for Python3 in

* contrib/inventory/consul_io.py
* contrib/inventory/rudder.py
* contrib/inventory/windows_azure.py
* lib/ansible/module_utils/known_hosts.py
* lib/ansible/modules/cloud/centurylink/clc_firewall_policy.py
* lib/ansible/modules/cloud/docker/_docker.py
* lib/ansible/modules/cloud/ovirt/ovirt_disk.py
* lib/ansible/plugins/action/ce_template.py
7 years ago
Thomas Stringer cb01f33d1e refactor azure dynamic inventory script configparser import to support python3 (#31370)
* refactor configparser import to support python3

* change ModuleNotFoundError to ImportError
7 years ago
Avner Cohen d313c2d5e9 [cloud] RDS config should be getboolean, as per ec2.ini instructions (#31168) 7 years ago
Jiri Tyr d35ef1fc21 [cloud][contrib] Set missing default values for EC2 inventory (#28375)
* Set missing default values for EC2 inventory

* Make it run even with no ec2.ini file

* Fixing INI file reading

* Refactor how defaults are handeled

Define defaults in a dictionary and use .get rather than if statements with has_option

* Removing double keys and fixing logic for instance_filter

* Removing one more doubled key
7 years ago
jctanner 219a6a67f1 Add a select_chain_match filter to vmware_inventory (#28778) 7 years ago
Martin Krizek d804ac6f4b Implement AND'd filters in ec2.py/ini (#30272)
* Implement AND'd filters in ec2.py/ini

remove debug print

* Adjusting code to changed filters' data structure
7 years ago
Matt Clay 7714dcd04e Enable more pylint rules and fix reported issues. (#30539)
* Enable pylint unreachable test.
* Enable pylint suppressed-message test.
* Enable pylint redundant-unittest-assert test.
* Enable pylint bad-open-mode test.
* Enable pylint signature-differs test.
* Enable pylint unnecessary-pass test.
* Enable pylint unnecessary-lambda test.
* Enable pylint raising-bad-type test.
* Enable pylint logging-not-lazy test.
* Enable pylint logging-format-interpolation test.
* Enable pylint useless-else-on-loop test.
7 years ago
jchristi 9d5671db76 Allow filtering RDS instances by tags in the ec2 dynamic inventory script (#24423)
* Allow filtering RDS instances by tags in the ec2.py dynamic inventory script

* PEP8 fix

* Fix no-bastring code smell

* Simplify logic in ec2.py RDS filtering by tag
7 years ago
Matt Clay 442af3744e Miscellaneous pylint fixes.
The following rules are no longer disabled:

- bad-format-string
- duplicate-key
- lost-exception
- trailing-newlines
- unexpected-keyword-arg
- useless-suppression
- using-constant-test
7 years ago
Matt Clay 68aeaa58a8 Fix dangerous default args. (#29839) 7 years ago
Will Thames f9a179f770 Handle missing docker-py better (#27540)
* Update docker inventory to use APIClient

docker-py has been updated, and the `Client` class no longer
exists. We use the new `APIClient` class.

To provide graceful failure when docker-py is not installed,
we need to create a dummy `Client` class so that the inventory
script will get as far as displaying a useful error message

Before

```
$ contrib/inventory/docker.py --pretty
Traceback (most recent call last):
  File "contrib/inventory/docker.py", line 418, in <module>
    class AnsibleDockerClient(Client):
NameError: name 'Client' is not defined
```

After

```
$ contrib/inventory/docker.py --pretty
Failed to import docker-py. Try `pip install docker-py` - cannot import name Client
```

* docker inventory configuration file location

Allow docker.yml to live next to docker.py, as well as in the
current directory
7 years ago
Matt Davis 12700f61e7 fixed incorrect endpoint selection in azure_rm.py 7 years ago
Maciej Lasyk 5c0b94217e Added handling optional GCE_CREDENTIALS_FILE_PATH (#25526)
Ansible documentation states that env variable based authentication bases on variable GCE_CREDENTIALS_FILE_PATH while gce.py reads only GCE_PEM_FILE_PATH (see https://docs.ansible.com/ansible/guide_gce.html). This commit adds GCE_CREDENTIALS_FILE_PATH to the configuration chain; if set it will be used.
7 years ago
Matt Davis b3f2d1befe expose cloud_environment override in azure_rm modules (#28743)
* Can be set via env, credential profile, or module arg
* Valid values defined by Azure Python SDK, currently `AzureCloud`,`AzureChinaCloud`,`AzureUSGovernment`,`AzureGermanCloud` or any Azure Stack metadata discovery URL.
7 years ago
Alejandro Bednarik 9aa5e0cc3e Add GPL License header to freeipa inventory file. (#24353)
* Add GPl License header to freeipa incentory file.

* Short GPL license
7 years ago
furhouse af9396841e zabbix_inventory PEP8 compliance. (#28680) 7 years ago
jctanner 443b25d72a Fixup the property collection for dictionaries vs. objects (#28609)
* Fixup the property collection for dictionaries vs. objects

* Remove debug lines

* Do not attempt to sort because it's a waste

* Remove unused code

* Remove extra code

* Capture lowercase keys
7 years ago
jctanner 65feaa11b2 Fix valueerror in vmware_inventory.py (#28597) 7 years ago
David Kretch beed59f303 Fix trailing space in ec2_vol example, fix 'the the' typos (#28440)
* Fix 'the the' typos, fix 'pahting' filename typo

* Change 'the the' typos to a single 'the'.
* Change `playbook_pahting.rst` to `playbook_pathing.rst`.

* Delete trailing space in ec2_vol example

Delete the trailing space in `instance: "{{ item.id }} "`, which makes the
example fail when run because it looks for instance "i-xxxx ".
7 years ago
Abhijeet Kasurde c876f4f3cf Make FreeIPA inventory work (#25354)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Andrea Tartaglia fd01a9bb99 Added GPL header to vmware_inventory.py (#24443) 7 years ago
Michael Overmeyer 930d5d88b7 Fix #24546 (#24562) 7 years ago
Sam Doran f35975f114 PEP8 fixes 7 years ago
Peter Hoffmann 6c9cb05cfd Use tenant in UserPassCredentials if set.
If you have multiple Tenants you need to set the tenant in https://github.com/Azure/msrestazure-for-python/blob/master/msrestazure/azure_active_directory.py otherwise the azure_rm.py call will fail.
7 years ago
Achraf Cherti e45d5b7e8e Compatibility of gce.py (Google Cloud Ansible inventory) with Python 3 (#26032)
* Compatibility of gce.py (inventory) with Python 3

* Revert './secrets.py' file check (will import 'secrets' from PYTHONPATH)

Instead of checking if secrets.py exists in the current directory, this
commit will make gce import 'secrets' from one of PYTHONPATH's paths.

There are 2 possibilities:
1. secrets.py will be used if secrets.GCE_PARAMS and
secrets.GCE_KEYWORD_PARAMS are declared.

2. secrets.py will be ignored if secrets.GCE_PARAMS and
secrets.GCE_KEYWORD_PARAMS aren't declared. This could happen in Python
>=3.6 where a module named 'secrets' could be imported if a custom
secrets.py doesn't exist in PYTHONPATH.
Check out https://www.python.org/dev/peps/pep-0506/ and
https://docs.python.org/3/library/secrets.html for more information.
7 years ago
James Portman 950e4b6505 Added checks for machine.os_profile is not None before trying to access child attributes (#22906) 7 years ago
Alvaro Aleman bb9c6694a7 Allow the Openstack dynamic inventory to discover ansible_user (#17944) 7 years ago
Gerard Lynch d9d983160d support OS_CLOUD in openstack dynamic inventory
allow a user to limit to a single cloud in clouds.yaml, and support
per-cloud caching.
7 years ago
Alvaro Aleman fe5e1a4bc4 OS dynamic inventory: respect OS_CLOUD env var 7 years ago
Do Hoang Khiem 3b12a85750 Add node private & public ips to gce groups (#12539) 7 years ago
Sebastian Cruz 223f94ec56 Fix missing option in #27848 (#27892) 7 years ago
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
7 years ago
Eric L 1fe14da226 Add possibility to interpret global parameters value as JSON with rich_params flag (#26180) 7 years ago
Adam Johnson 3f85aa3abd Use a real list comprehension rather than list() around a generator (#25594)
It's faster and more idiomatic.
7 years ago
Tian You 9364fa202f [cloud] Group RDS instances by tag keys in ec2 dynamic inventory (#24763) 7 years ago
jctanner 3b20585ada Fix 23417 (#27770)
* Expose user_metadat to ansible

* Fixed exception when no userData
7 years ago
Will Weber bfbdb3f3f0 assumption made that dopy only dep in dopy (#27536) 7 years ago
Nick Ball edf31f56af Linode inventory improvements: Add _meta/hostvars to inventory output. Add a 'linode' host group with all the hosts (#19329) 7 years ago
Toshio Kuratomi 225fa5d092 Fix undefined variables, basestring usage, and some associated python3 issues 7 years ago
Toshio Kuratomi edccfd5908 Fix undefined variable in libcloud dyn inv script
References #27193
7 years ago
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
7 years ago
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
7 years ago
Abhijeet Kasurde f7c8e7bdab Update vmware_inventory (#26308)
Fix adds
* Exception handling
* Unit tests

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
7 years ago
Josh Smift 290d84f904 Update ansible_ssh_host->ansible_host in ec2.py dynamic inventory (#17113) 7 years ago
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.
7 years ago
Alejandro Bednarik 2420bca0b5 Add GPl License header to rackhd inventory file. (#24354) 7 years ago
Ryan S. Brown 7cee903118 [cluster] Name Consul dynamic inventory config consistently w/ the script 7 years ago
Brian Coca 365f3dc9d9 switched to elif 7 years ago
Lorin Hochstein b17da1fae9 ec2.py: Better error messages for OptInRequired
Improve error messages for RDS and ElastiCache failures for code OptInRequired.
7 years ago
Matt Clay 2e85272cd5 PEP 8 fixes. 7 years ago
Ronny 955f8923e7 Update dynamic inventory zabbix.py (#19862)
Added _meta to improve the speed when using this dynamic inventory file
7 years ago