Conjur Lookup Plugin (#34280)

* Imported lookup plugin from Role

* Plugin cleanup, including:
* Use existing Python YAML parsing
* Remove environment variables as connection options
* Added initial debugging information

* Reworked the lookup plugin using the Python Request library.  As it's available through Ansible, it makes communication with Conjur much more straight forward.

* Removed un-used libraries

* Fixed linting issues

* Standardized output on `format` and insure it works for 2.6, 2.7, and 3.x.

* Use quote_plus from the six library for improved python 2/3 behavior.

* Refactored identity & configuration to prefer user's file. This also includes a refactor to remove an un-needed dictionary merge method.

* Removed `requests` in favor of `ansible.module_utils.urls`.

* Refactored netrc loading to warn if host is not present.

* Tests and a refactor to support easier testing.

* Added reference to website

* Fixed two linting errors

* Fixed an extra line found by linting

* Updated file write to use binary to insure config files are written correctly

* Resolved linting issues

* Refactored config & identity loading to take advantage of plugin options

* Cleanup a bunch of small items caught by linting

* Removed extra line caught by linting

* Swapped in pytest and added some tests with mocked network responses

* Pushing to see if this approach works better...

* Refactored be open_url mocking based on feedback

* Fixed a couple linting issues & refactored mocking into each method to attempt to resolve a failing test

* Use a generic MagicMock for python 2.6

* Fixes doc typo

require -> required

* Use `type: path` in identity_file and config_file

Also removes `expanduser` calls below (which will now be called automatically on
paths.)

* Defines maintainers for conjur_variable plugin

* BOTMETA.yml:
** defines $team_cyberark_conjur as maintainers of Conjur Variable plugin
** adds myself and @jvanderhoof to that team

* Adds URLs to relevant documentation for Conjur Variable lookup plugin

* Clarifies "the server," "the machine" -> "controlling host"

The machine identity used is that of the Ansible controlling host, not any
server being provisioned or instructed. This documentation change aims to make
that relationship clear.

* Adds response code to exception message on authentication failure

* Enhances exception messages to specify the controlling host

These error messages are less likely to confuse a user as to which machine is
associated with the files, identities, and configurations being described.

* Adds ANSIBLE_METADATA for Conjur variable lookup plugin
This commit is contained in:
Jason Vanderhoof
2018-01-23 09:04:57 -07:00
committed by Matt Martz
parent 9c9e692165
commit 7c8e365dff
3 changed files with 280 additions and 0 deletions

3
.github/BOTMETA.yml vendored
View File

@@ -1147,6 +1147,8 @@ files:
lib/ansible/plugins/lookup/dig:
maintainers: jpmens
labels: community
lib/ansible/plugins/lookup/conjur_variable.py:
maintainers: $team_cyberark_conjur
lib/ansible/plugins/netconf/:
maintainers: $team_networking
labels: networking
@@ -1233,6 +1235,7 @@ macros:
team_avi: ericsysmin grastogi23 khaltore
team_azure: haroldwongms nitzmahone trstringer yuwzho xscript zikalino
team_cumulus: isharacomix jrrivers privateip
team_cyberark_conjur: jvanderhoof ryanprior
team_manageiq: gtanzillo abellotti zgalor yaacov cben
team_netapp: hulquest lmprice broncofan gouthampacha
team_netscaler: chiradeep giorgos-nikolopoulos