Created
June 19, 2014 01:16
-
-
Save mmurray/a4bc6e9a9364343e6c60 to your computer and use it in GitHub Desktop.
ansible_maxcdn_purge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import datetime | |
import json | |
import os | |
from maxcdn import MaxCDN | |
def main(): | |
module = AnsibleModule( | |
argument_spec = dict( | |
alias=dict(default=None), | |
secret_key=dict(default=None), | |
consumer_key=dict(default=None), | |
zone=dict(default=None), | |
file=dict(default=None), | |
), | |
) | |
params = module.params | |
alias = params['alias'] | |
secret_key = params['secret_key'] | |
consumer_key = params['consumer_key'] | |
zone = int(params['zone']) | |
file = params['file'] | |
api = MaxCDN(alias, consumer_key, secret_key) | |
api.purge(zone, file) | |
date = str(datetime.datetime.now()) | |
print json.dumps({ | |
"time" : date, | |
"purged" : file, | |
"zone": "/zones/pull.json/%s/cache" % zone | |
}) | |
# import module snippets | |
from ansible.module_utils.basic import * | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment