mirror of
https://github.com/Infisical/ansible-collection.git
synced 2025-07-29 08:01:27 -07:00
push init collection setup
This commit is contained in:
parent
a7bc303927
commit
8779acc489
2 changed files with 30 additions and 0 deletions
17
plugins/lookup/fetch_data.py
Normal file
17
plugins/lookup/fetch_data.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
import requests
|
||||
|
||||
class LookupModule(LookupBase):
|
||||
|
||||
def run(self, terms, variables=None, **kwargs):
|
||||
# URL from the terms or you can define it within the plugin
|
||||
url = terms[0]
|
||||
|
||||
try:
|
||||
response = requests.get(url)
|
||||
response.raise_for_status() # Raise HTTPError for bad responses (4xx and 5xx)
|
||||
return [response.json()]
|
||||
except requests.RequestException as e:
|
||||
raise AnsibleError("Error fetching data from {}: {}".format(url, e))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue