-
Notifications
You must be signed in to change notification settings - Fork 29
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,2 +1,23 @@ | ||
# ansible-compat | ||
A python package containing functions that help interacting with various versions of Ansible | ||
|
||
A python package contains functions that facilitates working with various | ||
versions of Ansible, 2.9 and newer. | ||
|
||
## Access to Ansible configuration | ||
|
||
As you may not want to parse `ansible-config dump` yourself, you | ||
can make use of a simple python class that facilitates access to | ||
it, using python data types. | ||
|
||
```python | ||
from ansible_compat.config import AnsibleConfig | ||
|
||
|
||
def test_example_config(): | ||
cfg = AnsibleConfig() | ||
assert isinstance(cfg.ACTION_WARNINGS, bool) | ||
# you can also use lowercase: | ||
assert isinstance(cfg.action_warnings, bool) | ||
# you can also use it as dictionary | ||
assert cfg['action_warnings'] == cfg.action_warnings | ||
``` |
This file contains hidden or 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 |
---|---|---|
|
@@ -69,6 +69,8 @@ test = | |
flaky | ||
pytest | ||
pytest-cov | ||
pytest-markdown | ||
pytest-plus | ||
|
||
[options.packages.find] | ||
where = src | ||
|
This file contains hidden or 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 hidden or 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,22 @@ | ||
"""Tests for ansible_compat.config submodule.""" | ||
import pytest | ||
|
||
import ansible_compat | ||
|
||
|
||
def test_config() -> None: | ||
"""Checks that config vars are loaded with their expected type.""" | ||
config = ansible_compat.config.AnsibleConfig() | ||
assert isinstance(config.ACTION_WARNINGS, bool) | ||
assert isinstance(config.CACHE_PLUGIN_PREFIX, str) | ||
assert isinstance(config.CONNECTION_FACTS_MODULES, dict) | ||
assert config.ANSIBLE_COW_PATH is None | ||
assert isinstance(config.NETWORK_GROUP_MODULES, list) | ||
assert isinstance(config.DEFAULT_GATHER_TIMEOUT, int) | ||
|
||
# check lowercase and older name aliasing | ||
assert isinstance(config.collections_paths, list) | ||
assert isinstance(config.collections_path, list) | ||
|
||
with pytest.raises(AttributeError): | ||
print(config.THIS_DOES_NOT_EXIST) |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add class for accessing Ansible configuration #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
8000 Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Add class for accessing Ansible configuration #10
Changes from all commits
e738fb3
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.