Merge pull request #5039 from bpennypacker/airbrake
airbrake: Made the reporting URL an optional parameter
This commit is contained in:
commit
e89dafc6c1
1 changed files with 11 additions and 3 deletions
|
@ -47,6 +47,11 @@ options:
|
||||||
description:
|
description:
|
||||||
- A hash, number, tag, or other identifier showing what revision was deployed
|
- A hash, number, tag, or other identifier showing what revision was deployed
|
||||||
required: false
|
required: false
|
||||||
|
url:
|
||||||
|
description:
|
||||||
|
- Optional URL to submit the notification to. Use to send notifications to Airbrake-compliant tools like Errbit.
|
||||||
|
required: false
|
||||||
|
default: https://airbrake.io/deploys
|
||||||
|
|
||||||
# informational: requirements for nodes
|
# informational: requirements for nodes
|
||||||
requirements: [ urllib, urllib2 ]
|
requirements: [ urllib, urllib2 ]
|
||||||
|
@ -89,6 +94,7 @@ def main():
|
||||||
user=dict(required=False),
|
user=dict(required=False),
|
||||||
repo=dict(required=False),
|
repo=dict(required=False),
|
||||||
revision=dict(required=False),
|
revision=dict(required=False),
|
||||||
|
url=dict(required=False, default='https://api.airbrake.io/deploys.txt')
|
||||||
),
|
),
|
||||||
supports_check_mode=True
|
supports_check_mode=True
|
||||||
)
|
)
|
||||||
|
@ -110,21 +116,23 @@ def main():
|
||||||
|
|
||||||
params["api_key"] = module.params["token"]
|
params["api_key"] = module.params["token"]
|
||||||
|
|
||||||
|
url = module.params.get('url')
|
||||||
|
|
||||||
# If we're in check mode, just exit pretending like we succeeded
|
# If we're in check mode, just exit pretending like we succeeded
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
|
|
||||||
# Send the data to airbrake
|
# Send the data to airbrake
|
||||||
try:
|
try:
|
||||||
req = urllib2.Request("https://airbrake.io/deploys", urllib.urlencode(params))
|
req = urllib2.Request(url, urllib.urlencode(params))
|
||||||
result=urllib2.urlopen(req)
|
result=urllib2.urlopen(req)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
module.fail_json(msg="unable to update airbrake: %s" % e)
|
module.fail_json(msg="unable to update airbrake via %s?%s : %s" % (url, urllib.urlencode(params), e))
|
||||||
else:
|
else:
|
||||||
if result.code == 200:
|
if result.code == 200:
|
||||||
module.exit_json(changed=True)
|
module.exit_json(changed=True)
|
||||||
else:
|
else:
|
||||||
module.fail_json(msg="HTTP result code: %d" % result.code)
|
module.fail_json(msg="HTTP result code: %d connecting to %s" % (result.code, url))
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
from ansible.module_utils.basic import *
|
from ansible.module_utils.basic import *
|
||||||
|
|
Loading…
Reference in a new issue