Debian Codegraph @

ansible_collections/community/crypto/tests/ee/roles/smoke/library/smoke_pyyaml.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright (c) 2022 Felix Fontein <[email protected]>
5 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
6 # SPDX-License-Identifier: GPL-3.0-or-later
7
8 from __future__ import absolute_import, division, print_function
9 __metaclass__ = type
10
11
12 DOCUMENTATION = r'''
13 ---
14 module: smoke_pyyaml
15 short_description: Check whether PyYAML is present
16 author:
17 - Felix Fontein (@felixfontein)
18 description:
19 - Check whether C(yaml) is present.
20 options: {}
21 '''
22
23 EXAMPLES = r''' # '''
24
25 RETURN = r''' # '''
26
27 import traceback
28
29 from ansible.module_utils.basic import AnsibleModule, missing_required_lib
30
31 try:
32 import yaml # noqa: F401, pylint: disable=unused-import
33 HAS_PYYAML = True
34 PYYAML_IMP_ERR = None
35 except ImportError as exc:
36 PYYAML_IMP_ERR = traceback.format_exc()
37 HAS_PYYAML = False
38
39
40 def main():
41 module = AnsibleModule(argument_spec=dict(), supports_check_mode=True)
42
43 if not HAS_PYYAML:
44 module.fail_json(msg=missing_required_lib('PyYAML'), exception=PYYAML_IMP_ERR)
45
46 module.exit_json(msg='Everything is ok')
47
48
49 if __name__ == '__main__': # pragma: no cover
50 main() # pragma: no cover