Skip to content

Instantly share code, notes, and snippets.

@mmurray
Created June 19, 2014 01:16
Show Gist options
  • Save mmurray/a4bc6e9a9364343e6c60 to your computer and use it in GitHub Desktop.
Save mmurray/a4bc6e9a9364343e6c60 to your computer and use it in GitHub Desktop.
ansible_maxcdn_purge
#!/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