summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Gonzalez <likwid@gmail.com>2014-12-22 18:22:31 -0600
committerJeff Gonzalez <likwid@gmail.com>2014-12-22 18:22:31 -0600
commit54214f83b5da2920a05b65535116c01cab7cb617 (patch)
tree848835c6a517417f610bdbd6266b927883623b3d
parent8f6ae92cf88beda287c6c11d8b4127239c3168e0 (diff)
downloadansible-modules-core-54214f83b5da2920a05b65535116c01cab7cb617.tar.gz
Added ability to use url as key source
-rw-r--r--system/authorized_key.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/system/authorized_key.py b/system/authorized_key.py
index d5792200..898f74b5 100644
--- a/system/authorized_key.py
+++ b/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('#')]