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,400
|
fakemodule.py
|
ansible_ansible/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
module: fakemodule
broken:
short_description: fake module
description:
- this is a fake module
version_added: 1.0.0
options:
_notreal:
description: really not a real option
author:
- me
"""
import json
def main():
print(json.dumps(dict(changed=False, source='testns.testcol.fakemodule')))
if __name__ == '__main__':
main()
| 480
|
Python
|
.py
| 20
| 18.85
| 78
| 0.631347
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,401
|
noop.py
|
ansible_ansible/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.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
DOCUMENTATION = """
lookup: noop
broken:
author: Ansible core team
short_description: returns input
description:
- this is a noop
deprecated:
alternative: Use some other lookup
why: Test deprecation
removed_in: '3.0.0'
extends_documentation_fragment:
- testns.testcol2.version_added
"""
EXAMPLES = """
- name: do nothing
debug: msg="{{ lookup('testns.testcol.noop', [1,2,3,4] }}"
"""
RETURN = """
_list:
description: input given
version_added: 1.0.0
"""
from collections.abc import Sequence
from ansible.plugins.lookup import LookupBase
from ansible.errors import AnsibleError
class LookupModule(LookupBase):
def run(self, terms, **kwargs):
if not isinstance(terms, Sequence):
raise AnsibleError("testns.testcol.noop expects a list")
return terms
| 1,026
|
Python
|
.py
| 34
| 25.529412
| 92
| 0.691446
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,402
|
notjsonfile.py
|
ansible_ansible/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.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
DOCUMENTATION = """
cache: notjsonfile
broken:
short_description: JSON formatted files.
description:
- This cache uses JSON formatted, per host, files saved to the filesystem.
author: Ansible Core (@ansible-core)
version_added: 0.7.0
options:
_uri:
required: True
description:
- Path in which the cache plugin will save the JSON files
env:
- name: ANSIBLE_CACHE_PLUGIN_CONNECTION
version_added: 1.2.0
ini:
- key: fact_caching_connection
section: defaults
deprecated:
alternative: none
why: Test deprecation
version: '2.0.0'
_prefix:
description: User defined prefix to use when creating the JSON files
env:
- name: ANSIBLE_CACHE_PLUGIN_PREFIX
version_added: 1.1.0
ini:
- key: fact_caching_prefix
section: defaults
deprecated:
alternative: none
why: Another test deprecation
removed_at_date: '2050-01-01'
_timeout:
default: 86400
description: Expiration timeout for the cache plugin data
env:
- name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
ini:
- key: fact_caching_timeout
section: defaults
vars:
- name: notsjonfile_fact_caching_timeout
version_added: 1.5.0
deprecated:
alternative: do not use a variable
why: Test deprecation
version: '3.0.0'
type: integer
extends_documentation_fragment:
- testns.testcol2.plugin
"""
from ansible.plugins.cache import BaseFileCacheModule
class CacheModule(BaseFileCacheModule):
"""
A caching module backed by json files.
"""
pass
| 2,003
|
Python
|
.py
| 63
| 22.968254
| 92
| 0.604651
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,403
|
test_docs_returns_broken.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_returns_broken.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
---
module: test_docs_returns_broken
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
test:
description: A test return value.
type: str
broken_key: [
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 517
|
Python
|
.py
| 27
| 16.259259
| 52
| 0.677824
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,404
|
double_doc.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/double_doc.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = r"""
name: double_doc
description:
- module also uses 'DOCUMENTATION' in class
"""
class Foo:
# 2nd ref to documentation string, used to trip up tokinzer doc reader
DOCUMENTATION = None
def __init__(self):
pass
| 310
|
Python
|
.py
| 12
| 22.333333
| 74
| 0.708904
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,405
|
test_docs_no_status.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_no_status.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'core'}
DOCUMENTATION = """
---
module: test_docs_no_status
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 532
|
Python
|
.py
| 25
| 17.72
| 52
| 0.644444
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,406
|
test_docs.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: test_docs
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 573
|
Python
|
.py
| 26
| 17.807692
| 52
| 0.620561
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,407
|
test_docs_non_iterable_status.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_non_iterable_status.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': 1,
'supported_by': 'core'}
DOCUMENTATION = """
---
module: test_docs_non_iterable_status
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 575
|
Python
|
.py
| 26
| 17.884615
| 52
| 0.623836
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,408
|
test_no_docs_no_status.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_no_docs_no_status.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'supported_by': 'core'}
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 343
|
Python
|
.py
| 12
| 23.166667
| 52
| 0.627329
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,409
|
test_docs_suboptions.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_suboptions.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
---
module: test_docs_suboptions
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
options:
with_suboptions:
description:
- An option with suboptions.
- Use with care.
type: dict
suboptions:
z_last:
description: The last suboption.
type: str
m_middle:
description:
- The suboption in the middle.
- Has its own suboptions.
suboptions:
a_suboption:
description: A sub-suboption.
type: str
a_first:
description: The first suboption.
type: str
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
test_docs_suboptions=dict(
type='dict',
options=dict(
a_first=dict(type='str'),
m_middle=dict(
type='dict',
options=dict(
a_suboption=dict(type='str')
),
),
z_last=dict(type='str'),
),
),
),
)
module.exit_json()
if __name__ == '__main__':
main()
| 1,539
|
Python
|
.py
| 58
| 15.275862
| 56
| 0.457823
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,410
|
test_no_docs_no_metadata.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_no_docs_no_metadata.py
|
#!/usr/bin/python
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 250
|
Python
|
.py
| 10
| 20.9
| 52
| 0.665236
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,411
|
test_docs_removed_precedence.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_removed_precedence.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
---
module: test_docs_removed_precedence
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
deprecated:
alternative: new_module
why: Updated module released with more functionality
removed_at_date: '2022-06-01'
removed_in: '2.14'
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 595
|
Python
|
.py
| 28
| 18.428571
| 54
| 0.69964
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,412
|
test_docs_returns.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_returns.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
---
module: test_docs_returns
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
z_last:
description: A last result.
type: str
returned: success
m_middle:
description:
- This should be in the middle.
- Has some more data
type: dict
returned: success and 1st of month
contains:
suboption:
description: A suboption.
type: str
choices: [ARF, BARN, c_without_capital_first_letter]
a_first:
description: A first result.
type: str
returned: success
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 902
|
Python
|
.py
| 42
| 17.02381
| 64
| 0.646989
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,413
|
test_docs_no_metadata.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_no_metadata.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
---
module: test_docs_no_metadata
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 442
|
Python
|
.py
| 23
| 16.347826
| 52
| 0.671569
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,414
|
test_no_docs.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_no_docs.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 394
|
Python
|
.py
| 13
| 23.692308
| 52
| 0.599462
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,415
|
test_docs_removed_status.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_removed_status.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['removed'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: test_docs_removed_status
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 580
|
Python
|
.py
| 26
| 18.076923
| 52
| 0.621771
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,416
|
test_no_docs_non_iterable_status.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_no_docs_non_iterable_status.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': 1,
'supported_by': 'core'}
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 376
|
Python
|
.py
| 13
| 22.307692
| 52
| 0.590395
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,417
|
test_docs_missing_description.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_missing_description.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
---
module: test_docs_returns
short_description: Test module
description:
- Test module
author:
- Ansible Core Team
options:
test:
type: str
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
test=dict(type='str'),
),
)
module.exit_json()
if __name__ == '__main__':
main()
| 519
|
Python
|
.py
| 28
| 14.857143
| 52
| 0.633333
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,418
|
test_docs_yaml_anchors.py
|
ansible_ansible/test/integration/targets/ansible-doc/library/test_docs_yaml_anchors.py
|
#!/usr/bin/python
from __future__ import annotations
DOCUMENTATION = """
---
module: test_docs_yaml_anchors
short_description: Test module with YAML anchors in docs
description:
- Test module
author:
- Ansible Core Team
options:
at_the_top: &toplevel_anchor
description:
- Short desc
default: some string
type: str
last_one: *toplevel_anchor
egress:
description:
- Egress firewall rules
type: list
elements: dict
suboptions: &sub_anchor
port:
description:
- Rule port
type: int
required: true
ingress:
description:
- Ingress firewall rules
type: list
elements: dict
suboptions: *sub_anchor
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
at_the_top=dict(type='str', default='some string'),
last_one=dict(type='str', default='some string'),
egress=dict(type='list', elements='dict', options=dict(
port=dict(type='int', required=True),
)),
ingress=dict(type='list', elements='dict', options=dict(
port=dict(type='int', required=True),
)),
),
)
module.exit_json()
if __name__ == '__main__':
main()
| 1,390
|
Python
|
.py
| 56
| 18.571429
| 68
| 0.6
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,419
|
respawnme.py
|
ansible_ansible/test/integration/targets/module_utils_common.respawn/library/respawnme.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
import os
import sys
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.respawn import respawn_module, has_respawned
def main():
mod = AnsibleModule(argument_spec=dict(
mode=dict(required=True, choices=['multi_respawn', 'no_respawn', 'respawn'])
))
# just return info about what interpreter we're currently running under
if mod.params['mode'] == 'no_respawn':
mod.exit_json(interpreter_path=sys.executable)
elif mod.params['mode'] == 'respawn':
if not has_respawned():
new_interpreter = os.path.join(mod.tmpdir, 'anotherpython')
os.symlink(sys.executable, new_interpreter)
respawn_module(interpreter_path=new_interpreter)
# respawn should always exit internally- if we continue executing here, it's a bug
raise Exception('FAIL, should never reach this line')
else:
# return the current interpreter, as well as a signal that we created a different one
mod.exit_json(created_interpreter=sys.executable, interpreter_path=sys.executable)
elif mod.params['mode'] == 'multi_respawn':
# blindly respawn with the current interpreter, the second time should bomb
respawn_module(sys.executable)
# shouldn't be any way for us to fall through, but just in case, that's also a bug
raise Exception('FAIL, should never reach this code')
if __name__ == '__main__':
main()
| 1,655
|
Python
|
.py
| 32
| 45.125
| 97
| 0.699132
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,420
|
removeoption.py
|
ansible_ansible/test/integration/targets/deprecations/library/removeoption.py
|
# -*- coding: utf-8 -*-
# Copyright: 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 = r"""
---
module: removeoption
short_description: noop
description: does nothing, test for removal of option
options:
one:
description:
- first option
type: bool
default: no
two:
description:
- second option
deprecated:
removed_in: '3.30'
why: cause i wanna test this!
alternatives: none needed
notes:
- Just noop to test module deprecation
seealso:
- module: willremove
author:
- Ansible Core Team
attributes:
action:
support: full
async:
support: full
bypass_host_loop:
support: none
check_mode:
support: full
diff_mode:
support: none
platform:
platforms: all
"""
EXAMPLES = r"""
- name: useless
remove_option:
one: true
two: /etc/file.conf
"""
RETURN = r"""
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
one=dict(type='bool', default='no'),
two=dict(type='str', removed_in_version='3.30'),
),
supports_check_mode=True
)
one = module.params['one']
two = module.params['two']
result = {'yolo': 'lola'}
module.exit_json(**result)
if __name__ == '__main__':
main()
| 1,442
|
Python
|
.py
| 65
| 17.876923
| 92
| 0.646628
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,421
|
willremove.py
|
ansible_ansible/test/integration/targets/deprecations/library/willremove.py
|
# -*- coding: utf-8 -*-
# Copyright: 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 = r"""
---
module: willremove
version_added: histerical
short_description: does nothing
description: does nothing, this is deprecation test
deprecated:
removed_in: '3.30'
why: cause i wanna!
alternatives: no soup for you!
options:
one:
description:
- first option
type: bool
default: no
two:
description:
- second option
notes:
- Just noop to test module deprecation
seealso:
- module: removeoption
author:
- Ansible Core Team
attributes:
action:
support: full
async:
support: full
bypass_host_loop:
support: none
check_mode:
support: full
diff_mode:
support: none
platform:
platforms: all
"""
EXAMPLES = r"""
- name: useless
willremove:
one: true
two: /etc/file.conf
"""
RETURN = r"""
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
one=dict(type='bool', default='no'),
two=dict(type='str'),
),
supports_check_mode=True
)
one = module.params['one']
two = module.params['two']
result = {'yolo': 'lola'}
module.exit_json(**result)
if __name__ == '__main__':
main()
| 1,423
|
Python
|
.py
| 66
| 17.545455
| 92
| 0.656994
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,422
|
notjsonfile.py
|
ansible_ansible/test/integration/targets/deprecations/cache_plugins/notjsonfile.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
DOCUMENTATION = """
cache: notjsonfile
short_description: NotJSON cache plugin
description: This cache uses is NOT JSON
author: Ansible Core (@ansible-core)
version_added: 0.7.0
options:
_uri:
required: True
description:
- Path in which the cache plugin will save the JSON files
env:
- name: ANSIBLE_CACHE_PLUGIN_CONNECTION
version_added: 1.2.0
ini:
- key: fact_caching_connection
section: notjsonfile_cache
- key: fact_caching_connection
section: defaults
_prefix:
description: User defined prefix to use when creating the JSON files
env:
- name: ANSIBLE_CACHE_PLUGIN_PREFIX
version_added: 1.1.0
ini:
- key: fact_caching_prefix
section: defaults
- key: fact_caching_prefix
section: notjson_cache
deprecated:
alternative: section is notjsonfile_cache
why: Another test deprecation
removed_at_date: '2050-01-01'
- key: fact_caching_prefix
section: notjsonfile_cache
_timeout:
default: 86400
description: Expiration timeout for the cache plugin data
env:
- name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
- name: ANSIBLE_NOTJSON_CACHE_PLUGIN_TIMEOUT
deprecated:
alternative: do not use a variable
why: Test deprecation
version: '3.0.0'
ini:
- key: fact_caching_timeout
section: defaults
- key: fact_caching_timeout
section: notjsonfile_cache
vars:
- name: notsjonfile_fact_caching_timeout
version_added: 1.5.0
type: integer
removeme:
default: 86400
description: Expiration timeout for the cache plugin data
deprecated:
alternative: cause i need to test it
why: Test deprecation
version: '2.0.0'
env:
- name: ANSIBLE_NOTJSON_CACHE_PLUGIN_REMOVEME
"""
from ansible.plugins.cache import BaseFileCacheModule
class CacheModule(BaseFileCacheModule):
"""
A caching module backed by json files.
"""
def _dump(self):
pass
def _load(self):
pass
| 2,505
|
Python
|
.py
| 76
| 23.671053
| 92
| 0.602146
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,423
|
network_noop.py
|
ansible_ansible/test/integration/targets/connection_local/connection_plugins/network_noop.py
|
# (c) 2024 Red Hat Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
connection: network_noop
author: ansible-core
short_description: legacy-ish connection plugin with only minimal config
description:
- A wrapper around NetworkConnectionBase to test that the default attributes don't cause internal errors in TE.
options:
persistent_log_messages:
type: boolean
description:
- This flag will enable logging the command executed and response received from
target device in the ansible log file. For this option to work 'log_path' ansible
configuration option is required to be set to a file path with write access.
- Be sure to fully understand the security implications of enabling this
option as it could create a security vulnerability by logging sensitive information in log file.
default: False
ini:
- section: persistent_connection
key: log_messages
env:
- name: ANSIBLE_PERSISTENT_LOG_MESSAGES
vars:
- name: ansible_persistent_log_messages
persistent_command_timeout:
type: int
description:
- Configures, in seconds, the amount of time to wait for a command to
return from the remote device. If this timer is exceeded before the
command returns, the connection plugin will raise an exception and
close.
default: 30
ini:
- section: persistent_connection
key: command_timeout
env:
- name: ANSIBLE_PERSISTENT_COMMAND_TIMEOUT
vars:
- name: ansible_command_timeout
persistent_connect_timeout:
type: int
description:
- Configures, in seconds, the amount of time to wait when trying to
initially establish a persistent connection. If this value expires
before the connection to the remote device is completed, the connection
will fail.
default: 30
ini:
- section: persistent_connection
key: connect_timeout
env:
- name: ANSIBLE_PERSISTENT_CONNECT_TIMEOUT
vars:
extends_documentation_fragment:
- connection_pipelining
"""
from ansible.plugins.connection import NetworkConnectionBase, ensure_connect
from ansible.utils.display import Display
display = Display()
class Connection(NetworkConnectionBase):
transport = 'network_noop'
has_pipelining = True
def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
@ensure_connect
def exec_command(self, *args, **kwargs):
return super(Connection, self).exec_command(*args, **kwargs)
@ensure_connect
def put_file(self, *args, **kwargs):
return super(Connection, self).put_file(*args, **kwargs)
@ensure_connect
def fetch_file(self, *args, **kwargs):
return super(Connection, self).fetch_file(*args, **kwargs)
def _connect(self):
if not self.connected:
self._connected = True
display.vvv("ESTABLISH NEW CONNECTION")
def close(self):
if self.connected:
display.vvv("CLOSING CONNECTION")
super(Connection, self).close()
| 3,238
|
Python
|
.py
| 83
| 33.216867
| 113
| 0.707922
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,424
|
test_echo_module.py
|
ansible_ansible/test/integration/targets/interpreter_discovery_python/library/test_echo_module.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
import sys
from ansible.module_utils.basic import AnsibleModule
def main():
result = dict(changed=False)
module = AnsibleModule(argument_spec=dict(
facts=dict(type=dict, default={})
))
result['ansible_facts'] = module.params['facts']
result['running_python_interpreter'] = sys.executable
module.exit_json(**result)
if __name__ == '__main__':
main()
| 671
|
Python
|
.py
| 18
| 33.722222
| 92
| 0.698289
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,425
|
test_ansible_forked.py
|
ansible_ansible/test/integration/targets/ansible-test-units-forked/ansible_collections/ns/col/tests/unit/plugins/modules/test_ansible_forked.py
|
"""Unit tests to verify the functionality of the ansible-forked pytest plugin."""
from __future__ import annotations
import os
import pytest
import signal
import sys
import warnings
warnings.warn("This verifies that warnings generated during test collection are reported.")
@pytest.mark.xfail
def test_kill_xfail():
os.kill(os.getpid(), signal.SIGKILL) # causes pytest to report stdout and stderr
def test_kill():
os.kill(os.getpid(), signal.SIGKILL) # causes pytest to report stdout and stderr
@pytest.mark.xfail
def test_exception_xfail():
sys.stdout.write("This stdout message should be hidden due to xfail.")
sys.stderr.write("This stderr message should be hidden due to xfail.")
raise Exception("This error is expected, but should be hidden due to xfail.")
def test_exception():
sys.stdout.write("This stdout message should be reported since we're throwing an exception.")
sys.stderr.write("This stderr message should be reported since we're throwing an exception.")
raise Exception("This error is expected and should be visible.")
def test_warning():
warnings.warn("This verifies that warnings generated at test time are reported.")
def test_passed():
pass
| 1,221
|
Python
|
.py
| 26
| 43.807692
| 97
| 0.769296
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,426
|
vendor1.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor1.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: vendor1
short_description: lookup
description: Lookup.
author:
- Ansible Core Team
"""
EXAMPLES = """#"""
RETURN = """#"""
from ansible.plugins.lookup import LookupBase
# noinspection PyUnresolvedReferences
from ansible.plugins import loader # import the loader to verify it works when the collection loader has already been loaded # pylint: disable=unused-import
try:
import demo # pylint: disable=unused-import
except ImportError:
pass
else:
raise Exception('demo import found when it should not be')
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
return terms
| 845
|
Python
|
.py
| 24
| 32.458333
| 158
| 0.758918
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,427
|
vendor2.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor2.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: vendor2
short_description: lookup
description: Lookup.
author:
- Ansible Core Team
"""
EXAMPLES = """#"""
RETURN = """#"""
from ansible.plugins.lookup import LookupBase
# noinspection PyUnresolvedReferences
from ansible.plugins import loader # import the loader to verify it works when the collection loader has already been loaded # pylint: disable=unused-import
try:
import demo # pylint: disable=unused-import
except ImportError:
pass
else:
raise Exception('demo import found when it should not be')
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
return terms
| 845
|
Python
|
.py
| 24
| 32.458333
| 158
| 0.758918
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,428
|
toml.py
|
ansible_ansible/test/integration/targets/ansible-inventory/filter_plugins/toml.py
|
# (c) 2017, 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
import functools
from ansible.plugins.inventory.toml import HAS_TOML, toml_dumps
try:
from ansible.plugins.inventory.toml import toml
except ImportError:
pass
from ansible.errors import AnsibleFilterError
from ansible.module_utils.common.text.converters import to_text
from ansible.module_utils.common._collections_compat import MutableMapping
from ansible.module_utils.six import string_types
def _check_toml(func):
@functools.wraps(func)
def inner(o):
if not HAS_TOML:
raise AnsibleFilterError('The %s filter plugin requires the python "toml" library' % func.__name__)
return func(o)
return inner
@_check_toml
def from_toml(o):
if not isinstance(o, string_types):
raise AnsibleFilterError('from_toml requires a string, got %s' % type(o))
return toml.loads(to_text(o, errors='surrogate_or_strict'))
@_check_toml
def to_toml(o):
if not isinstance(o, MutableMapping):
raise AnsibleFilterError('to_toml requires a dict, got %s' % type(o))
return to_text(toml_dumps(o), errors='surrogate_or_strict')
class FilterModule(object):
def filters(self):
return {
'to_toml': to_toml,
'from_toml': from_toml
}
| 1,402
|
Python
|
.py
| 36
| 34.166667
| 111
| 0.717873
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,429
|
is_mac.py
|
ansible_ansible/test/integration/targets/common_network/test_plugins/is_mac.py
|
# 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.common.network import is_mac
class TestModule(object):
def tests(self):
return {
'is_mac': is_mac,
}
| 342
|
Python
|
.py
| 9
| 33
| 92
| 0.683891
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,430
|
testserver.py
|
ansible_ansible/test/integration/targets/wait_for/files/testserver.py
|
from __future__ import annotations
import http.server
import socketserver
import sys
if __name__ == '__main__':
PORT = int(sys.argv[1])
Handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
httpd.serve_forever()
| 275
|
Python
|
.py
| 9
| 27.555556
| 55
| 0.719697
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,431
|
write_utf16.py
|
ansible_ansible/test/integration/targets/wait_for/files/write_utf16.py
|
from __future__ import annotations
import sys
# utf16 encoded bytes
# to ensure wait_for doesn't have any encoding errors
data = (
b'\xff\xfep\x00r\x00e\x00m\x00i\x00\xe8\x00r\x00e\x00 \x00i\x00s\x00 '
b'\x00f\x00i\x00r\x00s\x00t\x00\n\x00p\x00r\x00e\x00m\x00i\x00e\x00'
b'\x00\x03r\x00e\x00 \x00i\x00s\x00 \x00s\x00l\x00i\x00g\x00h\x00t\x00'
b'l\x00y\x00 \x00d\x00i\x00f\x00f\x00e\x00r\x00e\x00n\x00t\x00\n\x00\x1a'
b'\x048\x04@\x048\x04;\x04;\x048\x04F\x040\x04 \x00i\x00s\x00 \x00C\x00y'
b'\x00r\x00i\x00l\x00l\x00i\x00c\x00\n\x00\x01\xd8\x00\xdc \x00a\x00m'
b'\x00 \x00D\x00e\x00s\x00e\x00r\x00e\x00t\x00\n\x00\n'
b'completed\n'
)
with open(sys.argv[1], 'wb') as f:
f.write(data)
| 723
|
Python
|
.py
| 16
| 41.75
| 77
| 0.705966
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,432
|
zombie.py
|
ansible_ansible/test/integration/targets/wait_for/files/zombie.py
|
from __future__ import annotations
import os
import sys
import time
child_pid = os.fork()
if child_pid > 0:
time.sleep(60)
else:
sys.exit()
| 151
|
Python
|
.py
| 9
| 14.555556
| 34
| 0.726619
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,433
|
track_connections.py
|
ansible_ansible/test/integration/targets/callback_results/callback_plugins/track_connections.py
|
# Copyright: Contributors to the 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 = """
name: track_connections
short_description: Track connection plugins used for hosts
description:
- Track connection plugins used for hosts
type: aggregate
"""
import json
from collections import defaultdict
from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_NAME = 'track_connections'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._conntrack = defaultdict(lambda : defaultdict(int))
def _track(self, result, *args, **kwargs):
host = result._host.get_name()
task = result._task
self._conntrack[host][task.connection] += 1
v2_runner_on_ok = v2_runner_on_failed = _track
v2_runner_on_async_poll = v2_runner_on_async_ok = v2_runner_on_async_failed = _track
v2_runner_item_on_ok = v2_runner_item_on_failed = _track
def v2_playbook_on_stats(self, stats):
self._display.display(json.dumps(self._conntrack, indent=4))
| 1,250
|
Python
|
.py
| 29
| 38
| 92
| 0.702479
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,434
|
result_pickle_error.py
|
ansible_ansible/test/integration/targets/result_pickle_error/action_plugins/result_pickle_error.py
|
# -*- coding: utf-8 -*-
# Copyright: Contributors to the 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
from jinja2 import Undefined
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
return {'obj': Undefined('obj')}
| 399
|
Python
|
.py
| 9
| 41.444444
| 92
| 0.745455
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,435
|
dnf_module_list.py
|
ansible_ansible/test/integration/targets/dnf/filter_plugins/dnf_module_list.py
|
# Copyright: Contributors to the 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 collections import Counter
def parse_module_list(stdout):
lines = stdout.splitlines()
name_offset = 0
empty_offset = -1
modules = []
for i, line in enumerate(lines):
if line.startswith('Name '):
name_offset = i + 1
if not line.strip():
empty_offset = i
for line in lines[name_offset:empty_offset]:
cols = line.split()[:3]
modules.append({
'name': cols[0],
'version': cols[1],
'profile': cols[2].rstrip(','), # Just the first profile
})
return modules
def get_first_single_version_module(stdout):
modules = parse_module_list(stdout)
name = Counter([m['name'] for m in modules]).most_common()[-1][0]
module, = [m for m in modules if m['name'] == name]
return module
class FilterModule:
def filters(self):
return {
'get_first_single_version_module': get_first_single_version_module,
}
| 1,149
|
Python
|
.py
| 32
| 29.15625
| 92
| 0.623986
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,436
|
httptester_kinit.py
|
ansible_ansible/test/integration/targets/prepare_http_tests/library/httptester_kinit.py
|
#!/usr/bin/python
# 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
DOCUMENTATION = r"""
---
module: httptester_kinit
short_description: Get Kerberos ticket
description: Get Kerberos ticket using kinit non-interactively.
options:
username:
description: The username to get the ticket for.
required: true
type: str
password:
description: The password for I(username).
required; true
type: str
author:
- Ansible Project
"""
EXAMPLES = r"""
#
"""
RETURN = r"""
#
"""
import contextlib
import errno
import os
import subprocess
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_bytes, to_text
try:
import configparser
except ImportError:
import ConfigParser as configparser
@contextlib.contextmanager
def env_path(name, value, default_value):
""" Adds a value to a PATH-like env var and preserve the existing value if present. """
orig_value = os.environ.get(name, None)
os.environ[name] = '%s:%s' % (value, orig_value or default_value)
try:
yield
finally:
if orig_value:
os.environ[name] = orig_value
else:
del os.environ[name]
@contextlib.contextmanager
def krb5_conf(module, config):
""" Runs with a custom krb5.conf file that extends the existing config if present. """
if config:
ini_config = configparser.ConfigParser()
for section, entries in config.items():
ini_config.add_section(section)
for key, value in entries.items():
ini_config.set(section, key, value)
config_path = os.path.join(module.tmpdir, 'krb5.conf')
with open(config_path, mode='wt') as config_fd:
ini_config.write(config_fd)
with env_path('KRB5_CONFIG', config_path, '/etc/krb5.conf'):
yield
else:
yield
def main():
module_args = dict(
username=dict(type='str', required=True),
password=dict(type='str', required=True, no_log=True),
)
module = AnsibleModule(
argument_spec=module_args,
required_together=[('username', 'password')],
)
# Heimdal has a few quirks that we want to paper over in this module
# 1. KRB5_TRACE does not work in any released version (<=7.7), we need to use a custom krb5.config to enable it
# 2. When reading the password it reads from the pty not stdin by default causing an issue with subprocess. We
# can control that behaviour with '--password-file=STDIN'
# Also need to set the custom path to krb5-config and kinit as FreeBSD relies on the newer Heimdal version in the
# port package.
sysname = os.uname()[0]
prefix = '/usr/local/bin/' if sysname == 'FreeBSD' else ''
is_heimdal = sysname in ['Darwin', 'FreeBSD']
# Debugging purposes, get the Kerberos version. On platforms like OpenSUSE this may not be on the PATH.
try:
process = subprocess.Popen(['%skrb5-config' % prefix, '--version'], stdout=subprocess.PIPE)
stdout, stderr = process.communicate()
version = to_text(stdout)
except OSError as e:
if e.errno != errno.ENOENT:
raise
version = 'Unknown (no krb5-config)'
kinit_args = ['%skinit' % prefix]
config = {}
if is_heimdal:
kinit_args.append('--password-file=STDIN')
config['logging'] = {'krb5': 'FILE:/dev/stdout'}
kinit_args.append(to_text(module.params['username'], errors='surrogate_or_strict'))
with krb5_conf(module, config):
# Weirdly setting KRB5_CONFIG in the modules environment block does not work unless we pass it in explicitly.
# Take a copy of the existing environment to make sure the process has the same env vars as ours. Also set
# KRB5_TRACE to output and debug logs helping to identify problems when calling kinit with MIT.
kinit_env = os.environ.copy()
kinit_env['KRB5_TRACE'] = '/dev/stdout'
process = subprocess.Popen(kinit_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=kinit_env)
stdout, stderr = process.communicate(to_bytes(module.params['password'], errors='surrogate_or_strict') + b'\n')
rc = process.returncode
module.exit_json(changed=True, stdout=to_text(stdout), stderr=to_text(stderr), rc=rc, version=version)
if __name__ == '__main__':
main()
| 4,560
|
Python
|
.py
| 111
| 35.171171
| 119
| 0.674655
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,437
|
win_ping.py
|
ansible_ansible/test/integration/targets/windows-minimal/library/win_ping.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>, and others
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# this is a windows documentation stub. actual code lives in the .ps1
# file of the same name
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = r"""
---
module: win_ping
version_added: "1.7"
short_description: A windows version of the classic ping module
description:
- Checks management connectivity of a windows host.
- This is NOT ICMP ping, this is just a trivial test module.
- For non-Windows targets, use the M(ping) module instead.
- For Network targets, use the M(net_ping) module instead.
options:
data:
description:
- Alternate data to return instead of 'pong'.
- If this parameter is set to C(crash), the module will cause an exception.
type: str
default: pong
seealso:
- module: ping
author:
- Chris Church (@cchurch)
"""
EXAMPLES = r"""
# Test connectivity to a windows host
# ansible winserver -m win_ping
- name: Example from an Ansible Playbook
win_ping:
- name: Induce an exception to see what happens
win_ping:
data: crash
"""
RETURN = r"""
ping:
description: Value provided with the data parameter.
returned: success
type: str
sample: pong
"""
| 1,451
|
Python
|
.py
| 47
| 27.617021
| 92
| 0.702006
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,438
|
boo.py
|
ansible_ansible/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-foo/ansible_collections/python/dist/plugins/modules/boo.py
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Say hello in Ukrainian."""
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec={
'name': {'default': 'світ'},
},
)
name = module.params['name']
module.exit_json(
msg='Greeting {name} completed.'.
format(name=name.title()),
greeting='Привіт, {name}!'.format(name=name),
)
if __name__ == '__main__':
main()
| 582
|
Python
|
.py
| 18
| 26.055556
| 92
| 0.616514
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,439
|
boo.py
|
ansible_ansible/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-boo/ansible_collections/python/dist/plugins/modules/boo.py
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Say hello."""
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec={
'name': {'default': 'world'},
},
)
name = module.params['name']
module.exit_json(
msg='Greeting {name} completed.'.
format(name=name.title()),
greeting='Hello, {name}!'.format(name=name),
)
if __name__ == '__main__':
main()
| 559
|
Python
|
.py
| 18
| 25.333333
| 92
| 0.610902
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,440
|
test_inventory.py
|
ansible_ansible/test/integration/targets/plugin_config_for_inventory/test_inventory.py
|
from __future__ import annotations
DOCUMENTATION = """
name: test_inventory
plugin_type: inventory
authors:
- Pierre-Louis Bonicoli (@pilou-)
short_description: test inventory
description:
- test inventory (fetch parameters using config API)
options:
departments:
description: test parameter
type: list
default:
- seine-et-marne
- haute-garonne
required: False
cache:
description: cache
type: bool
default: false
required: False
cache_plugin:
description: cache plugin
type: str
default: none
required: False
cache_timeout:
description: test cache parameter
type: integer
default: 7
required: False
cache_connection:
description: cache connection
type: str
default: /tmp/foo
required: False
cache_prefix:
description: cache prefix
type: str
default: prefix_
required: False
"""
EXAMPLES = """
# Example command line: ansible-inventory --list -i test_inventory.yml
plugin: test_inventory
departments:
- paris
"""
from ansible.plugins.inventory import BaseInventoryPlugin
class InventoryModule(BaseInventoryPlugin):
NAME = 'test_inventory'
def verify_file(self, path):
return True
def parse(self, inventory, loader, path, cache=True):
super(InventoryModule, self).parse(inventory, loader, path)
config_data = self._read_config_data(path=path)
self._consume_options(config_data)
departments = self.get_option('departments')
group = 'test_group'
host = 'test_host'
self.inventory.add_group(group)
self.inventory.add_host(group=group, host=host)
self.inventory.set_variable(host, 'departments', departments)
# Ensure the timeout we're given gets sent to the cache plugin
if self.get_option('cache'):
given_timeout = self.get_option('cache_timeout')
cache_timeout = self._cache._plugin.get_option('_timeout')
self.inventory.set_variable(host, 'given_timeout', given_timeout)
self.inventory.set_variable(host, 'cache_timeout', cache_timeout)
| 2,412
|
Python
|
.py
| 70
| 25.214286
| 77
| 0.614427
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,441
|
none.py
|
ansible_ansible/test/integration/targets/plugin_config_for_inventory/cache_plugins/none.py
|
# (c) 2014, Brian Coca, Josh Drake, et al
# (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
from ansible.plugins.cache import BaseCacheModule
DOCUMENTATION = """
cache: none
short_description: write-only cache (no cache)
description:
- No caching at all
version_added: historical
author: core team (@ansible-core)
options:
_timeout:
default: 86400
description: Expiration timeout for the cache plugin data
env:
- name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
ini:
- key: fact_caching_timeout
section: defaults
type: integer
"""
class CacheModule(BaseCacheModule):
def __init__(self, *args, **kwargs):
super(CacheModule, self).__init__(*args, **kwargs)
self.empty = {}
self._timeout = self.get_option('_timeout')
def get(self, key):
return self.empty.get(key)
def set(self, key, value):
return value
def keys(self):
return self.empty.keys()
def contains(self, key):
return key in self.empty
def delete(self, key):
del self.emtpy[key]
def flush(self):
self.empty = {}
def copy(self):
return self.empty.copy()
def __getstate__(self):
return self.copy()
def __setstate__(self, data):
self.empty = data
| 1,453
|
Python
|
.py
| 46
| 24.913043
| 92
| 0.627155
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,442
|
test.py
|
ansible_ansible/test/integration/targets/infra/library/test.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(),
)
result = {
'selinux_special_fs': module._selinux_special_fs,
'tmpdir': module._tmpdir,
'keep_remote_files': module._keep_remote_files,
'version': module.ansible_version,
}
module.exit_json(**result)
if __name__ == '__main__':
main()
| 493
|
Python
|
.py
| 17
| 23.882353
| 57
| 0.629787
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,443
|
require_enabled.py
|
ansible_ansible/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py
|
from __future__ import annotations
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
REQUIRES_ENABLED = True
def get_vars(self, loader, path, entities):
return {'require_enabled': True}
| 238
|
Python
|
.py
| 6
| 35.333333
| 47
| 0.758772
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,444
|
implicitly_auto_enabled.py
|
ansible_ansible/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py
|
from __future__ import annotations
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities):
return {'implicitly_auto_enabled': True}
| 218
|
Python
|
.py
| 5
| 39.4
| 48
| 0.770335
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,445
|
auto_enabled.py
|
ansible_ansible/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py
|
from __future__ import annotations
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
REQUIRES_ENABLED = False
def get_vars(self, loader, path, entities):
return {'explicitly_auto_enabled': True}
| 247
|
Python
|
.py
| 6
| 36.833333
| 48
| 0.763713
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,446
|
v2_vars_plugin.py
|
ansible_ansible/test/integration/targets/old_style_vars_plugins/deprecation_warning/v2_vars_plugin.py
|
from __future__ import annotations
class VarsModule:
def get_host_vars(self, entity):
return {}
def get_group_vars(self, entity):
return {}
| 167
|
Python
|
.py
| 6
| 22.333333
| 37
| 0.651899
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,447
|
auto_role_vars.py
|
ansible_ansible/test/integration/targets/old_style_vars_plugins/roles/a/vars_plugins/auto_role_vars.py
|
from __future__ import annotations
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
# Implicitly
# REQUIRES_ENABLED = False
def get_vars(self, loader, path, entities):
return {'auto_role_var': True}
| 256
|
Python
|
.py
| 7
| 32.142857
| 47
| 0.738776
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,448
|
bad.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py
|
from __future__ import annotations
import tempfile
try:
import urllib2 # intentionally trigger pylint ansible-bad-import error # pylint: disable=unused-import
except ImportError:
urllib2 = None
try:
from urllib2 import Request # intentionally trigger pylint ansible-bad-import-from error # pylint: disable=unused-import
except ImportError:
Request = None
tempfile.mktemp() # intentionally trigger pylint ansible-bad-function error
| 456
|
Python
|
.py
| 11
| 38.636364
| 126
| 0.795918
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,449
|
check_pylint.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/plugin_utils/check_pylint.py
|
"""
These test cases verify ansible-test version constraints for pylint and its dependencies across Python versions.
The initial test cases were discovered while testing various Python versions against ansible/ansible.
"""
from __future__ import annotations
# Python 3.8 fails with astroid 2.2.5 but works on 2.3.3
# syntax-error: Cannot import 'string' due to syntax error 'invalid syntax (<unknown>, line 109)'
# Python 3.9 fails with astroid 2.2.5 but works on 2.3.3
# syntax-error: Cannot import 'string' due to syntax error 'invalid syntax (<unknown>, line 104)'
import string # pylint: disable=unused-import
# Python 3.9 fails with pylint 2.3.1 or 2.4.4 with astroid 2.3.3 but works with pylint 2.5.0 and astroid 2.4.0
# 'Call' object has no attribute 'value'
result = {None: None}[{}.get('something')]
foo = {}.keys()
| 847
|
Python
|
.py
| 14
| 59.285714
| 112
| 0.746988
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,450
|
bad.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py
|
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
module: bad
short_description: Bad test module
description: Bad test module.
author:
- Ansible Core Team
"""
EXAMPLES = """
- bad:
"""
RETURN = """"""
from ansible.module_utils.basic import AnsibleModule
from ansible import constants # intentionally trigger pylint ansible-bad-module-import error # pylint: disable=unused-import
def main():
module = AnsibleModule(
argument_spec=dict(),
)
module.exit_json()
if __name__ == '__main__':
main()
| 646
|
Python
|
.py
| 23
| 25.521739
| 126
| 0.717781
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,451
|
world.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.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: world
short_description: World lookup
description: A world lookup.
author:
- Ansible Core Team
"""
EXAMPLES = """
- debug:
msg: "{{ lookup('ns.col.world') }}"
"""
RETURN = """ # """
from ansible.plugins.lookup import LookupBase
from ansible import constants # pylint: disable=unused-import
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
return terms
| 622
|
Python
|
.py
| 20
| 28.4
| 92
| 0.723906
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,452
|
bad.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.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: bad
short_description: Bad lookup
description: A bad lookup.
author:
- Ansible Core Team
"""
EXAMPLES = """
- debug:
msg: "{{ lookup('ns.col.bad') }}"
"""
RETURN = """ # """
from ansible.plugins.lookup import LookupBase
from ansible import constants # pylint: disable=unused-import
import lxml # pylint: disable=unused-import
class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
return terms
| 660
|
Python
|
.py
| 21
| 28.761905
| 92
| 0.725397
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,453
|
bad.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
# This is not an allowed import, but since this file is in a plugins/ subdirectory that is not checked,
# the import sanity test will not complain.
import lxml # pylint: disable=unused-import
| 323
|
Python
|
.py
| 5
| 63.2
| 103
| 0.772152
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,454
|
casting.py
|
ansible_ansible/test/integration/targets/config/lookup_plugins/casting.py
|
# (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
DOCUMENTATION = """
name: casting
author: Ansible Core Team
version_added: histerical
short_description: returns what you gave it
description:
- this is mostly a noop
options:
_terms:
description: stuff to pass through
test_list:
description: does nothihng, just for testing values
type: list
test_int:
description: does nothihng, just to test casting
type: int
test_bool:
description: does nothihng, just to test casting
type: bool
test_str:
description: does nothihng, just to test casting
type: str
"""
EXAMPLES = """
- name: like some other plugins, this is mostly useless
debug: msg={{ q('casting', [1,2,3])}}
"""
RETURN = """
_list:
description: basically the same as you fed in
type: list
elements: raw
"""
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
for cast in (list, int, bool, str):
option = 'test_%s' % str(cast).replace("<class '", '').replace("'>", '')
value = self.get_option(option)
if value is None or type(value) is cast:
continue
raise Exception('%s is not a %s: got %s/%s' % (option, cast, type(value), value))
return terms
| 1,634
|
Python
|
.py
| 47
| 27.425532
| 93
| 0.619048
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,455
|
bogus.py
|
ansible_ansible/test/integration/targets/config/lookup_plugins/bogus.py
|
# (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
DOCUMENTATION = """
name: bogus
author: Ansible Core Team
version_added: histerical
short_description: returns what you gave it
description:
- this is mostly a noop
options:
_terms:
description: stuff to pass through
test_list:
description: does nothihng, just for testing values
type: list
choices:
- Dan
- Yevgeni
- Carla
- Manuela
"""
EXAMPLES = """
- name: like some other plugins, this is mostly useless
debug: msg={{ q('bogus', [1,2,3])}}
"""
RETURN = """
_list:
description: basically the same as you fed in
type: list
elements: raw
"""
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
dump = self.get_option('test_list')
return terms
| 1,142
|
Python
|
.py
| 38
| 23.447368
| 92
| 0.62946
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,456
|
casting_individual.py
|
ansible_ansible/test/integration/targets/config/lookup_plugins/casting_individual.py
|
# (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
DOCUMENTATION = """
name: casting_individual
author: Ansible Core Team
version_added: histerical
short_description: returns what you gave it
description:
- this is mostly a noop
options:
_terms:
description: stuff to pass through
test_list:
description: does nothihng, just for testing values
type: list
test_int:
description: does nothihng, just to test casting
type: int
test_bool:
description: does nothihng, just to test casting
type: bool
test_str:
description: does nothihng, just to test casting
type: str
"""
EXAMPLES = """
- name: like some other plugins, this is mostly useless
debug: msg={{ q('casting_individual', [1,2,3])}}
"""
RETURN = """
_list:
description: basically the same as you fed in
type: list
elements: raw
"""
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
for cast in (list, int, bool, str):
option = 'test_%s' % str(cast).replace("<class '", '').replace("'>", '')
if option in kwargs:
self.set_option(option, kwargs[option])
value = self.get_option(option)
if type(value) is not cast:
raise Exception('%s is not a %s: got %s/%s' % (option, cast, type(value), value))
return terms
| 1,659
|
Python
|
.py
| 47
| 27.553191
| 101
| 0.611493
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,457
|
types.py
|
ansible_ansible/test/integration/targets/config/lookup_plugins/types.py
|
# (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
DOCUMENTATION = """
name: types
author: Ansible Core Team
version_added: histerical
short_description: returns what you gave it
description:
- this is mostly a noop
options:
_terms:
description: stuff to pass through
valid:
description: does nothihng, just for testing values
type: list
ini:
- section: list_values
key: valid
env:
- name: ANSIBLE_TYPES_VALID
vars:
- name: ansible_types_valid
mustunquote:
description: does nothihng, just for testing values
type: list
ini:
- section: list_values
key: mustunquote
env:
- name: ANSIBLE_TYPES_MUSTUNQUOTE
vars:
- name: ansible_types_mustunquote
notvalid:
description: does nothihng, just for testing values
type: list
ini:
- section: list_values
key: notvalid
env:
- name: ANSIBLE_TYPES_NOTVALID
vars:
- name: ansible_types_notvalid
totallynotvalid:
description: does nothihng, just for testing values
type: list
ini:
- section: list_values
key: totallynotvalid
env:
- name: ANSIBLE_TYPES_TOTALLYNOTVALID
vars:
- name: ansible_types_totallynotvalid
str_mustunquote:
description: does nothihng, just for testing values
type: string
ini:
- section: string_values
key: str_mustunquote
env:
- name: ANSIBLE_TYPES_STR_MUSTUNQUOTE
vars:
- name: ansible_types_str_mustunquote
"""
EXAMPLES = """
- name: like some other plugins, this is mostly useless
debug: msg={{ q('types', [1,2,3])}}
"""
RETURN = """
_list:
description: basically the same as you fed in
type: list
elements: raw
"""
from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
self.set_options(var_options=variables, direct=kwargs)
return terms
| 2,543
|
Python
|
.py
| 79
| 21.481013
| 92
| 0.552792
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,458
|
inventory1.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/inventory/inventory1.py
|
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = r"""
---
module: module2
short_description: Hello test module
description: Hello test module.
options:
plugin:
required: true
description: name of the plugin (cache_host)
author:
- Ansible Core Team
"""
EXAMPLES = r"""
---
first_doc:
some_key:
---
second_doc:
some_key:
"""
RETURN = r"""
---
---
"""
from ansible.plugins.inventory import BaseInventoryPlugin
class InventoryModule(BaseInventoryPlugin):
NAME = 'inventory1'
| 665
|
Python
|
.py
| 30
| 18.666667
| 92
| 0.678457
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,459
|
module1.py
|
ansible_ansible/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/modules/module1.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = r"""
module: module1
short_description: Hello test module
description: Hello test module.
options: {}
author:
- Ansible Core Team
short_description: Duplicate short description
"""
EXAMPLES = r"""
- minimal:
"""
RETURN = r"""
invalid_yaml:
bad_indent:
usual_indent:
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec={},
)
module.exit_json()
if __name__ == "__main__":
main()
| 661
|
Python
|
.py
| 29
| 20.310345
| 92
| 0.702093
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,460
|
delegation_connection.py
|
ansible_ansible/test/integration/targets/connection_delegation/connection_plugins/delegation_connection.py
|
from __future__ import annotations
DOCUMENTATION = """
author: Ansible Core Team
connection: delegation_connection
short_description: Test connection for delegated host check
description:
- Some further description that you don't care about.
options:
remote_password:
description: The remote password
type: str
vars:
- name: ansible_password
# Tests that an aliased key gets the -k option which hardcodes the value to password
aliases:
- password
"""
from ansible.plugins.connection import ConnectionBase
class Connection(ConnectionBase):
transport = 'delegation_connection'
has_pipelining = True
def __init__(self, *args, **kwargs):
super(Connection, self).__init__(*args, **kwargs)
def _connect(self):
super(Connection, self)._connect()
def exec_command(self, cmd, in_data=None, sudoable=True):
super(Connection, self).exec_command(cmd, in_data, sudoable)
def put_file(self, in_path, out_path):
super(Connection, self).put_file(in_path, out_path)
def fetch_file(self, in_path, out_path):
super(Connection, self).fetch_file(in_path, out_path)
def close(self):
super(Connection, self).close()
| 1,214
|
Python
|
.py
| 33
| 32.121212
| 88
| 0.713675
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,461
|
delegation_action.py
|
ansible_ansible/test/integration/targets/connection_delegation/action_plugins/delegation_action.py
|
from __future__ import annotations
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
return {
'remote_password': self._connection.get_option('remote_password'),
}
| 268
|
Python
|
.py
| 7
| 32.142857
| 78
| 0.700389
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,462
|
faux-editor.py
|
ansible_ansible/test/integration/targets/ansible-vault/faux-editor.py
|
#!/usr/bin/env python
#
# 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/>.
#
# ansible-vault is a script that encrypts/decrypts YAML files. See
# https://docs.ansible.com/ansible/latest/user_guide/vault.html for more details.
from __future__ import annotations
import sys
import time
import os
def main(args):
path = os.path.abspath(args[1])
fo = open(path, 'r+')
content = fo.readlines()
content.append('faux editor added at %s\n' % time.time())
fo.seek(0)
fo.write(''.join(content))
fo.close()
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[:]))
| 1,175
|
Python
|
.py
| 32
| 34.25
| 81
| 0.732332
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,463
|
password-script.py
|
ansible_ansible/test/integration/targets/ansible-vault/password-script.py
|
#!/usr/bin/env python
#
# 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/>.
#
# ansible-vault is a script that encrypts/decrypts YAML files. See
# https://docs.ansible.com/ansible/latest/user_guide/vault.html for more details.
from __future__ import annotations
import sys
PASSWORD = 'test-vault-password'
def main(args):
print(PASSWORD)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[:]))
| 988
|
Python
|
.py
| 25
| 37.76
| 81
| 0.759414
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,464
|
test-vault-client.py
|
ansible_ansible/test/integration/targets/ansible-vault/test-vault-client.py
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import annotations
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
import argparse
import sys
# TODO: could read these from the files I suppose...
secrets = {'vault-password': 'test-vault-password',
'vault-password-wrong': 'hunter42',
'vault-password-ansible': 'ansible',
'password': 'password',
'vault-client-password-1': 'password-1',
'vault-client-password-2': 'password-2'}
def build_arg_parser():
parser = argparse.ArgumentParser(description='Get a vault password from user keyring')
parser.add_argument('--vault-id', action='store', default=None,
dest='vault_id',
help='name of the vault secret to get from keyring')
parser.add_argument('--username', action='store', default=None,
help='the username whose keyring is queried')
parser.add_argument('--set', action='store_true', default=False,
dest='set_password',
help='set the password instead of getting it')
return parser
def get_secret(keyname):
return secrets.get(keyname, None)
def main():
rc = 0
arg_parser = build_arg_parser()
args = arg_parser.parse_args()
# print('args: %s' % args)
keyname = args.vault_id or 'ansible'
if args.set_password:
print('--set is not supported yet')
sys.exit(1)
secret = get_secret(keyname)
if secret is None:
sys.stderr.write('test-vault-client could not find key for vault-id="%s"\n' % keyname)
# key not found rc=2
return 2
sys.stdout.write('%s\n' % secret)
return rc
if __name__ == '__main__':
sys.exit(main())
| 1,854
|
Python
|
.py
| 46
| 31.869565
| 94
| 0.600894
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,465
|
verify.py
|
ansible_ansible/test/integration/targets/packaging_cli-doc/verify.py
|
#!/usr/bin/env python
from __future__ import annotations
import os
import pathlib
import sys
exclude_programs = {
'ansible-test',
}
bin_dir = pathlib.Path(os.environ['JUNIT_OUTPUT_DIR']).parent.parent.parent / 'bin'
programs = set(program.name for program in bin_dir.iterdir() if program.name not in exclude_programs)
docs_dir = pathlib.Path(sys.argv[1])
docs = set(path.with_suffix('').name for path in docs_dir.iterdir())
print('\n'.join(sorted(docs)))
missing = programs - docs
extra = docs - programs
if missing or extra:
raise RuntimeError(f'{missing=} {extra=}')
| 583
|
Python
|
.py
| 17
| 32.470588
| 101
| 0.741071
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,466
|
test_connection_override.py
|
ansible_ansible/test/integration/targets/shell/connection_plugins/test_connection_override.py
|
# Copyright (c) 2019 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 = """
connection: test_connection_override
short_description: test connection plugin used in tests
description:
- This is a test connection plugin used for shell testing
author: ansible (@core)
version_added: historical
options:
"""
from ansible.plugins.connection import ConnectionBase
class Connection(ConnectionBase):
""" test connection """
transport = 'test_connection_override'
def __init__(self, *args, **kwargs):
self._shell_type = 'powershell' # Set a shell type that is not sh
super(Connection, self).__init__(*args, **kwargs)
def _connect(self):
pass
def exec_command(self, cmd, in_data=None, sudoable=True):
pass
def put_file(self, in_path, out_path):
pass
def fetch_file(self, in_path, out_path):
pass
def close(self):
pass
| 1,017
|
Python
|
.py
| 29
| 30.62069
| 92
| 0.702869
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,467
|
test_connection_default.py
|
ansible_ansible/test/integration/targets/shell/connection_plugins/test_connection_default.py
|
# Copyright (c) 2019 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 = """
connection: test_connection_default
short_description: test connection plugin used in tests
description:
- This is a test connection plugin used for shell testing
author: ansible (@core)
version_added: historical
options:
"""
from ansible.plugins.connection import ConnectionBase
class Connection(ConnectionBase):
""" test connection """
transport = 'test_connection_default'
def __init__(self, *args, **kwargs):
super(Connection, self).__init__(*args, **kwargs)
def _connect(self):
pass
def exec_command(self, cmd, in_data=None, sudoable=True):
pass
def put_file(self, in_path, out_path):
pass
def fetch_file(self, in_path, out_path):
pass
def close(self):
pass
| 940
|
Python
|
.py
| 28
| 29.285714
| 92
| 0.707778
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,468
|
test_shell.py
|
ansible_ansible/test/integration/targets/shell/action_plugins/test_shell.py
|
# This file is part of Ansible
# Copyright (c) 2019 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=None, task_vars=None):
result = super(ActionModule, self).run(tmp, task_vars)
del tmp # tmp no longer has any effect
result['shell'] = self._connection._shell.SHELL_FAMILY
return result
| 521
|
Python
|
.py
| 11
| 42.545455
| 92
| 0.724206
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,469
|
test_command.py
|
ansible_ansible/test/integration/targets/expect/files/test_command.py
|
from __future__ import annotations
import sys
try:
input_function = raw_input
except NameError:
input_function = input
prompts = sys.argv[1:] or ['foo']
# latin1 encoded bytes
# to ensure pexpect doesn't have any encoding errors
data = b'premi\xe8re is first\npremie?re is slightly different\n????????? is Cyrillic\n? am Deseret\n'
try:
sys.stdout.buffer.write(data)
except AttributeError:
sys.stdout.write(data)
print()
for prompt in prompts:
user_input = input_function(prompt)
print(user_input)
| 528
|
Python
|
.py
| 18
| 26.666667
| 102
| 0.744048
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,470
|
dummy.py
|
ansible_ansible/test/integration/targets/error_from_connection/connection_plugins/dummy.py
|
from __future__ import annotations
DOCUMENTATION = """
author:
- John Doe
connection: dummy
short_description: defective connection plugin
description:
- defective connection plugin
version_added: "2.0"
options: {}
"""
from ansible.errors import AnsibleError
from ansible.plugins.connection import ConnectionBase
class Connection(ConnectionBase):
transport = 'dummy'
has_pipelining = True
def __init__(self, play_context, new_stdin, *args, **kwargs):
super(Connection, self).__init__(play_context, new_stdin, *args, **kwargs)
raise AnsibleError('an error with {{ some Jinja }}')
def _connect(self):
pass
def exec_command(self, cmd, in_data=None, sudoable=True):
pass
def put_file(self, in_path, out_path):
pass
def fetch_file(self, in_path, out_path):
pass
def close(self):
pass
| 918
|
Python
|
.py
| 29
| 25.862069
| 82
| 0.664009
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,471
|
no_shebang.py
|
ansible_ansible/test/integration/targets/script/files/no_shebang.py
|
from __future__ import annotations
import sys
sys.stdout.write("Script with shebang omitted")
| 96
|
Python
|
.py
| 3
| 30.333333
| 47
| 0.813187
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,472
|
callback_host_count.py
|
ansible_ansible/test/integration/targets/strategy_host_pinned/callback_plugins/callback_host_count.py
|
# (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.callback import CallbackBase
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'stdout'
CALLBACK_NAME = 'callback_host_count'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._executing_hosts_counter = 0
def v2_playbook_on_task_start(self, task, is_conditional):
self._display.display(task.name or task.action)
if task.name == "start":
self._executing_hosts_counter += 1
# NOTE assumes 2 forks
num_forks = 2
if self._executing_hosts_counter > num_forks:
# Exception is caught and turned into just a warning in TQM,
# so raise BaseException to fail the test
# To prevent seeing false positives in case the exception handling
# in TQM is changed and BaseException is swallowed, print something
# and ensure the test fails in runme.sh in such a case.
self._display.display("host_pinned_test_failed")
raise BaseException(
"host_pinned test failed, number of hosts executing: "
f"{self._executing_hosts_counter}, expected: {num_forks}"
)
def v2_playbook_on_handler_task_start(self, task):
self._display.display(task.name or task.action)
def v2_runner_on_ok(self, result):
if result._task.name == "end":
self._executing_hosts_counter -= 1
| 1,623
|
Python
|
.py
| 33
| 40.242424
| 92
| 0.646835
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,473
|
my_module.py
|
ansible_ansible/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py
|
#!/usr/bin/python
from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ..module_utils.my_util2 import two
from ..module_utils import my_util3
def main():
module = AnsibleModule(
argument_spec=dict(),
supports_check_mode=True
)
result = dict(
two=two(),
three=my_util3.three(),
)
module.exit_json(**result)
if __name__ == '__main__':
main()
| 442
|
Python
|
.py
| 17
| 21.352941
| 52
| 0.653938
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,474
|
my_util2.py
|
ansible_ansible/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py
|
from __future__ import annotations
from .my_util1 import one
def two():
return one() * 2
| 96
|
Python
|
.py
| 4
| 21.25
| 34
| 0.707865
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,475
|
my_util3.py
|
ansible_ansible/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util3.py
|
from __future__ import annotations
from . import my_util2
def three():
return my_util2.two() + 1
| 104
|
Python
|
.py
| 4
| 23.25
| 34
| 0.71134
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,476
|
argspec.py
|
ansible_ansible/test/integration/targets/argspec/library/argspec.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
def main():
module = AnsibleModule(
{
'required': {
'required': True,
},
'required_one_of_one': {},
'required_one_of_two': {},
'required_by_one': {},
'required_by_two': {},
'required_by_three': {},
'state': {
'type': 'str',
'choices': ['absent', 'present'],
},
'default_value': {
'type': 'bool',
'default': True,
},
'path': {},
'content': {},
'mapping': {
'type': 'dict',
},
'required_one_of': {
'required_one_of': [['thing', 'other']],
'type': 'list',
'elements': 'dict',
'options': {
'thing': {},
'other': {'aliases': ['other_alias']},
},
},
'required_by': {
'required_by': {'thing': 'other'},
'type': 'list',
'elements': 'dict',
'options': {
'thing': {},
'other': {},
},
},
'required_together': {
'required_together': [['thing', 'other']],
'type': 'list',
'elements': 'dict',
'options': {
'thing': {},
'other': {},
'another': {},
},
},
'required_if': {
'required_if': (
('thing', 'foo', ('other',), True),
),
'type': 'list',
'elements': 'dict',
'options': {
'thing': {},
'other': {},
'another': {},
},
},
'json': {
'type': 'json',
},
'fail_on_missing_params': {
'type': 'list',
'default': [],
},
'needed_param': {},
'required_together_one': {},
'required_together_two': {},
'suboptions_list_no_elements': {
'type': 'list',
'options': {
'thing': {},
},
},
'choices_with_strings_like_bools': {
'type': 'str',
'choices': [
'on',
'off',
],
},
'choices': {
'type': 'str',
'choices': [
'foo',
'bar',
],
},
'list_choices': {
'type': 'list',
'choices': [
'foo',
'bar',
'baz',
],
},
'primary': {
'type': 'str',
'aliases': [
'alias',
],
},
'password': {
'type': 'str',
'no_log': True,
},
'not_a_password': {
'type': 'str',
'no_log': False,
},
'maybe_password': {
'type': 'str',
},
'int': {
'type': 'int',
},
'apply_defaults': {
'type': 'dict',
'apply_defaults': True,
'options': {
'foo': {
'type': 'str',
},
'bar': {
'type': 'str',
'default': 'baz',
'aliases': ['bar_alias1', 'bar_alias2'],
},
},
},
'deprecation_aliases': {
'type': 'str',
'aliases': [
'deprecation_aliases_version',
'deprecation_aliases_date',
],
'deprecated_aliases': [
{
'name': 'deprecation_aliases_version',
'version': '2.0.0',
'collection_name': 'foo.bar',
},
{
'name': 'deprecation_aliases_date',
'date': '2023-01-01',
'collection_name': 'foo.bar',
},
],
},
'deprecation_param_version': {
'type': 'str',
'removed_in_version': '2.0.0',
'removed_from_collection': 'foo.bar',
},
'deprecation_param_date': {
'type': 'str',
'removed_at_date': '2023-01-01',
'removed_from_collection': 'foo.bar',
},
'subdeprecation': {
'aliases': [
'subdeprecation_alias',
],
'type': 'dict',
'options': {
'deprecation_aliases': {
'type': 'str',
'aliases': [
'deprecation_aliases_version',
'deprecation_aliases_date',
],
'deprecated_aliases': [
{
'name': 'deprecation_aliases_version',
'version': '2.0.0',
'collection_name': 'foo.bar',
},
{
'name': 'deprecation_aliases_date',
'date': '2023-01-01',
'collection_name': 'foo.bar',
},
],
},
'deprecation_param_version': {
'type': 'str',
'removed_in_version': '2.0.0',
'removed_from_collection': 'foo.bar',
},
'deprecation_param_date': {
'type': 'str',
'removed_at_date': '2023-01-01',
'removed_from_collection': 'foo.bar',
},
},
},
'subdeprecation_list': {
'type': 'list',
'elements': 'dict',
'options': {
'deprecation_aliases': {
'type': 'str',
'aliases': [
'deprecation_aliases_version',
'deprecation_aliases_date',
],
'deprecated_aliases': [
{
'name': 'deprecation_aliases_version',
'version': '2.0.0',
'collection_name': 'foo.bar',
},
{
'name': 'deprecation_aliases_date',
'date': '2023-01-01',
'collection_name': 'foo.bar',
},
],
},
'deprecation_param_version': {
'type': 'str',
'removed_in_version': '2.0.0',
'removed_from_collection': 'foo.bar',
},
'deprecation_param_date': {
'type': 'str',
'removed_at_date': '2023-01-01',
'removed_from_collection': 'foo.bar',
},
},
}
},
required_if=(
('state', 'present', ('path', 'content'), True),
),
mutually_exclusive=(
('path', 'content', 'default_value',),
),
required_one_of=(
('required_one_of_one', 'required_one_of_two'),
),
required_by={
'required_by_one': ('required_by_two', 'required_by_three'),
},
required_together=(
('required_together_one', 'required_together_two'),
),
)
module.fail_on_missing_params(module.params['fail_on_missing_params'])
module.exit_json(**module.params)
if __name__ == '__main__':
main()
| 8,965
|
Python
|
.py
| 263
| 16.159696
| 92
| 0.309524
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,477
|
override_formerly_core_masked_filter.py
|
ansible_ansible/test/integration/targets/collections/filter_plugins/override_formerly_core_masked_filter.py
|
from __future__ import annotations
def override_formerly_core_masked_filter(*args, **kwargs):
return 'hello from overridden formerly_core_masked_filter'
class FilterModule(object):
def filters(self):
return {
'formerly_core_masked_filter': override_formerly_core_masked_filter
}
| 319
|
Python
|
.py
| 8
| 33.875
| 79
| 0.716612
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,478
|
v2_vars_plugin.py
|
ansible_ansible/test/integration/targets/collections/custom_vars_plugins/v2_vars_plugin.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: v2_vars_plugin
version_added: "2.10"
short_description: load host and group vars
description:
- Third party vars plugin to test loading host and group vars without enabling and with a plugin-specific stage option
options:
stage:
choices: ['all', 'inventory', 'task']
type: str
ini:
- key: stage
section: other_vars_plugin
env:
- name: ANSIBLE_VARS_PLUGIN_STAGE
"""
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
super(VarsModule, self).get_vars(loader, path, entities)
return {'collection': False, 'name': 'v2_vars_plugin', 'v2_vars_plugin': True}
| 1,550
|
Python
|
.py
| 39
| 35.641026
| 124
| 0.695219
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,479
|
v1_vars_plugin.py
|
ansible_ansible/test/integration/targets/collections/custom_vars_plugins/v1_vars_plugin.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: v1_vars_plugin
version_added: "2.10"
short_description: load host and group vars
description:
- Third-party vars plugin to test loading host and group vars without enabling and without a plugin-specific stage option
options:
"""
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
super(VarsModule, self).get_vars(loader, path, entities)
return {'collection': False, 'name': 'v1_vars_plugin', 'v1_vars_plugin': True}
| 1,344
|
Python
|
.py
| 31
| 40.709677
| 127
| 0.728593
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,480
|
display_resolved_action.py
|
ansible_ansible/test/integration/targets/collections/test_task_resolved_plugin/callback_plugins/display_resolved_action.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
DOCUMENTATION = """
name: display_resolved_action
type: aggregate
short_description: Displays the requested and resolved actions at the end of a playbook.
description:
- Displays the requested and resolved actions in the format "requested == resolved".
requirements:
- Enable in configuration.
"""
from ansible.plugins.callback import CallbackBase
class CallbackModule(CallbackBase):
CALLBACK_VERSION = 2.0
CALLBACK_TYPE = 'aggregate'
CALLBACK_NAME = 'display_resolved_action'
CALLBACK_NEEDS_ENABLED = True
def __init__(self, *args, **kwargs):
super(CallbackModule, self).__init__(*args, **kwargs)
self.requested_to_resolved = {}
def v2_playbook_on_task_start(self, task, is_conditional):
self.requested_to_resolved[task.action] = task.resolved_action
def v2_playbook_on_stats(self, stats):
for requested, resolved in self.requested_to_resolved.items():
self._display.display("%s == %s" % (requested, resolved), screen_only=True)
| 1,200
|
Python
|
.py
| 26
| 40.730769
| 92
| 0.708155
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,481
|
collection_action.py
|
ansible_ansible/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/action/collection_action.py
|
# 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):
TRANSFERS_FILES = False
_VALID_ARGS = frozenset()
def run(self, tmp=None, task_vars=None):
return {'changed': False}
| 348
|
Python
|
.py
| 8
| 39.375
| 92
| 0.734328
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,482
|
collection_module.py
|
ansible_ansible/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/modules/collection_module.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
---
module: collection_module
short_description: A module to test a task's resolved action name.
description: A module to test a task's resolved action name.
options: {}
author: Ansible Core Team
notes:
- Supports C(check_mode).
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(supports_check_mode=True, argument_spec={})
module.exit_json(changed=False)
if __name__ == '__main__':
main()
| 643
|
Python
|
.py
| 20
| 30.05
| 92
| 0.730081
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,483
|
legacy_module.py
|
ansible_ansible/test/integration/targets/collections/test_task_resolved_plugin/library/legacy_module.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import annotations
DOCUMENTATION = """
---
module: legacy_module
short_description: A module to test a task's resolved action name.
description: A module to test a task's resolved action name.
options: {}
author: Ansible Core Team
notes:
- Supports C(check_mode).
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(supports_check_mode=True, argument_spec={})
module.exit_json(changed=False)
if __name__ == '__main__':
main()
| 639
|
Python
|
.py
| 20
| 29.85
| 92
| 0.728314
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,484
|
legacy_action.py
|
ansible_ansible/test/integration/targets/collections/test_task_resolved_plugin/action_plugins/legacy_action.py
|
# 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):
TRANSFERS_FILES = False
_VALID_ARGS = frozenset()
def run(self, tmp=None, task_vars=None):
return {'changed': False}
| 348
|
Python
|
.py
| 8
| 39.375
| 92
| 0.734328
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,485
|
action1.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/action/action1.py
|
from __future__ import annotations
from ansible.plugins.action import ActionBase
class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=None):
""" handler for file transfer operations """
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars)
if result.get('skipped'):
return result
module_args = self._task.args.copy()
result.update(
self._execute_module(
module_name='me.mycoll2.module1',
module_args=module_args,
task_vars=task_vars,
)
)
return result
| 680
|
Python
|
.py
| 19
| 25.684211
| 62
| 0.587423
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,486
|
action1.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/modules/action1.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: action1
short_description: Action Test module
description:
- Action Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
| 388
|
Python
|
.py
| 18
| 17.611111
| 50
| 0.621918
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,487
|
module1.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/me/mycoll2/plugins/modules/module1.py
|
#!/usr/bin/python
from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
'supported_by': 'core'}
DOCUMENTATION = """
---
module: module1
short_description: module1 Test module
description:
- module1 Test module
author:
- Ansible Core Team
"""
EXAMPLES = """
"""
RETURN = """
"""
from ansible.module_utils.basic import AnsibleModule
def main():
module = AnsibleModule(
argument_spec=dict(
desc=dict(type='str'),
),
)
results = dict(msg="you just ran me.mycoll2.module1", desc=module.params.get('desc'))
module.exit_json(**results)
if __name__ == '__main__':
main()
| 731
|
Python
|
.py
| 29
| 20.448276
| 89
| 0.624093
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,488
|
statichost.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/inventory/statichost.py
|
# Copyright (c) 2018 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: statichost
short_description: Add a single host
description: Add a single host
extends_documentation_fragment:
- inventory_cache
options:
plugin:
description: plugin name (must be statichost)
required: true
hostname:
description: Toggle display of stderr even when script was successful
required: True
"""
from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable
class InventoryModule(BaseInventoryPlugin, Cacheable):
NAME = 'testns.content_adj.statichost'
def __init__(self):
super(InventoryModule, self).__init__()
self._hosts = set()
def verify_file(self, path):
""" Verify if file is usable by this plugin, base does minimal accessibility check """
if not path.endswith('.statichost.yml') and not path.endswith('.statichost.yaml'):
return False
return super(InventoryModule, self).verify_file(path)
def parse(self, inventory, loader, path, cache=None):
super(InventoryModule, self).parse(inventory, loader, path)
# Initialize and validate options
self._read_config_data(path)
# Exercise cache
cache_key = self.get_cache_key(path)
attempt_to_read_cache = self.get_option('cache') and cache
cache_needs_update = self.get_option('cache') and not cache
if attempt_to_read_cache:
try:
host_to_add = self._cache[cache_key]
except KeyError:
cache_needs_update = True
if not attempt_to_read_cache or cache_needs_update:
host_to_add = self.get_option('hostname')
# this is where the magic happens
self.inventory.add_host(host_to_add, 'all')
self._cache[cache_key] = host_to_add
# self.inventory.add_group()...
# self.inventory.add_child()...
# self.inventory.set_variable()..
| 2,122
|
Python
|
.py
| 49
| 35.306122
| 94
| 0.660019
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,489
|
custom_adj_vars.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/vars/custom_adj_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_adj_vars
version_added: "2.10"
short_description: load host and group vars
description: test loading host and group vars from a collection
options:
stage:
default: all
choices: ['all', 'inventory', 'task']
type: str
ini:
- key: stage
section: custom_adj_vars
env:
- name: ANSIBLE_VARS_PLUGIN_STAGE
"""
from ansible.plugins.vars import BaseVarsPlugin
class VarsModule(BaseVarsPlugin):
def get_vars(self, loader, path, entities, cache=True):
super(VarsModule, self).get_vars(loader, path, entities)
return {'collection': 'adjacent', 'adj_var': 'value'}
| 1,471
|
Python
|
.py
| 39
| 33.564103
| 70
| 0.688858
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,490
|
contentadjmodule.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/modules/contentadjmodule.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='content_adj')))
if __name__ == '__main__':
main()
| 185
|
Python
|
.py
| 7
| 23.571429
| 64
| 0.67052
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,491
|
foomodule.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/module_utils/sub1/foomodule.py
|
from __future__ import annotations
def importme():
return "hello from {0}".format(__name__)
| 98
|
Python
|
.py
| 3
| 29.666667
| 44
| 0.688172
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,492
|
custom_jsonfile.py
|
ansible_ansible/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/cache/custom_jsonfile.py
|
# (c) 2014, Brian Coca, Josh Drake, et al
# (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 = """
cache: jsonfile
short_description: JSON formatted files.
description:
- This cache uses JSON formatted, per host, files saved to the filesystem.
version_added: "1.9"
author: Ansible Core (@ansible-core)
options:
_uri:
required: True
description:
- Path in which the cache plugin will save the JSON files
env:
- name: ANSIBLE_CACHE_PLUGIN_CONNECTION
ini:
- key: fact_caching_connection
section: defaults
_prefix:
description: User defined prefix to use when creating the JSON files
env:
- name: ANSIBLE_CACHE_PLUGIN_PREFIX
ini:
- key: fact_caching_prefix
section: defaults
_timeout:
default: 86400
description: Expiration timeout for the cache plugin data
env:
- name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
ini:
- key: fact_caching_timeout
section: defaults
type: integer
"""
import codecs
import json
from ansible.parsing.ajson import AnsibleJSONEncoder, AnsibleJSONDecoder
from ansible.plugins.cache import BaseFileCacheModule
class CacheModule(BaseFileCacheModule):
"""
A caching module backed by json files.
"""
def _load(self, filepath):
# Valid JSON is always UTF-8 encoded.
with codecs.open(filepath, 'r', encoding='utf-8') as f:
return json.load(f, cls=AnsibleJSONDecoder)
def _dump(self, value, filepath):
with codecs.open(filepath, 'w', encoding='utf-8') as f:
f.write(json.dumps(value, cls=AnsibleJSONEncoder, sort_keys=True, indent=4))
| 1,883
|
Python
|
.py
| 53
| 28.339623
| 92
| 0.654775
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,493
|
maskedmodule.py
|
ansible_ansible/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/maskedmodule.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, failed=True, msg='this collection should be masked by testcoll in the user content root')))
if __name__ == '__main__':
main()
| 253
|
Python
|
.py
| 7
| 33.285714
| 132
| 0.709544
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,494
|
testmodule.py
|
ansible_ansible/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='sys')))
if __name__ == '__main__':
main()
| 177
|
Python
|
.py
| 7
| 22.428571
| 56
| 0.660606
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,495
|
systestmodule.py
|
ansible_ansible/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/coll_in_sys/plugins/modules/systestmodule.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='sys')))
if __name__ == '__main__':
main()
| 177
|
Python
|
.py
| 7
| 22.428571
| 56
| 0.660606
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,496
|
ping.py
|
ansible_ansible/test/integration/targets/collections/library/ping.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='legacy_library_dir')))
if __name__ == '__main__':
main()
| 192
|
Python
|
.py
| 7
| 24.571429
| 71
| 0.677778
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,497
|
ping.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/builtin/plugins/modules/ping.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='overridden ansible.builtin (should not be possible)')))
if __name__ == '__main__':
main()
| 225
|
Python
|
.py
| 7
| 29.285714
| 104
| 0.699531
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,498
|
bullmodule.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/bullcoll/plugins/modules/bullmodule.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='user_ansible_bullcoll')))
if __name__ == '__main__':
main()
| 195
|
Python
|
.py
| 7
| 25
| 74
| 0.68306
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|
13,499
|
embedded_module.py
|
ansible_ansible/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/playbooks/roles/non_coll_role/library/embedded_module.py
|
#!/usr/bin/python
from __future__ import annotations
import json
def main():
print(json.dumps(dict(changed=False, source='collection_embedded_non_collection_role')))
if __name__ == '__main__':
main()
| 213
|
Python
|
.py
| 7
| 27.571429
| 92
| 0.701493
|
ansible/ansible
| 62,258
| 23,791
| 861
|
GPL-3.0
|
9/5/2024, 5:11:58 PM (Europe/Amsterdam)
|