-
Notifications
You must be signed in to change notification settings - Fork 23.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make the module_utils path configurable * Add a config value to define the path site module_utils files * Handle module_utils that do not have source as an error * Make an integration test for module_utils envvar working * Add documentation for the ANSIBLE_MODULE_UTILS config option/envvar * Add it to the sample ansible.cfg * Add it to intro_configuration. * Also modify intro_configuration to place envvars on equal footing with the config options (will need to document the envvar names in the future) * Also add the ANSIBLE_LIBRARY use case from #15432 so we can close out that bug.
- Loading branch information
Showing
22 changed files
with
145 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/integration/targets/module_utils/library/test_env_override.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/python | ||
from ansible.module_utils.basic import AnsibleModule | ||
from ansible.module_utils.json_utils import data | ||
from ansible.module_utils.mork import data as mork_data | ||
|
||
results = {"json_utils": data, "mork": mork_data} | ||
|
||
AnsibleModule(argument_spec=dict()).exit_json(**results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sysv_is_enabled = 'sysv_is_enabled' |
51 changes: 51 additions & 0 deletions
51
test/integration/targets/module_utils/module_utils_envvar.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
- hosts: localhost | ||
gather_facts: no | ||
tasks: | ||
- name: Use a specially crafted module to see if things were imported correctly | ||
test: | ||
register: result | ||
|
||
- name: Check that these are all loaded from playbook dir's module_utils | ||
assert: | ||
that: | ||
- 'result["abcdefgh"] == "abcdefgh"' | ||
- 'result["bar0"] == "bar0"' | ||
- 'result["bar1"] == "bar1"' | ||
- 'result["bar2"] == "bar2"' | ||
- 'result["baz1"] == "baz1"' | ||
- 'result["baz2"] == "baz2"' | ||
- 'result["foo0"] == "foo0"' | ||
- 'result["foo1"] == "foo1"' | ||
- 'result["foo2"] == "foo2"' | ||
- 'result["qux1"] == "qux1"' | ||
- 'result["qux2"] == ["qux2:quux", "qux2:quuz"]' | ||
- 'result["spam1"] == "spam1"' | ||
- 'result["spam2"] == "spam2"' | ||
- 'result["spam3"] == "spam3"' | ||
- 'result["spam4"] == "spam4"' | ||
- 'result["spam5"] == ["spam5:bacon", "spam5:eggs"]' | ||
- 'result["spam6"] == ["spam6:bacon", "spam6:eggs"]' | ||
- 'result["spam7"] == ["spam7:bacon", "spam7:eggs"]' | ||
- 'result["spam8"] == ["spam8:bacon", "spam8:eggs"]' | ||
|
||
# Test that overriding something in module_utils with something in the local library works | ||
- name: Test that playbook dir's module_utils overrides facts.py | ||
test_override: | ||
register: result | ||
|
||
- name: Make sure the we used the local facts.py, not the one shipped with ansible | ||
assert: | ||
that: | ||
- 'result["data"] == "overridden facts.py"' | ||
|
||
- name: Test that importing something from the module_utils in the env_vars works | ||
test_env_override: | ||
register: result | ||
|
||
- name: Make sure we used the module_utils from the env_var for these | ||
assert: | ||
that: | ||
# Override of shipped module_utils | ||
- 'result["json_utils"] == "overridden json_utils"' | ||
# Only i nthe env vars directory | ||
- 'result["mork"] == "mork"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
test/integration/targets/module_utils/other_mu_dir/a/b/c/d/e/f/g/h/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data = 'should not be visible abcdefgh' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data = 'should not be visible facts.py' |
1 change: 1 addition & 0 deletions
1
test/integration/targets/module_utils/other_mu_dir/json_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data = 'overridden json_utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
data = 'mork' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters