blob: c8d950802060bcfabf9929483b029483e8a82647 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#!/bin/python
from __future__ import (absolute_import, division, print_function)
import requests
__metaclass__ = type
from ansible.module_utils.basic import AnsibleModule
API_ENDPOINT="https://repology.org/api/v1/project/"
def main():
# Available arguments
module_args = dict(
package=dict(type="str", required=True),
repository=dict(type="str", required=False)
)
# Result to return
result = dict(
changed=False,
message=""
)
# Object for manipulating argument
module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=True
)
print("aa")
if module.check_mode:
module.exit_json(**result)
response = requests.get(f"{API_ENDPOINT}/{module.params['package']}")
print(response)
for res in response.json():
try:
#print(res["name"])
result.message = (res["name"])
except Exception:
pass
module.exit_json(**result)
if __name__ == "__main__":
main()
|