From 30822706dda0238f03cd9fcb68c6ddbba055898e Mon Sep 17 00:00:00 2001 From: Jeff Gonzalez Date: Mon, 22 Dec 2014 18:22:31 -0600 Subject: [PATCH] Added ability to use url as key source --- lib/ansible/modules/system/authorized_key.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ansible/modules/system/authorized_key.py b/lib/ansible/modules/system/authorized_key.py index d5792200b8d..898f74b575b 100644 --- a/lib/ansible/modules/system/authorized_key.py +++ b/lib/ansible/modules/system/authorized_key.py @@ -118,6 +118,7 @@ import os.path import tempfile import re import shlex +import urllib2 class keydict(dict): @@ -333,6 +334,14 @@ def enforce_state(module, params): state = params.get("state", "present") key_options = params.get("key_options", None) + if key.startswith("http"): + try: + gh_key = urllib2.urlopen(key).read() + except urllib2.URLError, e: + module.fail_json(msg="no key found at: %s" % key) + + key = gh_key + # extract individual keys into an array, skipping blank lines and comments key = [s for s in key.splitlines() if s and not s.startswith('#')]