Commit graph

16428 commits

Author SHA1 Message Date
Tim Rupp
855fd98be6 Adds the bigip_config module to Ansible (#25191)
This patch adds the bigip_config module to Ansible to support
merging SCF files, saving running configs, resetting config
and validating SCF configs
2017-06-06 18:52:33 +01:00
Sloane Hertel
7bebc83dcf module_utils/ec2: fix boto3 tags to remove (#25277)
* Fix boto3 tags to remove; unable to remove a list of strings, need list of {'Key': key}

* pep8 fix

* cannot bugfix due to differences in AWS APIs - just document

* add more info to guidelines for using compare_aws_tags
2017-06-06 11:02:15 -04:00
Matt Kunkel
b2b0938aff Check / Skip cores for AIX5 Series (#25364) 2017-06-06 10:43:13 -04:00
Trishna Guha
f6a4803669 New module: platform agnostic way to manage local users on network devices (network/net_user.) (#25259)
* Add net_user platform agnostic module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Integration test for net_user

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* modify eos_user module to support name param as alias to username

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Test collection of users

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-06-06 20:05:08 +05:30
Toshio Kuratomi
15104acc00 Fix json.dumps to do something sensible with sets. 2017-06-06 07:15:39 -07:00
Toshio Kuratomi
be4e7a05fa remove_values could hit the recursion limit
When operating on arbitrary return data from modules, it is possible to
hit the recursion limit when cleaning out no_log values from the data.
To fix this, we have to switch from recursion to iteration.

Unittest for remove_values recursion limit

Fixes #24560
2017-06-06 07:15:39 -07:00
Tim Rupp
0133a5a763 Adds the bigip_gtm_pool module (#25275)
This module is used to manage GTM(DNS) pools in a BIG-IP.

Unit tests are provided. Integration tests can be found here

https://github.com/F5Networks/f5-ansible/blob/devel/test/integration/bigip_gtm_pool.yaml#L23
https://github.com/F5Networks/f5-ansible/tree/devel/test/integration/targets/bigip_gtm_pool/tasks
2017-06-06 11:25:55 +01:00
Ricardo Carrillo Cruz
1476e30c26 Add net_vlan platform agnostic module (#25252)
* Add net_vlan platform agnostic module

* Add vlan_id param

* Fix documentation and examples

* Remove whitespace
2017-06-06 11:45:02 +02:00
Ganesh Nalawade
6215922889 Add support for cliconf and netconf plugin (#25093)
* ansible-connection refactor and action plugin changes
* Add cliconf plugin for eos, ios, iosxr, junos, nxos, vyos
* Add netconf plugin for junos
* Add jsonrpc support
* Modify network_cli and netconf connection plugin
* Fix py3 unit test failure
* Fix review comment
* Minor fixes
* Fix ansible-connection review comments
* Fix CI issue
* platform_agnostic related changes
2017-06-06 13:56:25 +05:30
Toshio Kuratomi
6e473a432b Document the encoding parameter for the replace module
Add encoding parameter for replace to changelog
2017-06-05 19:39:56 -07:00
Evan Kaufman
49fe53266f Replace - workaround for non-utf8 text (#24861)
* Workaround for non-utf8 text exceptions
* Added encoding param, using to convert from bytes to text and back

Fixes ansible/ansible#24521
2017-06-05 19:35:18 -07:00
Ramon
bc4a8dbaa4 fix proposal for issue #25151: [python3] pip failed to create virtual env when using custom command (pyvenv) (#25241)
* Fix proposal for bug 25151

* Fix proposal for bug 25151 - pip module, pyvenv validation

* Graceful fail when virtualenv_python is defined and virtualenv_command uses the venv module

* Making sure that venv is being used as a modue "-m venv"

* Updating syntax in validations

* Updating syntax in validations - fixing stupid typo "[)"

* Raising an error if virtualenv_command is pyvenv or venv and virtualenv_python is used

* trailing whitespace gone, pyvenv, venv validation and docs update

* cleaning whitespaces from blank lines
2017-06-05 17:03:15 -07:00
Brian Coca
cf59f9765e fix script inventory plugin
fixes #25371

there is still better ways to do this, but this will 'unbreak' devel for now
2017-06-05 18:26:11 -04:00
Brian Coca
9831e1597f minor protection against bad config 2017-06-05 16:46:51 -04:00
Matthieu Simonin
8432ba80c1 Add the email confirmation option to gitlab_users (#25134)
`confirm` is an optional parameter ìn gitlab API[1].
It indicates whether the email of the user has to be confirmed.

[1]: https://docs.gitlab.com/ce/api/users.html#user-creation
2017-06-05 21:47:52 +02:00
Esteban Echeverry
e8e73e0edd Use to_text helper function to handle bytes and unicode 2017-06-05 11:58:19 -07:00
Esteban Echeverry
66040e0c9d Fix unicode errors in json.load method
HTTPConnection returns bytes in Python 2. An explicit
decoding is needed in Python 3 to ensure compatibility.
2017-06-05 11:58:19 -07:00
Abhijeet Kasurde
01eb70bdee Remove unwanted params from function call (#25348)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-06-05 11:04:39 -04:00
Karthik Suresh
448f6de6bd Minor change in comment sentence of shell (#25336)
Removing actually as "actual" mentioned two times in the sentence does not look good.
2017-06-05 10:52:57 -04:00
Abhijeet Kasurde
38775c5363 Fix a minor typo in network_common (#25328)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-06-05 10:50:27 -04:00
Michael De La Rue
e28845018d [cloud] New module: AWS API Gageway module (#20230)
* Ultra basic api-gateway module based of lambda.py

* Ultra basic deployment added to api-gateway module

* ApiGateway module Allow creation of APIs, more documentation and better return value

* ApiGateway module incorporate review feedback

* ApiGateway module flake8 cleanup

* APIGateway module - more review fixes.

* slightly better messages in api_gateway module

* AWS api_gateway module - try to improve messages in case of exceptions

* rename api_gateway module to aws_api_gateway as discussed in PR 20230

* aws_api_gateway - Allow delivery of swagger either as text or dictionary.

* aws_api_gateway module - introduce 'unit' tests, improve imports using them and small fixes

* aws_api_gateway module - move path expand_user to avoid early typecheck

* aws_api_gateway - version means version of metadata not module - fix to 1.0

* aws_api_gateway module - Rely on module_utils.ec2 for imports & path type for expanduser / cleanups

* aws_api_gateway module - heavy cleanup and refactor of code + cloud retry functionality.

* api_gateway_module - failing test case for handling more than one deployment in succession and API deletion

* add TooManyRequestsException to AWSRetry exception list - makes API deployment work.

* api_gateway_module - Fixes for various review comments + errors from various linters

* api_gateway_module - Fixes for more review comments + linter error

* api_gateway_module - Major refactor into sensible functions - create_response becomes configure_response

* api_gateway_module - should be working under python3; remove test exclusion

* api_gateway_module - finish off remaining review fixes - use ansible defaults and fix mutually exclusive

* api_gateway_module - attempt to improve handling of botocore errors in python3

* api_gateway_module - implement state=absent / API deletion
2017-06-05 10:25:56 -04:00
Adrian Likins
087b5277f1 Make ServiceMgrFactCollector.is_systemd_managed() a static method (#25316)
Fix 'hostname' module Facts is not defined by updating
'hostname' module to use it.

is_systemd_managed() was previously on the module_utils.facts.Facts
class that no longer exists.

Fixes #25289
2017-06-05 09:39:05 -04:00
René Moser
53c46df323 cloudstack: new module cs_network_acl_rule (#25325)
* cloudstack: new module cs_network_acl_rule
* fix doc errors
2017-06-03 14:34:09 +02:00
Rene Moser
fd3c92504a ansible-doc: fix exception for required field 2017-06-03 14:32:05 +02:00
jhawkesworth
de8c7c22d2 Add 'exists' to win_stat return docs (#25146)
* Add 'exists' to win_stat return docs

Fix 25107 by adding documentation for 'exists' return value in win_stat module

* Added missing filename attribute to RETURN

Also made the path and filename sample values consistent.
2017-06-03 09:11:09 +01:00
René Moser
3e02b19b98 cloudstack: fix pep8 cs_project (#25322) 2017-06-03 01:42:03 +02:00
Brian Coca
4aeca601f4 corrected default inventory plugin order
default inventory plugin order now follows the hardcoded one in previous versions
yaml plugin shoudl run before ini to avoid ini being able to parse some yaml files succesfully.

fixes #25321
2017-06-02 18:47:07 -04:00
Sebastian Kornehl
5d0340a9e3 datadog_monitor: Idempotence fix (#19217)
* Added matching_downtimes to list of ignores values. Fixes: #19216

* Added overall_state_modified to list of ignores values. Fixes: #19216
2017-06-02 23:36:32 +02:00
Sloane Hertel
6ba040591c {cloud} module_utils/ec2.py: get AWS access and secret keys from boto config (#24783)
* Get AWS access and secret keys from boto config

* matching the elif pattern

* avoid setting credentials as empty strings by checking os.environ.get('cred')

put comments back

* remove None from os.environ.get()
2017-06-02 17:05:15 -04:00
Sloane Hertel
77008707f5 ensure port is an int (#25310) 2017-06-02 15:15:47 -04:00
Matt Martz
99a30f8fdb Python3 fix for hashing in inventory plugins 2017-06-02 13:45:50 -04:00
Will Thames
84eea2a7e3 Support check_mode in ec2_vpc_nacl (#23112)
* Support check_mode in ec2_vpc_nacl

Ensure that all API calls that make changes are guarded by
`if not module.check_mode`.

* Update ec2_vpc_nacl_facts to latest pep8 standards
2017-06-02 13:15:38 -04:00
Kassian Sun
42d57782c0 Try to fix travis 2017-06-02 10:10:34 -07:00
Kassian Sun
981249daa1 use single line for-loop 2017-06-02 10:10:34 -07:00
Kassian Sun
b3a37da671 Add --sysctl support for cloud/docker_container 2017-06-02 10:10:34 -07:00
Trishna Guha
e90f1d6449 net_command platform agnostic module (#25249)
* net_command platform agnostic implementation

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Add net_command platform agnostic module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* Add integration test for net_command module

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix yaml issue
2017-06-02 22:03:27 +05:30
Dag Wieers
8cbed3c534 unarchive: PEP8, imports, cosmetics (#24654)
- Make PEP8 compliant
- Ensure imports are specific
- Few cosmetic changes (sort lists, casing, punctuation)
2017-06-02 16:22:52 +01:00
Ricardo Carrillo Cruz
955dc6e250 Add net_banner platform agnostic module (#25245)
* Add net_banner platform agnostic module

* Add integration tests for net_banner

* Remove default from required param

* Remove skip/python3 from net_banner aliases
2017-06-02 17:01:08 +02:00
Bill Nottingham
d0cc980223 Fix handling of extra_vars_path parameter. (#25272)
tower-cli process_extra_vars takes a list.
2017-06-02 09:29:53 -04:00
Ricardo Carrillo Cruz
64add28657 Platform agnostic net_system module (#24953)
* Platform agnostic net_system module

Also refactor the action network plugins for better code re-use

Still more refactoring to do once the connection plugin work is complete

* Replace importlib for imp

importlib is not available on 2.6, so we need to stick to imp

* Load action plugin via module metadata

* Better error message if no implementation is found

Now the plugin will show the module name and the network OS in the
error message

* Fix typo on documentation author line

* Fix pep8 issues

* Add missing options key on doc string and stringify version

* Return None in case module has no metadata

* Read module metadata only if it's a python module

Check for module suffix, if it's .py then read metadata.
Otherwise this fails on non-python modules, like Windows PS for example.

* Read metadata variable only if it's a python module

Fix referencing a variable before assignment

* Add action_handler to validate_modules metadata schema

* Pull metadata with plugin_docs get_docstring

Using load_source from PluginLoader is troublesome, it is not guaranteed
a module may be importable at the controller, e.g. if a module depends
on module_utils functions it won't work, because module_utils is not
in the sys path.
Rather than putting that module dependencies introspection, just
use plain parsing like plugin_docs get_docstring does as we only care
about reading ANSIBLE_METADATA.

* Add platform agnostic group of groups for integration tests

This will be the target for platform agnostic integration tests.

* Add integration tests for net_system

* Switch to action plugin inheritance from metadata driven action handler

As the metadata action driven action handler work is being worked on
on its standalone proposal+PR, let's just go back to have one
action handler per platform agnostic module.
Those action plugins will inherit from net_base.

* Add blank line to fix pep8

* Add aliases file to net_system integration test

This will avoid CI failure

* Fix integration tests for net_system

* Give more precedence to task network_os over inventory network_os
2017-06-02 14:06:38 +02:00
Silvio Tomatis
2ee2c8c1ab [cloud] ec2_elb_lb module Python 3 fix for string types (#24925)
* Python 3 compatibility for ec2_elb_lb module

* Use string_types from ansible.module_utils.six for python2/3 compatibility
2017-06-02 07:40:56 -04:00
Brandon Davidson
0e0c5328fa amazon/ec2_vpc_igw: Allow internet gateways to be tagged (#23782) 2017-06-02 07:38:50 -04:00
Dag Wieers
5553b20828 Collated PEP8 fixes (#25293)
- Make PEP8 compliant
2017-06-02 12:14:11 +01:00
Dag Wieers
2f33c1a1a1 find: PEP8, imports, cosmetics (#24646)
- Make PEP8 compliant
- Ensure imports are specific
- Few cosmetic changes (sort lists, casing, punctuation)
2017-06-02 08:43:40 +01:00
Dag Wieers
91ee93ce13 patch: PEP8, imports, cosmetics (#24649)
- Make PEP8 compliant
- Ensure imports are specific
- Few cosmetic changes (sort lists, casing, punctuation)
2017-06-02 08:42:40 +01:00
Ganesh Nalawade
85219dfdf3 Add support to fetch old style junos facts (#25250)
* Add support to fetch old style junos facts

Fixes #25050

Add support to fetch old style facts supported in Ansible <= 2.2
To fetch old style facts value `gather_subset` value shoule be `all`
and `junos-eznc` is required to be installed on control node as a
prerequisite.

* Remove unwanted import
2017-06-02 09:04:57 +05:30
Dag Wieers
4847613725 win_timezone: Add RETURN information (#24571)
And cosmetic cleanup.

This fixes ansible/ansible-modules-extras#1767
2017-06-01 16:43:08 -07:00
Peter Oliver
d0d33262cb pkg5 with latest shouldn't ignore absent packages (#23006)
When the state is set to `latest` we should install absent packages, not just upgrade already-instaled packages.

This should fix #22823.
2017-06-02 01:10:24 +02:00
Rene Moser
ff35d23a27 adjust versions added 2017-06-02 00:38:23 +02:00
Sloane Hertel
7160a491c2 elasticache: add requirements to parameter_group and snapshot (#24904)
* Add requirements to elasticache parameter group

* add requirements for elasticache_snapshot

* pep8 elasticache_snapshot

* remove elasticache_snapshot from legacy files
2017-06-02 00:18:02 +02:00
Naoya Nakazawa
727b8c80be support host parameter to datadog_event module (#20914) 2017-06-02 00:15:00 +02:00
Evan Kaufman
b244397a31 Cron - Explicitly fail on Solaris when given a special_time (#24898)
* Added explicit failure on Solaris given a special_time

Fixes ansible/ansible#22145

* Using get_platform from module utils
2017-06-02 00:04:12 +02:00
Peter Oliver
ea56d18c99 Support check mode in pkg5 module. (#23008) 2017-06-01 23:59:07 +02:00
Thomas Krahn
f8a99fd745 ipa_role: Add support for privileges (#21149)
* ipa_role: Add support for privileges

* ipa_role: Add default vaule to module documentation
2017-06-01 23:51:23 +02:00
Trond Hindenes
055fd6f5f5 New module: win dsc (#24872)
* Added win_dsc module file

* mute output and track reboot requirements

* added tests

* proper conditionals for test

* Added moar conditionals for test

* ci fixes

* Added metadata

* fixed integration test yaml

* ci fix

* ci fix

* added module_version param and output, no longer chokes on multiple versions found.

* ci fix

* code review improvements, make return vars more pythonic, cleanup
removed reference to handles in commit message

* Fixed tests, clearer documentation

* fixed trailing whitespace
2017-06-01 14:50:12 -07:00
James Labocki
055cc32830 Fix indentation for register module in example (#25274) 2017-06-01 14:22:22 -07:00
Tim Rupp
eb83c6f4e7 Fixes documentation (#25273)
This plugin was released with 2.4 but mentions it supports 2.3.
This patch fixes that.
2017-06-01 21:01:01 +01:00
Fabrizio Colonna
f364d7af8e Fixes parted i18n issues (#24991)
* Fixed issue 24969

* Used C locale and global env update.
2017-06-01 15:27:27 -04:00
mechaxl
3c3e9c3b36 Fixing policy sorting for Python 3 2017-06-01 11:28:43 -07:00
MechaXL
c1f0260ae3 Convert basestring to string_types (#25228) 2017-06-01 10:24:33 -07:00
evancarter-iex
3a2699f1bf gce_instance_template: Fix subnetwork not working (#25231)
* Fix problem with subnetwork not working

It is broken in the current master branch. This fixes it.

* Fix missing version_added
2017-06-01 10:19:19 -07:00
Adrian Likins
45a9f96774 Facts Refresh (2.4 roadmap) (#23012)
Facts Refresh (2.4 roadmap)

This commit implements most of the 2.4 roadmap 'Facts Refresh'
- move facts.py to facts/__init__.py
- move facts Distribution() to its own class
- add a facts/utils.py
- move get_file_content and get_uname_version to facts/utils.py
- move Facts() class from facts/__init__ to facts/facts.py
- mv get_file_lines to facts/utils.py
- mv Ohai()/Facter() class to facts/ohai.py and facter.py
- Start moving fact Hardware() classes to facts/hardware/*.py
- mv HPUX() hardware class to facts/hardware/hpux.py
- move SunOSHardware() fact class to facts/hardware/sunos.py
- move OpenBSDHardware() class to facts/hardware/openbsd.py
- mv FreeBsdHardware() and DragonFlyHardware() to facts/hardware/
- mv NetBSDHardware() to facts/hardware/netbsd.py
- mv Darwin() hardware class to facts/hardware/darwin.py
- pep8/etc cleanups on facts/hardware/*.py
- Mv network facts classes to facts/network/*.py
- mv Virtual fact classes to facts/virtual
- mv Hardware.get_sysctl to facts/sysctl.py:get_sysctl

- Also mv get_uname_version from facts/utils.py -> distribution.py
  since distribution.py is the only thing using it.

- add collector.py with new BaseFactCollector
- add a subclass for AnsibleFactCollector
- hook up dict key munging FactNamespaces
- add some test cases for testing the names of facts
- mv timeout stuff to facts.timeout

- rm ansible_facts()/get_all_facts() etc

- Instead of calling facts.ansible_facts(), fact collection
  api used by setup.py is now to create an AnsibleFactCollector()
  and call it's collect method.

- replace Facts.get_user_facts with UserFactCollector
- add a 'systems' facts package, mv UserFactCollector there
- mv get_dns_facts to DnsFactCollector
- mv get_env_facts to EnvFactCollector
- include the timeout length in exception message

- modules and module_utils that use AnsibleFactCollector
  can now theoretically set the 'valid_subsets'

  May be useful for network facts module that currently have
  to reimplement a good chunk of facts.py to get gather_subsets
  to work.

- get_local_facts -> system/LocalFactCollector
- get_date_time -> system/date_time.py
- get_fips_facts -> system/fips.py
- get_caps_facts() -> system/caps.py
- get_apparmor_facts -> system/apparmor.py
- get_selinux_facts -> system/selinux.py
- get_lsb_facts -> system/lsb.py
- get_service_mgr_facts -> system/service_mgr.py
- Facts.is_systemd_managed ->  system/service_mgr.py
- get_pkg_mgr_facts -> system/pkg_mgr.py
- Facts()._get_mount_size_facts() -> facts.utils.get_mount_size()

- add unit test for EnvFactCollector
- add a test case for minimal gather_subsets
- add test case for collect_ids
- Make gather_subset match existing behavior or '!all'

    If 'gather_subset' is provided as '!all', the existing behavior
    (in 2.2/2.3) is that means 'dont collect any facts except those
    from the Facts() class'. So 'skip everything except
    'apparmor', 'caps', 'date_time', 'env', 'fips', 'local', 'lsb',
    'pkg_mgr', 'python', 'selinux', 'service_mgr', 'user', 'platform', etc.

    The new facts setup was making '!all' mean no facts at all, since
    it can add/exclude at a finer granularity. Since that makes more
    sense for the ansible collector, and the set of minimal facts to
    collect is really more up to setup.py to decide we do just that.

    So if setup.py needs to always collect some gather_subset, even
    on !all, setup.py needs to have the that subset added to the
    list it passes as minimal_gather_subset.

    This should fix some intg tests that assume '!all' means that
    some facts are still collected (user info and env for example).

    If we want to make setup.py collect a more minimal set, we can do that.

- force facts_dicts.keys() to a list so py3 works
- split fact collector tests to test_collectors.py

- convert Facter(Facts) -> other/facter.py:FacterFactCollector

- add FactCollector.collect_with_namespace()

    regular .collect() will return a dict with the key names
    using the base names ('ip_address', 'service_mgr' etc)

    .collect_with_namespace() will return a dict where the key names
    have been transformed with the collectors namespace, if there is
    one. For most, this means a namespace that adds 'ansible_' to the
    start of the key name.

    For 'FacterFactCollector', the namespace transforms the key to
    'facter_*'.

- add test cases for collect_with_namespace

- move all the concrete 'which facts does setup.py' stuff to setup.py

    The caller of AnsibleFactCollector.from_gather_subset() needs to
    pass in the list of collector classes now.

- update system/setup.py to import all of the fact classes and pass
  in that list.
- split the Distribution fact class up a bit

    extracted the 'distro release' file handling (ie, linux
    boxes with /etc/release, /etc/os-release etc) into its
    own class.
- extract get_cmdline_facts -> cmdline.py
- extract get_public_ssh_host_keys -> system/ssh_pub_keys.py
- extract get_platform_facts -> system/platform.py

  platform.py may be a good candidate for further splitting.

- rm test for plain Facts() base class
- let the base class for Collector unit tests provide collected_facts

    some Collectors and/or their migrated Facts() subsclasses need
    to look at facts collected by other modules ('ansible_architecture'
    the main one...).

    Collector.collect() has the collected_facts arg for this, so add
    a class variable to BaseFactsTest so we can specify it.

- mv Ohai to other/ohai.py and convert to Collector
- update hardware/*.py to return facts (no side effects)

- mv AnsibleFactCollector to setup.py
- extra collector class gathering to module method in
  facts/__init__.py (collector_classes_from_gather_subset)
- add a CollectorMetaDataCollector collector used to provide
  the 'gather_setup' fact
- add unit test module for 'setup' module
  (test/units/modules/system/setup.py)

- Collector init now doesnt need a module, but collect does

    An instance of a FactCollector() isnt tied to a AnsibleModule
    instance, but the collect() method can be, so optionally pass
    in module to FactCollector.collect() (everywhere)

- add a default_collectors for list of default collectors

  import and use it from setup.py module

  eventually, would like to replace this with a plugin loader
  style class finder/loader

- unit tests for module_utils/facts/__init__.py
- add unit tests for ohai facts collector
- remove self.facts side effect on populate() in hardware/sunos.py
- convert OpenBSDHardware() to rm side effects on self.facts
- try to rm some self.facts side effects in Network()

    plumb in collected_facts from populate() where it is needed.

    stop passing collected_facts into Network() [via cached_facts=,
    where it eventually becomes self.facts]

- nothing provides Fact() cached_facts arg now, rm it

    Facts() should be internal only implementation so nothing
    should be using it.

    Of course, now someone will.

- add a Collector.name attr to build a map of name->_fact_ids

    To properly exclude a gather_subset spec like '!hardware', we
    need to know that 'hardware' also means 'devices', 'dmi', etc.
    Before, '!hardware' would remove the 'hardware' collector name
    but not 'devices'. Since both would end up in id_collector_map,
    we would still end up with the HardwareCollector in the collector
    list. End result being that '!hardware' wouldn't stop hardware
    from being collected.

    So we need to be able to build that map, so add the Collector.name
    attribute that is the primary name (like 'hardware') and let
    Collector._fact_ids be the other fact ids that a collector is
    responsible for.

    Construct the aliases_map of Collector.name -> set of _fact_ids
    in fact/__init__.py get_collector_names, and use it when we are
    populating the exclude set.

- refactor of distribution.py

    make the big OS_FAMILY literal a little easier to read
    Also keys can now be any string instead of python literals

    99% sure the test for 'KDE Neon' was wrong
    I don't see how/where it should or could get 'Neon' instead
    of 'KDE Neon' as provided in os-release NAME=

    Use 'distribution' string for key to OS_MAP

    ie, we dont need to make it a valid python label anymore so dont.

    move _has_dist_file to module as _file_exists
    easier to mock without mucking with os.path

    mv platform.system() calls to within get_distribution_facts() instead
    of Distribution() init.

- remove _json compat module

    The code in here was to support:

      -a 'json' python module that was not the standard one included
      with python since 2.6.

      - potentially fallback to simplejson if 'json' was not available.

    'json' is available for all supported python versions now so
    no longer needed.

- mv get_collector_names -> facts.collector
- mv collector_classes_from_gather_subset -> facts.collector
- mv collector tests from test_facts -> test_collector

- Use six's reduce() in sunos/netbsd hardware facts

- rm extraneous get_uname_version in utils

  only system/distribution.py uses it

- Remove Facts() subclass metaclass usage

  - using fact_id and a platform id for matching collectors

    gut most of Facts() subclasses

    rm Facts() subclasses with weird metaclass

    only add collectors that match the fact_ids and the platform_info
    to the list of collectors used.

    atm, a collectors platform_id will default to 'Generic', and
    any platform matches 'Generic'

    goal is to select collector classes including matching the
    systems platform in collector.py, instead of relying on
    metaclasses in hardware/*. To finish this, the various
    Facts() subclasses will need to be replaced entirely with
    Collector() subclasses.

    use collector classmethod platform_match() to match the platform

    This lets the particular class decide if it is compatible with
    a given platform_info. platform_info is a dict like obj, so it could be
    expanded in the future.

    Add a default platform_match to BaseFactCollector that matches
    platform_info['system'] == cls._platform

    They were needed previously to trigger a module
    load on all the collector classes when we import
    facts/hardare so that the Hardware() and related
    classes that used __new__ and find_all_subclasses()
    would work.

    Now that is done in collectors based on platform matching
    at runtime we dont need to do it py module import/parse
    time. So the non empty __init__.pys are no longer needed
    and their is a more flexible mechanism for selection
    platform specific stuff.

    facts/facts.py is no longer used, rm'ed

- if we dont find an implement class for gather spec.. just ignore it.

  Would be useful to add a warn to warn about this case.

- Fix SD-UX typo (should be HP-UX)

- Port fix for #21893 (0 sockets) to this branch

    This readds the change from 8ad182059d
    that got lost in merge/rebase

    Fixes #21893

- port sunos fact locale fix for #24542 to this branch

    based on e558ec19cd

    Fixes #24542

    Solaris fact fix (#24793)

    ensure locale for solaris fact gathering

    fixes issue with locale interfering with proper reading of decimals

- raise exceptions in the air like we just dont care.

    Pretty much ignore any not exit exception in facts
    collection. And add some test cases.

- added new selinux fact to clarify python lib

    the selinux fact is boolean false when the library is not installed,
    a dictionary/hash otherwise, but this is ambigous
    added new fact so we can eventually remove the type dichtomy and normalize it as a dict

    Re-add of devel commit 85c7a7b844 to
    the new code layout, since it got removed in merge/rebase
2017-06-01 11:17:49 -04:00
Will Thames
3ca006ecbb Allow removal of target groups from ASGs (#25126)
An empty `target_group_arns` list represents no target groups.
This is different to not passing a `target_group_arns` list at all
which can signify no change.

Remove unnecessary empty list construction, as it must already be
an empty list to get to that point.
2017-06-01 08:53:31 -04:00
Abhijeet Kasurde
07be5f2b67 spelling fixes (non-trivial, changing messages) (#25094)
Multiple spell fixes in single commit.
Taking over existing PR as per comment -
https://github.com/ansible/ansible/pull/23645#issuecomment-304312275

Original Author: klemens <ka7@github.com>

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2017-06-01 10:45:19 +01:00
Trishna Guha
343b83041e nxos_feature fix and unit test (#25200)
* nxos_feature fix

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* nxos_feature unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* remove from pep8/legacy-file

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-06-01 08:58:35 +05:30
Trishna Guha
fb87680046 fix state present nxos_evpn_vni (#25212)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
2017-06-01 08:57:17 +05:30
Brian Coca
ea8c9a9b73 minor doc update 2017-05-31 19:39:30 -04:00
Brian Coca
16cc07a016 made doc more tolerant and recursive for spec 2017-05-31 19:38:20 -04:00
Chen Zhiwei
a44d57bf91 Allow customize fail message of wait_for module 2017-05-31 19:38:44 -04:00
Łukasz Jendrysik
bdd5adf21e Fix module name in example
'sv' module name in example refers to non-existent module.
2017-05-31 17:53:58 -04:00
Aurimas Lapiene
10167d83ee Add Cloudlinux support for hostname.py
**SUMMARY**

Add Cloudlinux 6 and Cloudlinux 7 support

**ISSUE TYPE**

Feature Pull Request

**COMPONENT NAME**

lib/ansible/modules/system/hostname.py

**ANSIBLE VERSION**
```
2.4
```
2017-05-31 17:01:22 -04:00
Esteban Echeverry
b7662f7e5b Import from urllib and not url (#25102)
* Import from urllib and not url

In Python 3, the correct way to import
urlparse is through urllib.parse.

* Use six module to import urlparse

Import urlparse from ansible.module_utils.six.
This way, the import statement is compatible both
with Python 3 and Python 2.

* Fix urlparse import using six module

The correct import is:
from six.moves.urllib.parse import urlparse

* Import six from ansible.compat

* Import from six.moves. Don't make six global.

Prevent code smell by not making six available
in the global namespace and instead importing from
one of its subpackages.
2017-05-31 15:27:22 -04:00
piotrsmolinski
c3ffc49914 reset_connection fixes: #23621 (#25211)
* moved the logging statement

moved the logging statement before the actual action

* added status code check

In the existing implementation when the ssh command fails the command
result is silently discarded. It hides the fact that the disconnection
did not go as expected. Effectively the intended action was not
successful, but the play continues.

* Revert "added status code check"

This reverts commit fe2eb2ae4a.

* added command status code check

In the existing implementation the command is checked for the success.
As a result failed execution is silently discarded. The change tests for
return code and fails if it did not work.
2017-05-31 13:40:57 -04:00
Dag Wieers
c13b1a718a plugins/terminal/: PEP8 compliancy (#25207)
- Make PEP8 compliant
2017-05-31 18:28:03 +01:00
Brian Coca
caf5868ec9 removed debugging prints 2017-05-31 13:08:50 -04:00
Brian Coca
798d05ea41 corrected object with columns 2017-05-31 13:03:10 -04:00
Brian Coca
5667603a27 fixed format 2017-05-31 12:52:44 -04:00
Brian Coca
05caa3654c fix to alwasy use param in case subpec is used 2017-05-31 12:39:47 -04:00
Philippe Dellaert
3ae69302a2 Fixes ansible/ansible#25096 (#25098) 2017-05-31 12:37:12 -04:00
Senthil Kumar Ganesan
e0db5d23cc Update facts module to support the new OS10 10.3 release (#25090)
* Update facts module to support the new OS10 10.3 release

* Address PEP8 issues reported by ansibot
2017-05-31 17:09:10 +01:00
Brian Coca
62a434141e ensure display is terminal sensistive
fixes #18248 by using display width intead of hardcoded length
2017-05-31 11:15:45 -04:00
Yap Sok Ann
24cfb10ce9 gce_net: change default to match with b7e78656 for idempotency (#23555)
After b7e78656, if `src_range`, `src_tags` or `target_tags` is left as
null, the firewall rule would always be recreated.
2017-05-31 11:02:22 -04:00
Yury V. Zaytsev
c559567f16 [cloud] s3_bucket: fix connections for buckets with dots in names (#24720)
Refer to 689f135 for similar fix in s3 module. This change makes `OrdinaryCallingFormat` default for handling S3 connections. 

Signed-off-by: Yury V. Zaytsev <yury.zaytsev@moneymeets.com>
2017-05-31 10:36:17 -04:00
Will Thames
bc24ae88a8 Allow iam_role to work with friendly policy names (#22630)
Basically obtain all the policies and create a mapping
from friendly name to ARN

Tidy up module argument specification to remove unneeded
settings.
2017-05-31 10:15:13 -04:00
Rob
2f0ce790d1 [cloud] New module to support ALB/ELBv2 elb_target_group (#19492)
* New module = elb_target_group

* Update elb_target_group.py

Adds support for adding and removing targets from a target group

* Better error handling

* Bump version_added

* Minor fixes

* Scope ec2 imports, add better doco, fix up examples, allow for both upper and lower case in protocol

* Yaml fixes

* ci fix

* Added targets parameter to doc and added new modify_targets flag to prevent runs from modifying targets

* Update to metadata_version

* Update to metadata support

* Remove defaults for some params. Add tags parameter

* Use paginator to get target groups

* Add tag support

* Add tg attributes to module

* Quote multilines

* Remove unnecessary defaults. Fix multiline

* Fix line ending
2017-05-31 10:09:20 -04:00
Rob
76e56bf48e [cloud] New module = elb_application_lb (#19491)
* New module = elb_application_lb

* Update elb_application_lb.py

Adds support for rules, adds wait option for ALB creation, adds support for using target group names instead of ARNs when referencing target groups in rules. All additional features should be idempotent.

* Better exception error messages. Bump version_added. Pep8 fixes

* Add missing full stop to description

* Review changes and fixes

* Fix pep issues

* Fix up examples

* Fix pep8

* half way through sorting elb attributes

* Add access logs enabled param

* Finish implementing elb attributes

* Use paginator to get elbs

* Dont snake_case the tags

* Add listeners to return output and fixed up examples

* review changes

* fix line lengths

* pep8 fixes
2017-05-31 09:29:49 -04:00
Sloane Hertel
b04cf04f59 Prior to 2.4 only one source is permitted for ec2_group rules/rules_egress. 2.4 and after a list of sources is accepted. (#25165) 2017-05-31 08:51:33 -04:00
Will Thames
5c1a914002 Fix ec2_asg exception handling (#25121)
`e.message` is a string, and `camel_dict_to_snake_dict` fails when
given a string. The intended code is to run `camel_dict_to_snake_dict`
on `e.response`, the result of which includes a `message` key.

Make exception handling lines more consistent and wrap for slightly
shorter lines.
2017-05-31 08:50:32 -04:00
Dag Wieers
d958440bcb win_firewall_rule: Implement idempotency, check-mode and diff support (#23162)
* win_firewall_rule: Small idempotency fix

This PR includes the following changes:
- an idempotency fix when `profile: any`
- better difference output to debug idempotency issues
- documentation fixes (remove `required: false`)
- Parameter handling fixes
- RDP example that matches default RDP rule
- Renamed parameter 'enable' to 'enabled' (kept alias)
- Renamed parameter 'profile' to 'profiles' (kept alias)

* Rewrite module completely

The logic is still intact, but various changes with a single goal:

- Make the module idempotent
- Implement check-mode
- Implement diff-mode
- Adapted integration tests

This fixes #18807 and #23455.

* Change casing to lowercase

* Improve the logic wrt. diff
2017-05-30 16:10:33 -07:00
Dag Wieers
0e160d5c7e Ensure exit_json returns failed = False
This is required for modules that may return a non-zero `rc` value for a
successful run, similar to #24865 for Windows fixing **win_chocolatey**.

We also disable the dependency on `rc` value only, even if `failed` was
set.

Adapted unit and integration tests to the new scheme.
Updated raw, shell, script, expect to take `rc` into account.
2017-05-30 14:56:31 -07:00
Evgeni Golov
1f78715848 apt: include arch in check for installed packages on multi-arch systems (#24846)
* apt: include arch in check for installed packages on multi-arch systems

Thanks: Stefan Löwen <stefan.loewen@gmail.com>

Fixes: #24673

* add an integration test for apt's multi-arch handling
2017-05-30 16:09:43 -04:00
Benjamin Curtis
16c2207d21 Fix return code (#23592)
The Honeybadger API returns 201 for success, not 200.
2017-05-30 22:01:42 +02:00
Will Thames
23324bdda0 Ensure when warning is checked before expanding (#25092)
The `when` condition templating warning should only happen
if the condition itself contains templating, not if variables
in the condition are themselves composed through templating

Before

```
vars:
  x: hello
  y: "{{ x }}"

tasks:
- debug: msg=hello
  when: y
```

would fire a warning because `y` would get expanded to `{{ x }}`.
This checks whether a warning is required prior to expansion.
2017-05-30 15:48:45 -04:00
Nathaniel Case
53837c2ab0 Assorted nxos_bgp_* fixes (#25080)
* Simplify apply_key_map

* Fix nxapi

* Clean up get_value

* Fix missing non-values

* Add test for existing bgp_af case

* Fix small issues with bgp_neighbor_af
2017-05-30 14:11:15 -04:00
Pierre-Louis Bonicoli
69edd9e0bb Avoid useless queries: use standard module hashlib
When an unchanged MD5-hashed password was used and passlib was
unavailable, an useless 'ALTER USER' query was executed.

Once this useless query avoided, the last 'SELECT' query becomes
useless too.
2017-05-30 10:55:49 -07:00
Pierre-Louis Bonicoli
f59f042bb0 postgresql_user: fix doc
See: https://www.postgresql.org/docs/current/static/sql-createrole.html
2017-05-30 10:55:49 -07:00
Dag Wieers
09ba70f7c4 stat: PEP8, imports, cosmetics (#24653)
- Make PEP8 compliant
- Ensure imports are specific
- Few cosmetic changes (sort lists, casing, punctuation)
2017-05-30 18:31:56 +01:00
Dag Wieers
8d962209f4 mod_utils/cloudengine: PEP8 compliancy (#24659)
- Make PEP8 compliant
2017-05-30 18:28:02 +01:00
Dag Wieers
b3b11fbce2 get_url: PEP8, imports, cosmetics (#24676)
- Make PEP8 compliant
- Ensure imports are specific
- Few cosmetic changes (sort lists, casing, punctuation)
2017-05-30 18:24:07 +01:00
Dag Wieers
630185cb20 ansible/executor: PEP8 compliancy (#24695)
- Make PEP8 compliant
2017-05-30 18:13:53 +01:00