mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Added ability to use url as key source
This commit is contained in:
@@ -118,6 +118,7 @@ import os.path
|
|||||||
import tempfile
|
import tempfile
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
import urllib2
|
||||||
|
|
||||||
class keydict(dict):
|
class keydict(dict):
|
||||||
|
|
||||||
@@ -333,6 +334,14 @@ def enforce_state(module, params):
|
|||||||
state = params.get("state", "present")
|
state = params.get("state", "present")
|
||||||
key_options = params.get("key_options", None)
|
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
|
# extract individual keys into an array, skipping blank lines and comments
|
||||||
key = [s for s in key.splitlines() if s and not s.startswith('#')]
|
key = [s for s in key.splitlines() if s and not s.startswith('#')]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user