mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
Added new feature for ansible_user and ansible_port in Icinga2 inventory source (#4088)
* Added new feature for ansible_user and ansible_port * Replaced 'try' and 'except' with 'if' condition * Replace '!=' with 'is not' * Fixed if condition * Implement the constructed interface * Correction at the suggestion of felixfontein * Added new options in unit test for icinga2 inventory * Added blank lines in unit test for icinga2 inventory * Added default filter in example Co-authored-by: Felix Fontein <felix@fontein.de> * Fixed variable name in example Co-authored-by: Felix Fontein <felix@fontein.de> * Added a changelog fragment * Fixed changelog fragment Co-authored-by: Felix Fontein <felix@fontein.de> * Updated documentation options Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
5710faab64
commit
969ad475e3
3 changed files with 51 additions and 1 deletions
|
@ -76,6 +76,19 @@ def query_hosts(hosts=None, attrs=None, joins=None, host_filter=None):
|
|||
return json_host_data
|
||||
|
||||
|
||||
def get_option(option):
|
||||
if option == 'groups':
|
||||
return {}
|
||||
elif option == 'keyed_groups':
|
||||
return []
|
||||
elif option == 'compose':
|
||||
return {}
|
||||
elif option == 'strict':
|
||||
return False
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def test_populate(inventory, mocker):
|
||||
# module settings
|
||||
inventory.icinga2_user = 'ansible'
|
||||
|
@ -86,6 +99,7 @@ def test_populate(inventory, mocker):
|
|||
# bypass authentication and API fetch calls
|
||||
inventory._check_api = mocker.MagicMock(side_effect=check_api)
|
||||
inventory._query_hosts = mocker.MagicMock(side_effect=query_hosts)
|
||||
inventory.get_option = mocker.MagicMock(side_effect=get_option)
|
||||
inventory._populate()
|
||||
|
||||
# get different hosts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue