mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-14 07:55:05 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -121,29 +121,62 @@ from ansible.module_utils.urls import fetch_url
|
|||
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
subscription=dict(required=True),
|
||||
token=dict(required=True, no_log=True),
|
||||
room=dict(required=True),
|
||||
msg=dict(required=True),
|
||||
notify=dict(choices=["56k", "bell", "bezos", "bueller",
|
||||
"clowntown", "cottoneyejoe",
|
||||
"crickets", "dadgummit", "dangerzone",
|
||||
"danielsan", "deeper", "drama",
|
||||
"greatjob", "greyjoy", "guarantee",
|
||||
"heygirl", "horn", "horror",
|
||||
"inconceivable", "live", "loggins",
|
||||
"makeitso", "noooo", "nyan", "ohmy",
|
||||
"ohyeah", "pushit", "rimshot",
|
||||
"rollout", "rumble", "sax", "secret",
|
||||
"sexyback", "story", "tada", "tmyk",
|
||||
"trololo", "trombone", "unix",
|
||||
"vuvuzela", "what", "whoomp", "yeah",
|
||||
"yodel"]),
|
||||
notify=dict(
|
||||
choices=[
|
||||
"56k",
|
||||
"bell",
|
||||
"bezos",
|
||||
"bueller",
|
||||
"clowntown",
|
||||
"cottoneyejoe",
|
||||
"crickets",
|
||||
"dadgummit",
|
||||
"dangerzone",
|
||||
"danielsan",
|
||||
"deeper",
|
||||
"drama",
|
||||
"greatjob",
|
||||
"greyjoy",
|
||||
"guarantee",
|
||||
"heygirl",
|
||||
"horn",
|
||||
"horror",
|
||||
"inconceivable",
|
||||
"live",
|
||||
"loggins",
|
||||
"makeitso",
|
||||
"noooo",
|
||||
"nyan",
|
||||
"ohmy",
|
||||
"ohyeah",
|
||||
"pushit",
|
||||
"rimshot",
|
||||
"rollout",
|
||||
"rumble",
|
||||
"sax",
|
||||
"secret",
|
||||
"sexyback",
|
||||
"story",
|
||||
"tada",
|
||||
"tmyk",
|
||||
"trololo",
|
||||
"trombone",
|
||||
"unix",
|
||||
"vuvuzela",
|
||||
"what",
|
||||
"whoomp",
|
||||
"yeah",
|
||||
"yodel",
|
||||
]
|
||||
),
|
||||
),
|
||||
supports_check_mode=False
|
||||
supports_check_mode=False,
|
||||
)
|
||||
|
||||
subscription = module.params["subscription"]
|
||||
|
|
@ -158,26 +191,27 @@ def main():
|
|||
AGENT = "Ansible/1.2"
|
||||
|
||||
# Hack to add basic auth username and password the way fetch_url expects
|
||||
module.params['url_username'] = token
|
||||
module.params['url_password'] = 'X'
|
||||
module.params["url_username"] = token
|
||||
module.params["url_password"] = "X"
|
||||
|
||||
target_url = f'{URI}/room/{room}/speak.xml'
|
||||
headers = {'Content-Type': 'application/xml',
|
||||
'User-agent': AGENT}
|
||||
target_url = f"{URI}/room/{room}/speak.xml"
|
||||
headers = {"Content-Type": "application/xml", "User-agent": AGENT}
|
||||
|
||||
# Send some audible notification if requested
|
||||
if notify:
|
||||
response, info = fetch_url(module, target_url, data=NSTR % html_escape(notify), headers=headers)
|
||||
if info['status'] not in [200, 201]:
|
||||
module.fail_json(msg=f"unable to send msg: '{notify}', campfire api returned error code: '{info['status']}'")
|
||||
if info["status"] not in [200, 201]:
|
||||
module.fail_json(
|
||||
msg=f"unable to send msg: '{notify}', campfire api returned error code: '{info['status']}'"
|
||||
)
|
||||
|
||||
# Send the message
|
||||
response, info = fetch_url(module, target_url, data=MSTR % html_escape(msg), headers=headers)
|
||||
if info['status'] not in [200, 201]:
|
||||
if info["status"] not in [200, 201]:
|
||||
module.fail_json(msg=f"unable to send msg: '{msg}', campfire api returned error code: '{info['status']}'")
|
||||
|
||||
module.exit_json(changed=True, room=room, msg=msg, notify=notify)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue