id
int64 0
458k
| file_name
stringlengths 4
119
| file_path
stringlengths 14
227
| content
stringlengths 24
9.96M
| size
int64 24
9.96M
| language
stringclasses 1
value | extension
stringclasses 14
values | total_lines
int64 1
219k
| avg_line_length
float64 2.52
4.63M
| max_line_length
int64 5
9.91M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 7
101
| repo_stars
int64 100
139k
| repo_forks
int64 0
26.4k
| repo_open_issues
int64 0
2.27k
| repo_license
stringclasses 12
values | repo_extraction_date
stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13,500
|
mytests2.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests2.py
|
from __future__ import annotations
def testtest(data):
return data == 'from_user2'
class TestModule(object):
def tests(self):
return {
'testtest2': testtest
}
| 199
|
Python
|
.py
| 8
| 18.875
| 34
| 0.625668
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,501
|
mytests.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests.py
|
from __future__ import annotations
def testtest(data):
return data == 'from_user'
class TestModule(object):
def tests(self):
return {
'testtest': testtest
}
| 197
|
Python
|
.py
| 8
| 18.625
| 34
| 0.621622
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,502
|
my_subdir_tests.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/test_subdir/my_subdir_tests.py
|
from __future__ import annotations
def subdir_test(data):
return data == 'subdir_from_user'
class TestModule(object):
def tests(self):
return {
'subdir_test': subdir_test
}
| 213
|
Python
|
.py
| 8
| 20.625
| 38
| 0.631841
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,503
|
custom_vars.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/vars/custom_vars.py
|
# Copyright 2019 RedHat, inc
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#############################################
from __future__ import annotations
DOCUMENTATION = """
vars: custom_vars
version_added: "2.10"
short_description: load host and group vars
description: test loading host and group vars from a collection
options:
stage:
choices: ['all', 'inventory', 'task']
type: str
ini:
- key: stage
section: custom_vars
env:
- name: ANSIBLE_VARS_PLUGIN_STAGE
"""
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
# Vars plugins in collections are only loaded when they are enabled by the user.
# If a vars plugin sets REQUIRES_ENABLED = False, a warning should occur (assuming it is loaded).
REQUIRES_ENABLED = False
def get_vars(self, loader, path, entities, cache=True):
super(VarsModule, self).get_vars(loader, path, entities)
return {'collection': 'collection_root_user'}
| 1,651
|
Python
|
.py
| 41
| 36.146341
| 101
| 0.700748
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,504
|
uses_redirected_import.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/uses_redirected_import.py
|
from __future__ import annotations
from ansible.plugins.action import ActionBase
from ansible.module_utils.formerly_core import thingtocall
class ActionModule(ActionBase):
TRANSFERS_FILES = False
_VALID_ARGS = frozenset()
def run(self, tmp=None, task_vars=None):
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(None, task_vars)
result = dict(changed=False, ttc_res=thingtocall())
return result
| 489
|
Python
|
.py
| 12
| 34.5
| 63
| 0.706383
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,505
|
subclassed_normal.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/subclassed_normal.py
|
from __future__ import annotations
from ansible.plugins.action.normal import ActionModule as NormalAction
class ActionModule(NormalAction):
def run(self, *args, **kwargs):
result = super(ActionModule, self).run(*args, **kwargs)
result['hacked'] = 'I got run under a subclassed normal, yay'
return result
| 335
|
Python
|
.py
| 7
| 42.428571
| 70
| 0.72
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,506
|
bypass_host_loop.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/bypass_host_loop.py
|
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
BYPASS_HOST_LOOP = True
def run(self, tmp=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars)
result['bypass_inventory_hostname'] = task_vars['inventory_hostname']
return result
| 487
|
Python
|
.py
| 10
| 43.9
| 92
| 0.730361
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,507
|
plugin_lookup.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py
|
from __future__ import annotations
from ansible.plugins.action import ActionBase
from ansible.plugins import loader
class ActionModule(ActionBase):
TRANSFERS_FILES = False
_VALID_ARGS = frozenset(('type', 'name'))
def run(self, tmp=None, task_vars=None):
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(None, task_vars)
plugin_type = self._task.args.get('type')
name = self._task.args.get('name')
result = dict(changed=False, collection_list=self._task.collections)
if all([plugin_type, name]):
attr_name = '{0}_loader'.format(plugin_type)
typed_loader = getattr(loader, attr_name, None)
if not typed_loader:
return (dict(failed=True, msg='invalid plugin type {0}'.format(plugin_type)))
context = typed_loader.find_plugin_with_context(name, collection_list=self._task.collections)
if not context.resolved:
result['plugin_path'] = None
result['redirect_list'] = []
else:
result['plugin_path'] = context.plugin_resolved_path
result['redirect_list'] = context.redirect_list
return result
| 1,262
|
Python
|
.py
| 26
| 38.115385
| 105
| 0.623058
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,508
|
subdir_ping_action.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/action_subdir/subdir_ping_action.py
|
from __future__ import annotations
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
TRANSFERS_FILES = False
_VALID_ARGS = frozenset()
def run(self, tmp=None, task_vars=None):
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(None, task_vars)
result = dict(changed=False)
return result
| 407
|
Python
|
.py
| 11
| 30.272727
| 63
| 0.678663
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,509
|
localconn.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/connection/localconn.py
|
from __future__ import annotations
from ansible.module_utils.common.text.converters import to_native
from ansible.plugins.connection import ConnectionBase
DOCUMENTATION = """
connection: localconn
short_description: do stuff local
description:
- does stuff
options:
connectionvar:
description:
- something we set
default: the_default
vars:
- name: ansible_localconn_connectionvar
"""
class Connection(ConnectionBase):
transport = 'local'
has_pipelining = True
def _connect(self):
return self
def exec_command(self, cmd, in_data=None, sudoable=True):
stdout = 'localconn ran {0}'.format(to_native(cmd))
stderr = 'connectionvar is {0}'.format(to_native(self.get_option('connectionvar')))
return (0, stdout, stderr)
def put_file(self, in_path, out_path):
raise NotImplementedError('just a test')
def fetch_file(self, in_path, out_path):
raise NotImplementedError('just a test')
def close(self):
self._connected = False
| 1,087
|
Python
|
.py
| 31
| 28.548387
| 91
| 0.674308
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,510
|
uses_nested_same_as_func.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_func.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
from ansible_collections.testns.testcoll.plugins.module_utils.nested_same.nested_same.nested_same import nested_same
def main():
mu_result = nested_same()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result)))
sys.exit()
if __name__ == '__main__':
main()
| 374
|
Python
|
.py
| 11
| 30.909091
| 116
| 0.730337
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,511
|
uses_leaf_mu_flat_import.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_flat_import.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
import ansible_collections.testns.testcoll.plugins.module_utils.leaf
def main():
mu_result = ansible_collections.testns.testcoll.plugins.module_utils.leaf.thingtocall()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result)))
sys.exit()
if __name__ == '__main__':
main()
| 388
|
Python
|
.py
| 11
| 32.181818
| 91
| 0.743243
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,512
|
win_selfcontained.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/win_selfcontained.py
|
# docs for Windows module would go here; just ensure we don't accidentally load this instead of the .ps1
| 105
|
Python
|
.py
| 1
| 104
| 104
| 0.788462
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,513
|
uses_mu_missing_redirect_collection.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_collection.py
|
#!/usr/bin/python
from __future__ import annotations
from ..module_utils import missing_redirect_target_collection # pylint: disable=relative-beyond-top-level,unused-import
def main():
raise Exception('should never get here')
if __name__ == '__main__':
main()
| 274
|
Python
|
.py
| 7
| 36.285714
| 120
| 0.729008
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,514
|
uses_collection_redirected_mu.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_collection_redirected_mu.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
from ansible_collections.testns.testcoll.plugins.module_utils.moved_out_root import importme
from ..module_utils.formerly_testcoll_pkg import thing as movedthing # pylint: disable=relative-beyond-top-level
from ..module_utils.formerly_testcoll_pkg.submod import thing as submodmovedthing # pylint: disable=relative-beyond-top-level
def main():
mu_result = importme()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result, mu_result2=movedthing, mu_result3=submodmovedthing)))
sys.exit()
if __name__ == '__main__':
main()
| 640
|
Python
|
.py
| 13
| 46.461538
| 130
| 0.770968
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,515
|
ping.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/ping.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='user')))
if __name__ == '__main__':
main()
| 178
|
Python
|
.py
| 7
| 22.571429
| 57
| 0.662651
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,516
|
uses_leaf_mu_module_import_from.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_module_import_from.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
from ansible_collections.testns.testcoll.plugins.module_utils import leaf, secondary
# FIXME: this one needs pkginit synthesis to work
# from ansible_collections.testns.testcoll.plugins.module_utils.subpkg import submod
from ansible_collections.testns.testcoll.plugins.module_utils.subpkg_with_init import (thingtocall as spwi_thingtocall,
submod_thingtocall as spwi_submod_thingtocall,
cousin_submod_thingtocall as spwi_cousin_submod_thingtocall)
def main():
mu_result = leaf.thingtocall()
mu2_result = secondary.thingtocall()
mu3_result = "thingtocall in subpkg.submod" # FIXME: this one needs pkginit synthesis to work
# mu3_result = submod.thingtocall()
mu4_result = spwi_thingtocall()
mu5_result = spwi_submod_thingtocall()
mu6_result = spwi_cousin_submod_thingtocall()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result, mu2_result=mu2_result,
mu3_result=mu3_result, mu4_result=mu4_result, mu5_result=mu5_result, mu6_result=mu6_result)))
sys.exit()
if __name__ == '__main__':
main()
| 1,334
|
Python
|
.py
| 23
| 46.26087
| 147
| 0.652607
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,517
|
deprecated_ping.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/deprecated_ping.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='user', is_deprecated=True)))
if __name__ == '__main__':
main()
| 198
|
Python
|
.py
| 7
| 25.428571
| 77
| 0.677419
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,518
|
uses_mu_missing.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing.py
|
#!/usr/bin/python
from __future__ import annotations
from ..module_utils import bogusmu # pylint: disable=relative-beyond-top-level,unused-import
def main():
raise Exception('should never get here')
if __name__ == '__main__':
main()
| 247
|
Python
|
.py
| 7
| 32.428571
| 93
| 0.710638
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,519
|
uses_base_mu_granular_nested_import.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_base_mu_granular_nested_import.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
from ansible_collections.testns.testcoll.plugins.module_utils.base import thingtocall
def main():
mu_result = thingtocall()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result)))
sys.exit()
if __name__ == '__main__':
main()
| 343
|
Python
|
.py
| 11
| 28.090909
| 85
| 0.726154
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,520
|
uses_core_redirected_mu.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_core_redirected_mu.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
from ansible.module_utils.formerly_core import thingtocall
def main():
mu_result = thingtocall()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result)))
sys.exit()
if __name__ == '__main__':
main()
| 316
|
Python
|
.py
| 11
| 25.636364
| 78
| 0.711409
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,521
|
uses_leaf_mu_granular_import.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_granular_import.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
from ansible_collections.testns.testcoll.plugins.module_utils.leaf import thingtocall as aliasedthing
def main():
mu_result = aliasedthing()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result)))
sys.exit()
if __name__ == '__main__':
main()
| 360
|
Python
|
.py
| 11
| 29.636364
| 101
| 0.733918
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,522
|
uses_nested_same_as_module.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_module.py
|
#!/usr/bin/python
from __future__ import annotations
import json
import sys
from ansible_collections.testns.testcoll.plugins.module_utils.nested_same.nested_same import nested_same
def main():
mu_result = nested_same.nested_same()
print(json.dumps(dict(changed=False, source='user', mu_result=mu_result)))
sys.exit()
if __name__ == '__main__':
main()
| 374
|
Python
|
.py
| 11
| 30.909091
| 104
| 0.730337
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,523
|
uses_mu_missing_redirect_module.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_module.py
|
#!/usr/bin/python
from __future__ import annotations
from ..module_utils import missing_redirect_target_module # pylint: disable=relative-beyond-top-level,unused-import
def main():
raise Exception('should never get here')
if __name__ == '__main__':
main()
| 270
|
Python
|
.py
| 7
| 35.714286
| 116
| 0.724806
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,524
|
testmodule.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
|
#!/usr/bin/python
from __future__ import annotations
import json
DOCUMENTATION = r"""
module: testmodule
description: for testing
extends_documentation_fragment:
- testns.testcoll.frag
- testns.testcoll.frag.other_documentation
"""
def main():
print(json.dumps(dict(changed=False, source='user')))
if __name__ == '__main__':
main()
| 350
|
Python
|
.py
| 14
| 22.714286
| 57
| 0.736364
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,525
|
testmodule_bad_docfrags.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule_bad_docfrags.py
|
#!/usr/bin/python
from __future__ import annotations
import json
DOCUMENTATION = r"""
module: testmodule
description: for testing
extends_documentation_fragment:
- noncollbogusfrag
- noncollbogusfrag.bogusvar
- bogusns.testcoll.frag
- testns.boguscoll.frag
- testns.testcoll.bogusfrag
- testns.testcoll.frag.bogusvar
"""
def main():
print(json.dumps(dict(changed=False, source='user')))
if __name__ == '__main__':
main()
| 447
|
Python
|
.py
| 18
| 22.388889
| 57
| 0.747045
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,526
|
subdir_ping_module.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/module_subdir/subdir_ping_module.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='user')))
if __name__ == '__main__':
main()
| 179
|
Python
|
.py
| 7
| 22.571429
| 57
| 0.662651
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,527
|
secondary.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/secondary.py
|
from __future__ import annotations
def thingtocall():
return "thingtocall in secondary"
| 94
|
Python
|
.py
| 3
| 28.333333
| 37
| 0.775281
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,528
|
subpkg_with_init.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init.py
|
# NB: this module should never be loaded, since we'll see the subpkg_with_init package dir first
from __future__ import annotations
def thingtocall():
raise Exception('this should never be called (loaded discrete module instead of package module)')
def anotherthingtocall():
raise Exception('this should never be called (loaded discrete module instead of package module)')
| 385
|
Python
|
.py
| 6
| 61.166667
| 101
| 0.786667
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,529
|
base.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/base.py
|
from __future__ import annotations
from ansible_collections.testns.testcoll.plugins.module_utils import secondary
import ansible_collections.testns.testcoll.plugins.module_utils.secondary
def thingtocall():
if secondary != ansible_collections.testns.testcoll.plugins.module_utils.secondary:
raise Exception()
return "thingtocall in base called " + ansible_collections.testns.testcoll.plugins.module_utils.secondary.thingtocall()
| 449
|
Python
|
.py
| 7
| 60.285714
| 123
| 0.817352
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,530
|
leaf.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/leaf.py
|
from __future__ import annotations
def thingtocall():
return "thingtocall in leaf"
| 89
|
Python
|
.py
| 3
| 26.666667
| 34
| 0.761905
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,531
|
nested_same.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/nested_same/nested_same/nested_same.py
|
from __future__ import annotations
def nested_same():
return 'hello from nested_same'
| 92
|
Python
|
.py
| 3
| 27.666667
| 35
| 0.747126
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,532
|
__init__.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/__init__.py
|
from __future__ import annotations
# exercise relative imports in package init; they behave differently
from .mod_in_subpkg_with_init import thingtocall as submod_thingtocall
from ..subpkg.submod import thingtocall as cousin_submod_thingtocall # pylint: disable=relative-beyond-top-level
def thingtocall():
return "thingtocall in subpkg_with_init"
| 356
|
Python
|
.py
| 6
| 57.166667
| 113
| 0.815562
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,533
|
mod_in_subpkg_with_init.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/mod_in_subpkg_with_init.py
|
from __future__ import annotations
def thingtocall():
return "thingtocall in mod_in_subpkg_with_init"
| 108
|
Python
|
.py
| 3
| 33
| 51
| 0.76699
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,534
|
submod.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg/submod.py
|
from __future__ import annotations
def thingtocall():
return "thingtocall in subpkg.submod"
| 98
|
Python
|
.py
| 3
| 29.666667
| 41
| 0.774194
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,535
|
mylookup.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup.py
|
from __future__ import annotations
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
return ['mylookup_from_user_dir']
| 207
|
Python
|
.py
| 5
| 37
| 46
| 0.756345
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,536
|
mylookup2.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup2.py
|
from __future__ import annotations
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
return ['mylookup2_from_user_dir']
| 209
|
Python
|
.py
| 5
| 37.2
| 46
| 0.757576
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,537
|
my_subdir_lookup.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/lookup_subdir/my_subdir_lookup.py
|
from __future__ import annotations
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
return ['subdir_lookup_from_user_dir']
| 212
|
Python
|
.py
| 5
| 38
| 46
| 0.757426
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,538
|
usercallback.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/callback/usercallback.py
|
from __future__ import annotations
from ansible.plugins.callback import CallbackBase
DOCUMENTATION = """
callback: usercallback
callback_type: notification
short_description: does stuff
description:
- does some stuff
"""
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_NAME = 'usercallback'
def __init__(self):
super(CallbackModule, self).__init__()
self._display.display("loaded usercallback from collection, yay")
def v2_runner_on_ok(self, result):
self._display.display("usercallback says ok")
| 618
|
Python
|
.py
| 18
| 29.277778
| 73
| 0.711636
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,539
|
myfilters.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters.py
|
from __future__ import annotations
def testfilter(data):
return "{0}_via_testfilter_from_userdir".format(data)
class FilterModule(object):
def filters(self):
return {
'testfilter': testfilter
}
| 235
|
Python
|
.py
| 8
| 23.25
| 57
| 0.666667
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,540
|
myfilters2.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters2.py
|
from __future__ import annotations
def testfilter2(data):
return "{0}_via_testfilter2_from_userdir".format(data)
class FilterModule(object):
def filters(self):
return {
'testfilter2': testfilter2
}
| 239
|
Python
|
.py
| 8
| 23.75
| 58
| 0.672566
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,541
|
my_subdir_filters.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/filter_subdir/my_subdir_filters.py
|
from __future__ import annotations
def test_subdir_filter(data):
return "{0}_via_testfilter_from_subdir".format(data)
class FilterModule(object):
def filters(self):
return {
'test_subdir_filter': test_subdir_filter
}
| 258
|
Python
|
.py
| 8
| 26.125
| 56
| 0.673469
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,542
|
frag.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/doc_fragments/frag.py
|
from __future__ import annotations
class ModuleDocFragment(object):
DOCUMENTATION = r"""
options:
normal_doc_frag:
description:
- an option
"""
OTHER_DOCUMENTATION = r"""
options:
other_doc_frag:
description:
- another option
"""
| 261
|
Python
|
.py
| 14
| 15.428571
| 34
| 0.696721
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,543
|
broken_filter.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testbroken/plugins/filter/broken_filter.py
|
from __future__ import annotations
class FilterModule(object):
def filters(self):
return {
'broken': lambda x: 'broken',
}
raise Exception('This is a broken filter plugin.')
| 211
|
Python
|
.py
| 7
| 23.857143
| 50
| 0.643216
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,544
|
ping.py
|
ansible_ansible/test/integration/targets/collections/ansiballz_dupe/collections/ansible_collections/duplicate/name/plugins/modules/ping.py
|
#!/usr/bin/python
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
AnsibleModule({}).exit_json(ping='duplicate.name.pong')
| 163
|
Python
|
.py
| 4
| 39.5
| 55
| 0.803797
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,545
|
override_formerly_core_masked_test.py
|
ansible_ansible/test/integration/targets/collections/test_plugins/override_formerly_core_masked_test.py
|
from __future__ import annotations
def override_formerly_core_masked_test(value, *args, **kwargs):
if value != 'hello override':
raise Exception('expected "hello override" only...')
return True
class TestModule(object):
def tests(self):
return {
'formerly_core_masked_test': override_formerly_core_masked_test
}
| 365
|
Python
|
.py
| 10
| 30.2
| 75
| 0.671429
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,546
|
testmodule2.py
|
ansible_ansible/test/integration/targets/collections/testcoll2/plugins/modules/testmodule2.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: testmodule2
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
import json
def main():
print(json.dumps(dict(changed=False, source='sys')))
if __name__ == '__main__':
main()
| 501
|
Python
|
.py
| 23
| 17.956522
| 56
| 0.616205
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,547
|
sys_check.py
|
ansible_ansible/test/integration/targets/ansiballz_python/library/sys_check.py
|
#!/usr/bin/python
# https://github.com/ansible/ansible/issues/64664
# https://github.com/ansible/ansible/issues/64479
from __future__ import annotations
import sys
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule({})
this_module = sys.modules[__name__]
module.exit_json(
failed=not getattr(this_module, 'AnsibleModule', False)
)
if __name__ == '__main__':
main()
| 438
|
Python
|
.py
| 14
| 27.714286
| 63
| 0.706731
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,548
|
custom_module.py
|
ansible_ansible/test/integration/targets/ansiballz_python/library/custom_module.py
|
#!/usr/bin/python
from __future__ import annotations
from ..module_utils.basic import AnsibleModule # pylint: disable=relative-beyond-top-level
from ..module_utils.custom_util import forty_two # pylint: disable=relative-beyond-top-level
def main():
module = AnsibleModule(
argument_spec=dict()
)
module.exit_json(answer=forty_two())
if __name__ == '__main__':
main()
| 400
|
Python
|
.py
| 11
| 32.545455
| 93
| 0.709424
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,549
|
check_rlimit_and_maxfd.py
|
ansible_ansible/test/integration/targets/ansiballz_python/library/check_rlimit_and_maxfd.py
|
#!/usr/bin/python
#
# Copyright 2018 Red Hat | Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
import resource
import subprocess
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict()
)
rlimit_nofile = resource.getrlimit(resource.RLIMIT_NOFILE)
try:
maxfd = subprocess.MAXFD
except AttributeError:
maxfd = -1
module.exit_json(rlimit_nofile=rlimit_nofile, maxfd=maxfd, infinity=resource.RLIM_INFINITY)
if __name__ == '__main__':
main()
| 640
|
Python
|
.py
| 20
| 27.9
| 95
| 0.719672
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,550
|
import_pkg_resources.py
|
ansible_ansible/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py
|
from __future__ import annotations
import pkg_resources # pylint: disable=unused-import
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
return ['ok']
| 240
|
Python
|
.py
| 6
| 36.333333
| 53
| 0.76087
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,551
|
dummy.py
|
ansible_ansible/test/integration/targets/loop-connection/collections/ansible_collections/ns/name/plugins/connection/dummy.py
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
name: dummy
short_description: Used for loop-connection tests
description:
- See above
author: ansible (@core)
"""
from ansible.errors import AnsibleError
from ansible.plugins.connection import ConnectionBase
class Connection(ConnectionBase):
transport = 'ns.name.dummy'
def __init__(self, *args, **kwargs):
self._cmds_run = 0
super().__init__(*args, **kwargs)
@property
def connected(self):
return True
def _connect(self):
return
def exec_command(self, cmd, in_data=None, sudoable=True):
if 'become_test' in cmd:
stderr = f"become - {self.become.name if self.become else None}"
elif 'connected_test' in cmd:
self._cmds_run += 1
stderr = f"ran - {self._cmds_run}"
else:
raise AnsibleError(f"Unknown test cmd {cmd}")
return 0, cmd.encode(), stderr.encode()
def put_file(self, in_path, out_path):
return
def fetch_file(self, in_path, out_path):
return
def close(self):
return
| 1,209
|
Python
|
.py
| 36
| 27.388889
| 92
| 0.645941
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,552
|
uninstall-Alpine-3-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/uninstall-Alpine-3-python-3.yml
|
- name: Uninstall Paramiko for Python 3 on Alpine
command: apk del py3-paramiko
| 82
|
Python
|
.py
| 2
| 39
| 49
| 0.7875
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,553
|
uninstall-RedHat-8-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/uninstall-RedHat-8-python-3.yml
|
- name: Uninstall Paramiko for Python 3 on RHEL 8
pip: # no python3-paramiko package exists for RHEL 8
name: paramiko
state: absent
| 142
|
Python
|
.py
| 4
| 32
| 54
| 0.73913
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,554
|
uninstall-zypper-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/uninstall-zypper-python-3.yml
|
- name: Uninstall Paramiko for Python 3 using zypper
command: zypper --quiet --non-interactive remove --clean-deps python3-paramiko
| 134
|
Python
|
.py
| 2
| 65
| 80
| 0.787879
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,555
|
uninstall-Darwin-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/uninstall-Darwin-python-3.yml
|
- name: Uninstall Paramiko for Python 3 on MacOS
pip:
name: paramiko
state: absent
| 93
|
Python
|
.py
| 4
| 19.75
| 48
| 0.719101
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,556
|
install-Alpine-3-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/install-Alpine-3-python-3.yml
|
- name: Install Paramiko for Python 3 on Alpine
command: apk add py3-paramiko
| 80
|
Python
|
.py
| 2
| 38
| 47
| 0.782051
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,557
|
uninstall-RedHat-9-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/uninstall-RedHat-9-python-3.yml
|
- name: Uninstall Paramiko for Python 3 on RHEL 9
pip: # no python3-paramiko package exists for RHEL 9
name: paramiko
state: absent
- name: Revert the crypto-policy back to DEFAULT
command: update-crypto-policies --set DEFAULT
| 240
|
Python
|
.py
| 6
| 36.833333
| 54
| 0.759657
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,558
|
install-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/install-python-3.yml
|
- name: Install Paramiko for Python 3
package:
name: python3-paramiko
| 76
|
Python
|
.py
| 3
| 22.333333
| 37
| 0.753425
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,559
|
uninstall-FreeBSD-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/uninstall-FreeBSD-python-3.yml
|
- name: Uninstall Paramiko for Python 3 on FreeBSD
pip:
name: paramiko
state: absent
| 95
|
Python
|
.py
| 4
| 20.25
| 50
| 0.725275
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,560
|
install-FreeBSD-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/install-FreeBSD-python-3.yml
|
- name: Setup remote constraints
include_tasks: setup-remote-constraints.yml
- name: Install Paramiko for Python 3 on FreeBSD
pip: # no package in pkg, just use pip
name: paramiko
extra_args: "-c {{ remote_constraints }}"
environment:
SETUPTOOLS_USE_DISTUTILS: stdlib
| 286
|
Python
|
.py
| 8
| 32.5
| 48
| 0.741007
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,561
|
install-RedHat-9-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/install-RedHat-9-python-3.yml
|
- name: Setup remote constraints
include_tasks: setup-remote-constraints.yml
- name: Install Paramiko for Python 3 on RHEL 9
pip: # no python3-paramiko package exists for RHEL 9
name: paramiko
extra_args: "-c {{ remote_constraints }}"
- name: Drop the crypto-policy to LEGACY for these tests
command: update-crypto-policies --set LEGACY
| 352
|
Python
|
.py
| 8
| 41.125
| 56
| 0.755102
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,562
|
uninstall-apt-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/uninstall-apt-python-3.yml
|
- name: Uninstall Paramiko for Python 3 using apt
apt:
name: python3-paramiko
state: absent
autoremove: yes
| 122
|
Python
|
.py
| 5
| 20.6
| 49
| 0.726496
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,563
|
install-Darwin-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/install-Darwin-python-3.yml
|
- name: Setup remote constraints
include_tasks: setup-remote-constraints.yml
- name: Install Paramiko for Python 3 on MacOS
pip: # no homebrew package manager in core, just use pip
name: paramiko
extra_args: "-c {{ remote_constraints }}"
environment:
# Not sure why this fixes the test, but it does.
SETUPTOOLS_USE_DISTUTILS: stdlib
| 355
|
Python
|
.py
| 9
| 36
| 58
| 0.736994
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,564
|
install-RedHat-8-python-3.yml
|
ansible_ansible/test/integration/targets/setup_paramiko/install-RedHat-8-python-3.yml
|
- name: Setup remote constraints
include_tasks: setup-remote-constraints.yml
- name: Install Paramiko for Python 3 on RHEL 8
pip: # no python3-paramiko package exists for RHEL 8
name: paramiko
extra_args: "-c {{ remote_constraints }}"
environment:
SETUPTOOLS_USE_DISTUTILS: stdlib
| 299
|
Python
|
.py
| 8
| 34.125
| 54
| 0.749141
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,565
|
detect_paramiko.py
|
ansible_ansible/test/integration/targets/setup_paramiko/library/detect_paramiko.py
|
#!/usr/bin/python
"""Ansible module to detect the presence of both the normal and Ansible-specific versions of Paramiko."""
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
try:
import paramiko
except ImportError:
paramiko = None
try:
import ansible_paramiko
except ImportError:
ansible_paramiko = None
def main():
module = AnsibleModule(argument_spec={})
module.exit_json(**dict(
found=bool(paramiko or ansible_paramiko),
paramiko=bool(paramiko),
ansible_paramiko=bool(ansible_paramiko),
))
if __name__ == '__main__':
main()
| 630
|
Python
|
.py
| 21
| 25.904762
| 105
| 0.72
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,566
|
async_test.py
|
ansible_ansible/test/integration/targets/async_fail/library/async_test.py
|
from __future__ import annotations
import json
import sys
import time
from ansible.module_utils.basic import AnsibleModule
def main():
if "--interactive" in sys.argv:
import ansible.module_utils.basic
ansible.module_utils.basic._ANSIBLE_ARGS = json.dumps(dict(
ANSIBLE_MODULE_ARGS=dict(
fail_mode="graceful"
)
))
module = AnsibleModule(
argument_spec=dict(
fail_mode=dict(type='list', default=['success'])
)
)
result = dict(changed=True)
fail_mode = module.params['fail_mode']
try:
if 'leading_junk' in fail_mode:
print("leading junk before module output")
if 'graceful' in fail_mode:
module.fail_json(msg="failed gracefully")
if 'exception' in fail_mode:
raise Exception('failing via exception')
if 'recovered_fail' in fail_mode:
result = {"msg": "succeeded", "failed": False, "changed": True}
# Wait in the middle to setup a race where the controller reads incomplete data from our
# special async_status the first poll
time.sleep(5)
module.exit_json(**result)
finally:
if 'trailing_junk' in fail_mode:
print("trailing junk after module output")
main()
| 1,334
|
Python
|
.py
| 37
| 27.513514
| 100
| 0.619345
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,567
|
normal.py
|
ansible_ansible/test/integration/targets/async_fail/action_plugins/normal.py
|
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
from ansible.errors import AnsibleError
from ansible.plugins.action import ActionBase
from ansible.utils.vars import merge_hash
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
# individual modules might disagree but as the generic the action plugin, pass at this point.
self._supports_check_mode = True
self._supports_async = True
result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
if not result.get('skipped'):
if result.get('invocation', {}).get('module_args'):
# avoid passing to modules in case of no_log
# should not be set anymore but here for backwards compatibility
del result['invocation']['module_args']
# FUTURE: better to let _execute_module calculate this internally?
wrap_async = self._task.async_val and not self._connection.has_native_async
# do work!
result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
# hack to keep --verbose from showing all the setup module result
# moved from setup module as now we filter out all _ansible_ from result
if self._task.action == 'setup':
result['_ansible_verbose_override'] = True
# Simulate a transient network failure
if self._task.action == 'async_status' and 'finished' in result and result['finished'] != 1:
raise AnsibleError('Pretend to fail somewhere in executing async_status')
if not wrap_async:
# remove a temporary path we created
self._remove_tmp_path(self._connection._shell.tmpdir)
return result
| 2,513
|
Python
|
.py
| 47
| 46.212766
| 105
| 0.691272
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,568
|
create_repo.py
|
ansible_ansible/test/integration/targets/setup_rpm_repo/library/create_repo.py
|
#!/usr/bin/python
from __future__ import annotations
import tempfile
from dataclasses import dataclass
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.respawn import has_respawned, probe_interpreters_for_module, respawn_module
HAS_RPMFLUFF = True
try:
from rpmfluff.make import make_gif
from rpmfluff.sourcefile import GeneratedSourceFile
from rpmfluff.rpmbuild import SimpleRpmBuild
from rpmfluff.yumrepobuild import YumRepoBuild
except ImportError:
HAS_RPMFLUFF = False
@dataclass
class RPM:
name: str
version: str
release: str = '1'
epoch: int = 0
arch: list[str] | None = None
recommends: list[str] | None = None
requires: list[str] | None = None
file: str | None = None
SPECS = [
RPM(name='dinginessentail', version='1.0'),
RPM(name='dinginessentail', version='1.0', release='2', epoch=1),
RPM(name='dinginessentail', version='1.1', epoch=1),
RPM(name='dinginessentail-olive', version='1.0'),
RPM(name='dinginessentail-olive', version='1.1'),
RPM(name='multilib-dinginessentail', version='1.0', arch=['i686', 'x86_64']),
RPM(name='multilib-dinginessentail', version='1.1', arch=['i686', 'x86_64']),
RPM(name='landsidescalping', version='1.0',),
RPM(name='landsidescalping', version='1.1',),
RPM(name='dinginessentail-with-weak-dep', version='1.0', recommends=['dinginessentail-weak-dep']),
RPM(name='dinginessentail-weak-dep', version='1.0',),
RPM(name='noarchfake', version='1.0'),
RPM(name='provides_foo_a', version='1.0', file='foo.gif'),
RPM(name='provides_foo_b', version='1.0', file='foo.gif'),
RPM(name='number-11-name', version='11.0',),
RPM(name='number-11-name', version='11.1',),
RPM(name='epochone', version='1.0', epoch=1),
RPM(name='epochone', version='1.1', epoch=1),
RPM(name='broken-a', version='1.2.3',),
RPM(name='broken-a', version='1.2.3.4', requires=['dinginessentail-doesnotexist']),
RPM(name='broken-a', version='1.2.4',),
RPM(name='broken-a', version='2.0.0', requires=['dinginessentail-doesnotexist']),
RPM(name='broken-b', version='1.0', requires=['broken-a = 1.2.3-1']),
RPM(name='broken-c', version='1.0', requires=['broken-c = 1.2.4-1']),
RPM(name='broken-d', version='1.0', requires=['broken-a']),
]
def create_repo():
pkgs = []
for spec in SPECS:
pkg = SimpleRpmBuild(spec.name, spec.version, spec.release, spec.arch or ['noarch'])
pkg.epoch = spec.epoch
for requires in spec.requires or []:
pkg.add_requires(requires)
for recommend in spec.recommends or []:
pkg.add_recommends(recommend)
if spec.file:
pkg.add_installed_file(
"/" + spec.file,
GeneratedSourceFile(
spec.file, make_gif()
)
)
pkgs.append(pkg)
repo = YumRepoBuild(pkgs)
repo.make('noarch', 'i686', 'x86_64')
for pkg in pkgs:
pkg.clean()
return repo.repoDir
def main():
module = AnsibleModule(
argument_spec={
'tempdir': {'type': 'path'},
}
)
if not HAS_RPMFLUFF:
system_interpreters = ['/usr/libexec/platform-python', '/usr/bin/python3', '/usr/bin/python']
interpreter = probe_interpreters_for_module(system_interpreters, 'rpmfluff')
if not interpreter or has_respawned():
module.fail_json('unable to find rpmfluff; tried {0}'.format(system_interpreters))
respawn_module(interpreter)
tempdir = module.params['tempdir']
# Save current temp dir so we can set it back later
original_tempdir = tempfile.tempdir
tempfile.tempdir = tempdir
try:
repo_dir = create_repo()
finally:
tempfile.tempdir = original_tempdir
module.exit_json(repo_dir=repo_dir, tmpfile=tempfile.gettempdir())
if __name__ == "__main__":
main()
| 3,960
|
Python
|
.py
| 96
| 34.927083
| 108
| 0.647535
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,569
|
do-not-check-me.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/do-not-check-me.py
|
from __future__ import annotations
from ansible.module_utils.pycompat24 import get_exception
def do_stuff():
get_exception()
| 132
|
Python
|
.py
| 4
| 30.25
| 57
| 0.792
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,570
|
check-me.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/plugins/modules/check-me.py
|
from __future__ import annotations
from ansible.module_utils.pycompat24 import get_exception
def do_stuff():
get_exception()
| 132
|
Python
|
.py
| 4
| 30.25
| 57
| 0.792
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,571
|
fakelocal.py
|
ansible_ansible/test/integration/targets/delegate_to/connection_plugins/fakelocal.py
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
connection: fakelocal
short_description: dont execute anything
description:
- This connection plugin just verifies parameters passed in
author: ansible (@core)
version_added: histerical
options:
password:
description: Authentication password for the C(remote_user). Can be supplied as CLI option.
vars:
- name: ansible_password
remote_user:
description:
- User name with which to login to the remote server, normally set by the remote_user keyword.
ini:
- section: defaults
key: remote_user
vars:
- name: ansible_user
"""
from ansible.errors import AnsibleConnectionFailure
from ansible.plugins.connection import ConnectionBase
from ansible.utils.display import Display
display = Display()
class Connection(ConnectionBase):
""" Local based connections """
transport = 'fakelocal'
has_pipelining = True
def __init__(self, *args, **kwargs):
super(Connection, self).__init__(*args, **kwargs)
self.cwd = None
def _connect(self):
""" verify """
if self.get_option('remote_user') == 'invaliduser' and self.get_option('password') == 'badpassword':
raise AnsibleConnectionFailure('Got invaliduser and badpassword')
if not self._connected:
display.vvv(u"ESTABLISH FAKELOCAL CONNECTION FOR USER: {0}".format(self._play_context.remote_user), host=self._play_context.remote_addr)
self._connected = True
return self
def exec_command(self, cmd, in_data=None, sudoable=True):
""" run a command on the local host """
super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable)
return 0, '{"msg": "ALL IS GOOD"}', ''
def put_file(self, in_path, out_path):
""" transfer a file from local to local """
super(Connection, self).put_file(in_path, out_path)
def fetch_file(self, in_path, out_path):
""" fetch a file from local to local -- for compatibility """
super(Connection, self).fetch_file(in_path, out_path)
def close(self):
""" terminate the connection; nothing to do here """
self._connected = False
| 2,426
|
Python
|
.py
| 55
| 36.309091
| 148
| 0.653339
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,572
|
detect_interpreter.py
|
ansible_ansible/test/integration/targets/delegate_to/library/detect_interpreter.py
|
#!/usr/bin/python
from __future__ import annotations
import sys
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(argument_spec={})
module.exit_json(**dict(found=sys.executable))
if __name__ == '__main__':
main()
| 271
|
Python
|
.py
| 9
| 26.888889
| 52
| 0.716535
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,573
|
test-pause.py
|
ansible_ansible/test/integration/targets/pause/test-pause.py
|
#!/usr/bin/env python
from __future__ import annotations
import os
import pexpect
import sys
import termios
from ansible.module_utils.six import PY2
args = sys.argv[1:]
env_vars = {
'ANSIBLE_ROLES_PATH': './roles',
'ANSIBLE_NOCOLOR': 'True',
'ANSIBLE_RETRY_FILES_ENABLED': 'False'
}
try:
backspace = termios.tcgetattr(sys.stdin.fileno())[6][termios.VERASE]
except Exception:
backspace = b'\x7f'
if PY2:
log_buffer = sys.stdout
else:
log_buffer = sys.stdout.buffer
os.environ.update(env_vars)
# -- Plain pause -- #
playbook = 'pause-1.yml'
# Case 1 - Contiune with enter
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Press enter to continue, Ctrl\+C to interrupt:')
pause_test.send('\r')
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 2 - Continue with C
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Press enter to continue, Ctrl\+C to interrupt:')
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('C')
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 3 - Abort with A
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Press enter to continue, Ctrl\+C to interrupt:')
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('A')
pause_test.expect('user requested abort!')
pause_test.expect(pexpect.EOF)
pause_test.close()
# -- Custom Prompt -- #
playbook = 'pause-2.yml'
# Case 1 - Contiune with enter
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Custom prompt:')
pause_test.send('\r')
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 2 - Contiune with C
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Custom prompt:')
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('C')
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 3 - Abort with A
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Custom prompt:')
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('A')
pause_test.expect('user requested abort!')
pause_test.expect(pexpect.EOF)
pause_test.close()
# -- Pause for N seconds -- #
playbook = 'pause-3.yml'
# Case 1 - Wait for task to continue after timeout
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Pausing for \d+ seconds')
pause_test.expect(r"\(ctrl\+C then 'C' = continue early, ctrl\+C then 'A' = abort\)")
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 2 - Contiune with Ctrl + C, C
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Pausing for \d+ seconds')
pause_test.expect(r"\(ctrl\+C then 'C' = continue early, ctrl\+C then 'A' = abort\)")
pause_test.send('\n') # test newline does not stop the prompt - waiting for a timeout or ctrl+C
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('C')
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 3 - Abort with Ctrl + C, A
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Pausing for \d+ seconds')
pause_test.expect(r"\(ctrl\+C then 'C' = continue early, ctrl\+C then 'A' = abort\)")
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('A')
pause_test.expect('user requested abort!')
pause_test.expect(pexpect.EOF)
pause_test.close()
# -- Pause for N seconds with custom prompt -- #
playbook = 'pause-4.yml'
# Case 1 - Wait for task to continue after timeout
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Pausing for \d+ seconds')
pause_test.expect(r"\(ctrl\+C then 'C' = continue early, ctrl\+C then 'A' = abort\)")
pause_test.expect(r"Waiting for two seconds:")
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 2 - Contiune with Ctrl + C, C
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Pausing for \d+ seconds')
pause_test.expect(r"\(ctrl\+C then 'C' = continue early, ctrl\+C then 'A' = abort\)")
pause_test.expect(r"Waiting for two seconds:")
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('C')
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Case 3 - Abort with Ctrl + C, A
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Pausing for \d+ seconds')
pause_test.expect(r"\(ctrl\+C then 'C' = continue early, ctrl\+C then 'A' = abort\)")
pause_test.expect(r"Waiting for two seconds:")
pause_test.send('\x03')
pause_test.expect("Press 'C' to continue the play or 'A' to abort")
pause_test.send('A')
pause_test.expect('user requested abort!')
pause_test.expect(pexpect.EOF)
pause_test.close()
# -- Enter input and ensure it's captured, echoed, and can be edited -- #
playbook = 'pause-5.yml'
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Enter some text:')
pause_test.send('hello there')
pause_test.send('\r')
pause_test.expect(r'Enter some text to edit:')
pause_test.send('hello there')
pause_test.send(backspace * 4)
pause_test.send('ommy boy')
pause_test.send('\r')
pause_test.expect(r'Enter some text \(output is hidden\):')
pause_test.send('supersecretpancakes')
pause_test.send('\r')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Test input is not returned if a timeout is given
playbook = 'pause-6.yml'
pause_test = pexpect.spawn(
'ansible-playbook',
args=[playbook] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r'Wait for three seconds:')
pause_test.send('ignored user input')
pause_test.expect('Task after pause')
pause_test.expect(pexpect.EOF)
pause_test.close()
# Test that enter presses may not continue the play when a timeout is set.
pause_test = pexpect.spawn(
'ansible-playbook',
args=["pause-3.yml"] + args,
timeout=10,
env=os.environ
)
pause_test.logfile = log_buffer
pause_test.expect(r"\(ctrl\+C then 'C' = continue early, ctrl\+C then 'A' = abort\)")
pause_test.send('\r')
pause_test.expect(pexpect.EOF)
pause_test.close()
| 7,823
|
Python
|
.py
| 258
| 28.065891
| 96
| 0.719537
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,574
|
with_yml.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-action-plugin-docs/ansible_collections/ns/col/plugins/action/with_yml.py
|
# Copyright (c) 2024 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
def run(self, tmp, task_vars):
return {"changed": False}
| 316
|
Python
|
.py
| 7
| 41.857143
| 92
| 0.75082
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,575
|
with_py.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-action-plugin-docs/ansible_collections/ns/col/plugins/action/with_py.py
|
# Copyright (c) 2024 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
def run(self, tmp, task_vars):
return {"changed": False}
| 316
|
Python
|
.py
| 7
| 41.857143
| 92
| 0.75082
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,576
|
with_yaml.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-action-plugin-docs/ansible_collections/ns/col/plugins/action/with_yaml.py
|
# Copyright (c) 2024 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
def run(self, tmp, task_vars):
return {"changed": False}
| 316
|
Python
|
.py
| 7
| 41.857143
| 92
| 0.75082
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,577
|
with_py.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-action-plugin-docs/ansible_collections/ns/col/plugins/modules/with_py.py
|
# Copyright (c) 2024 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = r"""
---
module: with_py
short_description: Short description
description: Long description
options: {}
author:
- Ansible Core Team (@ansible)
"""
EXAMPLES = r"""
- name: Some example
ns.col.with_py:
"""
RETURNS = ""
| 370
|
Python
|
.py
| 16
| 21.6875
| 92
| 0.732194
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,578
|
notyaml.py
|
ansible_ansible/test/integration/targets/rel_plugin_loading/subdir/inventory_plugins/notyaml.py
|
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
inventory: yaml
version_added: "2.4"
short_description: Uses a specific YAML file as an inventory source.
description:
- "YAML-based inventory, should start with the C(all) group and contain hosts/vars/children entries."
- Host entries can have sub-entries defined, which will be treated as variables.
- Vars entries are normal group vars.
- "Children are 'child groups', which can also have their own vars/hosts/children and so on."
- File MUST have a valid extension, defined in configuration.
notes:
- If you want to set vars for the C(all) group inside the inventory file, the C(all) group must be the first entry in the file.
- Enabled in configuration by default.
options:
yaml_extensions:
description: list of 'valid' extensions for files containing YAML
type: list
default: ['.yaml', '.yml', '.json']
env:
- name: ANSIBLE_YAML_FILENAME_EXT
- name: ANSIBLE_INVENTORY_PLUGIN_EXTS
ini:
- key: yaml_valid_extensions
section: defaults
- section: inventory_plugin_yaml
key: yaml_valid_extensions
"""
EXAMPLES = """
all: # keys must be unique, i.e. only one 'hosts' per group
hosts:
test1:
test2:
host_var: value
vars:
group_all_var: value
children: # key order does not matter, indentation does
other_group:
children:
group_x:
hosts:
test5
vars:
g2_var2: value3
hosts:
test4:
ansible_host: 127.0.0.1
last_group:
hosts:
test1 # same host as above, additional group membership
vars:
group_last_var: value
"""
import os
from collections.abc import MutableMapping
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.module_utils.six import string_types
from ansible.module_utils.common.text.converters import to_native, to_text
from ansible.plugins.inventory import BaseFileInventoryPlugin
NoneType = type(None)
class InventoryModule(BaseFileInventoryPlugin):
NAME = 'yaml'
def __init__(self):
super(InventoryModule, self).__init__()
def verify_file(self, path):
valid = False
if super(InventoryModule, self).verify_file(path):
file_name, ext = os.path.splitext(path)
if not ext or ext in self.get_option('yaml_extensions'):
valid = True
return valid
def parse(self, inventory, loader, path, cache=True):
""" parses the inventory file """
super(InventoryModule, self).parse(inventory, loader, path)
self.set_options()
try:
data = self.loader.load_from_file(path, cache='none')
except Exception as e:
raise AnsibleParserError(e)
if not data:
raise AnsibleParserError('Parsed empty YAML file')
elif not isinstance(data, MutableMapping):
raise AnsibleParserError('YAML inventory has invalid structure, it should be a dictionary, got: %s' % type(data))
elif data.get('plugin'):
raise AnsibleParserError('Plugin configuration YAML file, not YAML inventory')
# We expect top level keys to correspond to groups, iterate over them
# to get host, vars and subgroups (which we iterate over recursively)
if isinstance(data, MutableMapping):
for group_name in data:
self._parse_group(group_name, data[group_name])
else:
raise AnsibleParserError("Invalid data from file, expected dictionary and got:\n\n%s" % to_native(data))
def _parse_group(self, group, group_data):
if isinstance(group_data, (MutableMapping, NoneType)):
try:
self.inventory.add_group(group)
except AnsibleError as e:
raise AnsibleParserError("Unable to add group %s: %s" % (group, to_text(e)))
if group_data is not None:
# make sure they are dicts
for section in ['vars', 'children', 'hosts']:
if section in group_data:
# convert strings to dicts as these are allowed
if isinstance(group_data[section], string_types):
group_data[section] = {group_data[section]: None}
if not isinstance(group_data[section], (MutableMapping, NoneType)):
raise AnsibleParserError('Invalid "%s" entry for "%s" group, requires a dictionary, found "%s" instead.' %
(section, group, type(group_data[section])))
for key in group_data:
if not isinstance(group_data[key], (MutableMapping, NoneType)):
self.display.warning('Skipping key (%s) in group (%s) as it is not a mapping, it is a %s' % (key, group, type(group_data[key])))
continue
if isinstance(group_data[key], NoneType):
self.display.vvv('Skipping empty key (%s) in group (%s)' % (key, group))
elif key == 'vars':
for var in group_data[key]:
self.inventory.set_variable(group, var, group_data[key][var])
elif key == 'children':
for subgroup in group_data[key]:
self._parse_group(subgroup, group_data[key][subgroup])
self.inventory.add_child(group, subgroup)
elif key == 'hosts':
for host_pattern in group_data[key]:
hosts, port = self._parse_host(host_pattern)
self._populate_host_vars(hosts, group_data[key][host_pattern] or {}, group, port)
else:
self.display.warning('Skipping unexpected key (%s) in group (%s), only "vars", "children" and "hosts" are valid' % (key, group))
else:
self.display.warning("Skipping '%s' as this is not a valid group definition" % group)
def _parse_host(self, host_pattern):
"""
Each host key can be a pattern, try to process it and add variables as needed
"""
(hostnames, port) = self._expand_hostpattern(host_pattern)
return hostnames, port
| 6,766
|
Python
|
.py
| 137
| 36.751825
| 152
| 0.588663
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,579
|
ping.py
|
ansible_ansible/test/integration/targets/module_precedence/multiple_roles/foo/library/ping.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: ping
version_added: historical
short_description: Try to connect to host, verify a usable python and return C(pong) on success.
description:
- A trivial test module, this module always returns C(pong) on successful
contact. It does not make sense in playbooks, but it is useful from
C(/usr/bin/ansible) to verify the ability to login and that a usable python is configured.
- This is NOT ICMP ping, this is just a trivial test module.
options: {}
author:
- "Ansible Core Team"
- "Michael DeHaan"
"""
EXAMPLES = """
# Test we can logon to 'webservers' and execute python with json lib.
ansible webservers -m ping
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
data=dict(required=False, default=None),
),
supports_check_mode=True
)
result = dict(ping='pong')
if module.params['data']:
if module.params['data'] == 'crash':
raise Exception("boom")
result['ping'] = module.params['data']
result['location'] = 'role: foo'
module.exit_json(**result)
if __name__ == '__main__':
main()
| 2,181
|
Python
|
.py
| 59
| 33.135593
| 96
| 0.697774
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,580
|
ping.py
|
ansible_ansible/test/integration/targets/module_precedence/multiple_roles/bar/library/ping.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: ping
version_added: historical
short_description: Try to connect to host, verify a usable python and return C(pong) on success.
description:
- A trivial test module, this module always returns C(pong) on successful
contact. It does not make sense in playbooks, but it is useful from
C(/usr/bin/ansible) to verify the ability to login and that a usable python is configured.
- This is NOT ICMP ping, this is just a trivial test module.
options: {}
author:
- "Ansible Core Team"
- "Michael DeHaan"
"""
EXAMPLES = """
# Test we can logon to 'webservers' and execute python with json lib.
ansible webservers -m ping
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
data=dict(required=False, default=None),
),
supports_check_mode=True
)
result = dict(ping='pong')
if module.params['data']:
if module.params['data'] == 'crash':
raise Exception("boom")
result['ping'] = module.params['data']
result['location'] = 'role: bar'
module.exit_json(**result)
if __name__ == '__main__':
main()
| 2,181
|
Python
|
.py
| 59
| 33.135593
| 96
| 0.697774
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,581
|
ping.py
|
ansible_ansible/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: ping
version_added: historical
short_description: Try to connect to host, verify a usable python and return C(pong) on success.
description:
- A trivial test module, this module always returns C(pong) on successful
contact. It does not make sense in playbooks, but it is useful from
C(/usr/bin/ansible) to verify the ability to login and that a usable python is configured.
- This is NOT ICMP ping, this is just a trivial test module.
options: {}
author:
- "Ansible Core Team"
- "Michael DeHaan"
"""
EXAMPLES = """
# Test we can logon to 'webservers' and execute python with json lib.
ansible webservers -m ping
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
data=dict(required=False, default=None),
),
supports_check_mode=True
)
result = dict(ping='pong')
if module.params['data']:
if module.params['data'] == 'crash':
raise Exception("boom")
result['ping'] = module.params['data']
result['location'] = 'role: foo'
module.exit_json(**result)
if __name__ == '__main__':
main()
| 2,181
|
Python
|
.py
| 59
| 33.135593
| 96
| 0.697774
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,582
|
a.py
|
ansible_ansible/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, location='role: foo, a.py')))
if __name__ == '__main__':
main()
| 191
|
Python
|
.py
| 7
| 24.428571
| 70
| 0.659218
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,583
|
ping.py
|
ansible_ansible/test/integration/targets/module_precedence/lib_with_extension/ping.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: ping
version_added: historical
short_description: Try to connect to host, verify a usable python and return C(pong) on success.
description:
- A trivial test module, this module always returns C(pong) on successful
contact. It does not make sense in playbooks, but it is useful from
C(/usr/bin/ansible) to verify the ability to login and that a usable python is configured.
- This is NOT ICMP ping, this is just a trivial test module.
options: {}
author:
- "Ansible Core Team"
- "Michael DeHaan"
"""
EXAMPLES = """
# Test we can logon to 'webservers' and execute python with json lib.
ansible webservers -m ping
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
data=dict(required=False, default=None),
),
supports_check_mode=True
)
result = dict(ping='pong')
if module.params['data']:
if module.params['data'] == 'crash':
raise Exception("boom")
result['ping'] = module.params['data']
result['location'] = 'library'
module.exit_json(**result)
if __name__ == '__main__':
main()
| 2,179
|
Python
|
.py
| 59
| 33.101695
| 96
| 0.698435
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,584
|
a.py
|
ansible_ansible/test/integration/targets/module_precedence/lib_with_extension/a.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, location='a.py')))
if __name__ == '__main__':
main()
| 180
|
Python
|
.py
| 7
| 22.857143
| 59
| 0.660714
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,585
|
callback_debug.py
|
ansible_ansible/test/integration/targets/support-callback_plugins/callback_plugins/callback_debug.py
|
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
import functools
from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
CALLBACK_NAME = 'callback_debug'
def __init__(self, *args, **kwargs):
super(CallbackModule, self).__init__(*args, **kwargs)
self._display.display('__init__')
for name in (cb for cb in dir(self) if cb.startswith('v2_')):
setattr(self, name, functools.partial(self.handle_v2, name))
def handle_v2(self, name, *args, **kwargs):
self._display.display(name)
| 731
|
Python
|
.py
| 16
| 40.1875
| 92
| 0.683168
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,586
|
legit.py
|
ansible_ansible/test/integration/targets/module_utils/collections/ansible_collections/testns/testcoll/plugins/module_utils/legit.py
|
from __future__ import annotations
def importme():
return "successfully imported from testns.testcoll"
| 109
|
Python
|
.py
| 3
| 33.333333
| 55
| 0.788462
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,587
|
ansible_release.py
|
ansible_ansible/test/integration/targets/module_utils/module_utils/ansible_release.py
|
# This file overrides the builtin ansible.module_utils.ansible_release file
# to test that it can be overridden. Previously this was facts.py but caused issues
# with dependencies that may need to execute a module that makes use of facts
data = 'overridden ansible_release.py'
| 277
|
Python
|
.py
| 4
| 68.25
| 83
| 0.809524
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,588
|
test_override.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_override.py
|
#!/usr/bin/python
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
# overridden
from ansible.module_utils.ansible_release import data
results = {"data": data}
AnsibleModule(argument_spec=dict()).exit_json(**results)
| 258
|
Python
|
.py
| 7
| 35.428571
| 56
| 0.806452
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,589
|
test_network.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_network.py
|
#!/usr/bin/python
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.network import to_subnet
def main():
module = AnsibleModule(argument_spec=dict(
subnet=dict(),
))
subnet = module.params['subnet']
if subnet is not None:
split_addr = subnet.split('/')
if len(split_addr) != 2:
module.fail_json("Invalid CIDR notation: expected a subnet mask (e.g. 10.0.0.0/32)")
module.exit_json(resolved=to_subnet(split_addr[0], split_addr[1]))
if __name__ == '__main__':
main()
| 740
|
Python
|
.py
| 18
| 36.055556
| 96
| 0.677419
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,590
|
test.py
|
ansible_ansible/test/integration/targets/module_utils/library/test.py
|
#!/usr/bin/python
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
from __future__ import annotations
results = {}
# Test import with no from
import ansible.module_utils.foo0
results['foo0'] = ansible.module_utils.foo0.data
# Test depthful import with no from
import ansible.module_utils.bar0.foo3
results['bar0'] = ansible.module_utils.bar0.foo3.data
# Test import of module_utils/foo1.py
from ansible.module_utils import foo1
results['foo1'] = foo1.data
# Test import of an identifier inside of module_utils/foo2.py
from ansible.module_utils.foo2 import data
results['foo2'] = data
# Test import of module_utils/bar1/__init__.py
from ansible.module_utils import bar1
results['bar1'] = bar1.data
# Test import of an identifier inside of module_utils/bar2/__init__.py
from ansible.module_utils.bar2 import data
results['bar2'] = data
# Test import of module_utils/baz1/one.py
from ansible.module_utils.baz1 import one
results['baz1'] = one.data
# Test import of an identifier inside of module_utils/baz2/one.py
from ansible.module_utils.baz2.one import data
results['baz2'] = data
# Test import of module_utils/spam1/ham/eggs/__init__.py
from ansible.module_utils.spam1.ham import eggs
results['spam1'] = eggs.data
# Test import of an identifier inside module_utils/spam2/ham/eggs/__init__.py
from ansible.module_utils.spam2.ham.eggs import data
results['spam2'] = data
# Test import of module_utils/spam3/ham/bacon.py
from ansible.module_utils.spam3.ham import bacon
results['spam3'] = bacon.data
# Test import of an identifier inside of module_utils/spam4/ham/bacon.py
from ansible.module_utils.spam4.ham.bacon import data
results['spam4'] = data
# Test import of module_utils.spam5.ham bacon and eggs (modules)
from ansible.module_utils.spam5.ham import bacon, eggs
results['spam5'] = (bacon.data, eggs.data)
# Test import of module_utils.spam6.ham bacon and eggs (identifiers)
from ansible.module_utils.spam6.ham import bacon, eggs
results['spam6'] = (bacon, eggs)
# Test import of module_utils.spam7.ham bacon and eggs (module and identifier)
from ansible.module_utils.spam7.ham import bacon, eggs
results['spam7'] = (bacon.data, eggs)
# Test import of module_utils/spam8/ham/bacon.py and module_utils/spam8/ham/eggs.py separately
from ansible.module_utils.spam8.ham import bacon
from ansible.module_utils.spam8.ham import eggs
results['spam8'] = (bacon.data, eggs)
# Test that import of module_utils/qux1/quux.py using as works
from ansible.module_utils.qux1 import quux as two
results['qux1'] = two.data
# Test that importing qux2/quux.py and qux2/quuz.py using as works
from ansible.module_utils.qux2 import quux as three, quuz as four
results['qux2'] = (three.data, four.data)
# Test depth
from ansible.module_utils.a.b.c.d.e.f.g.h import data
results['abcdefgh'] = data
from ansible.module_utils.basic import AnsibleModule
AnsibleModule(argument_spec=dict()).exit_json(**results)
| 2,992
|
Python
|
.py
| 66
| 44.015152
| 94
| 0.787608
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,591
|
test_cwd_unreadable.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_cwd_unreadable.py
|
#!/usr/bin/python
from __future__ import annotations
import os
from ansible.module_utils.basic import AnsibleModule
def main():
# This module verifies that AnsibleModule works when cwd exists but is unreadable.
# This situation can occur when running tasks as an unprivileged user.
try:
cwd = os.getcwd()
except OSError:
# Compensate for macOS being unable to access cwd as an unprivileged user.
# This test is a no-op in this case.
# Testing for os.getcwd() failures is handled by the test_cwd_missing module.
cwd = '/'
os.chdir(cwd)
module = AnsibleModule(argument_spec=dict())
module.exit_json(before=cwd, after=os.getcwd())
if __name__ == '__main__':
main()
| 746
|
Python
|
.py
| 19
| 33.842105
| 86
| 0.688456
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,592
|
test_recursive_diff.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_recursive_diff.py
|
#!/usr/bin/python
# Copyright: (c) 2020, Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.dict_transformations import recursive_diff
def main():
module = AnsibleModule(
{
'a': {'type': 'dict'},
'b': {'type': 'dict'},
}
)
module.exit_json(
the_diff=recursive_diff(
module.params['a'],
module.params['b'],
),
)
if __name__ == '__main__':
main()
| 643
|
Python
|
.py
| 21
| 24.52381
| 92
| 0.604878
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,593
|
test_failure.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_failure.py
|
#!/usr/bin/python
from __future__ import annotations
results = {}
# Test that we are rooted correctly
# Following files:
# module_utils/yak/zebra/foo.py
from ansible.module_utils.zebra import foo4
results['zebra'] = foo4.data
from ansible.module_utils.basic import AnsibleModule
AnsibleModule(argument_spec=dict()).exit_json(**results)
| 341
|
Python
|
.py
| 10
| 32.8
| 56
| 0.789634
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,594
|
test_optional.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_optional.py
|
#!/usr/bin/python
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
# internal constants to keep pylint from griping about constant-valued conditionals
_private_false = False
_private_true = True
# module_utils import statements nested below any block are considered optional "best-effort" for AnsiballZ to include.
# test a number of different import shapes and nesting types to exercise this...
# first, some nested imports that should succeed...
try:
from ansible.module_utils.urls import fetch_url as yep1
except ImportError:
yep1 = None
try:
import ansible.module_utils.common.text.converters as yep2
except ImportError:
yep2 = None
try:
# optional import from a legit collection
from ansible_collections.testns.testcoll.plugins.module_utils.legit import importme as yep3
except ImportError:
yep3 = None
# and a bunch that should fail to be found, but not break the module_utils payload build in the process...
try:
from ansible.module_utils.bogus import fromnope1
except ImportError:
fromnope1 = None
if _private_false:
from ansible.module_utils.alsobogus import fromnope2
else:
fromnope2 = None
try:
import ansible.module_utils.verybogus
nope1 = ansible.module_utils.verybogus
except ImportError:
nope1 = None
# deepish nested with multiple block types- make sure the AST walker made it all the way down
try:
if _private_true:
if _private_true:
if _private_true:
if _private_true:
try:
import ansible.module_utils.stillbogus as nope2
except ImportError:
raise
except ImportError:
nope2 = None
try:
# optional import from a valid collection with an invalid package
from ansible_collections.testns.testcoll.plugins.module_utils.bogus import collnope1
except ImportError:
collnope1 = None
try:
# optional import from a bogus collection
from ansible_collections.bogusns.boguscoll.plugins.module_utils.bogus import collnope2
except ImportError:
collnope2 = None
module = AnsibleModule(argument_spec={})
if not all([yep1, yep2, yep3]):
module.fail_json(msg='one or more existing optional imports did not resolve')
if any([fromnope1, fromnope2, nope1, nope2, collnope1, collnope2]):
module.fail_json(msg='one or more missing optional imports resolved unexpectedly')
module.exit_json(msg='all missing optional imports behaved as expected')
| 2,643
|
Python
|
.py
| 67
| 34.925373
| 119
| 0.751953
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,595
|
test_datetime.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_datetime.py
|
#!/usr/bin/python
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
import datetime
module = AnsibleModule(argument_spec=dict(
datetime=dict(type=str, required=True),
date=dict(type=str, required=True),
))
result = {
'datetime': datetime.datetime.strptime(module.params.get('datetime'), '%Y-%m-%dT%H:%M:%S'),
'date': datetime.datetime.strptime(module.params.get('date'), '%Y-%m-%d').date(),
}
module.exit_json(**result)
| 606
|
Python
|
.py
| 16
| 35.75
| 95
| 0.739796
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,596
|
test_env_override.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_env_override.py
|
#!/usr/bin/python
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
from __future__ import annotations
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)
| 451
|
Python
|
.py
| 10
| 43.8
| 75
| 0.796804
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,597
|
test_no_log.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_no_log.py
|
#!/usr/bin/python
# (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule, env_fallback
def main():
module = AnsibleModule(
argument_spec=dict(
explicit_pass=dict(type='str', no_log=True),
fallback_pass=dict(type='str', no_log=True, fallback=(env_fallback, ['SECRET_ENV'])),
default_pass=dict(type='str', no_log=True, default='zyx'),
normal=dict(type='str', default='plaintext'),
suboption=dict(
type='dict',
options=dict(
explicit_sub_pass=dict(type='str', no_log=True),
fallback_sub_pass=dict(type='str', no_log=True, fallback=(env_fallback, ['SECRET_SUB_ENV'])),
default_sub_pass=dict(type='str', no_log=True, default='xvu'),
normal=dict(type='str', default='plaintext'),
),
),
),
)
module.exit_json(changed=False)
if __name__ == '__main__':
main()
| 1,144
|
Python
|
.py
| 26
| 33.769231
| 113
| 0.577477
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,598
|
test_cwd_missing.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_cwd_missing.py
|
#!/usr/bin/python
from __future__ import annotations
import os
from ansible.module_utils.basic import AnsibleModule
def main():
# This module verifies that AnsibleModule works when cwd does not exist.
# This situation can occur as a race condition when the following conditions are met:
#
# 1) Execute a module which has high startup overhead prior to instantiating AnsibleModule (0.5s is enough in many cases).
# 2) Run the module async as the last task in a playbook using connection=local (a fire-and-forget task).
# 3) Remove the directory containing the playbook immediately after playbook execution ends (playbook in a temp dir).
#
# To ease testing of this race condition the deletion of cwd is handled in this module.
# This avoids race conditions in the test, including timing cwd deletion between AnsiballZ wrapper execution and AnsibleModule instantiation.
# The timing issue with AnsiballZ is due to cwd checking in the wrapper when code coverage is enabled.
temp = os.path.abspath('temp')
os.mkdir(temp)
os.chdir(temp)
os.rmdir(temp)
module = AnsibleModule(argument_spec=dict())
module.exit_json(before=temp, after=os.getcwd())
if __name__ == '__main__':
main()
| 1,252
|
Python
|
.py
| 23
| 50.086957
| 145
| 0.746721
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,599
|
test_heuristic_log_sanitize.py
|
ansible_ansible/test/integration/targets/module_utils/library/test_heuristic_log_sanitize.py
|
#!/usr/bin/python
from __future__ import annotations
from ansible.module_utils import basic
from ansible.module_utils.basic import AnsibleModule
heuristic_log_sanitize = basic.heuristic_log_sanitize
def heuristic_log_sanitize_spy(*args, **kwargs):
heuristic_log_sanitize_spy.return_value = heuristic_log_sanitize(*args, **kwargs)
return heuristic_log_sanitize_spy.return_value
basic.heuristic_log_sanitize = heuristic_log_sanitize_spy
def main():
module = AnsibleModule(
argument_spec={
'data': {
'type': 'str',
'required': True,
}
},
)
# This test module is testing that the data that will be used for logging
# to syslog is properly sanitized when it includes URLs that contain a password.
#
# As such, we build an expected sanitized string from the input, to
# compare it with the output from heuristic_log_sanitize.
#
# To test this in the same way that modules ultimately operate this test
# monkeypatches ansible.module_utils.basic to store the sanitized data
# for later inspection.
data = module.params['data']
left = data.rindex(':') + 1
right = data.rindex('@')
expected = data[:left] + '********' + data[right:]
sanitized = heuristic_log_sanitize_spy.return_value
if sanitized != expected:
module.fail_json(msg='Invalid match', expected=expected, sanitized=sanitized)
module.exit_json(match=True)
if __name__ == '__main__':
main()
| 1,520
|
Python
|
.py
| 37
| 35.27027
| 85
| 0.684139
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|