mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-07-26 17:34:45 +00:00
Merge 0de02365d8 into 5321a9ecb5
This commit is contained in:
@@ -24,6 +24,7 @@ options:
|
||||
key:
|
||||
description:
|
||||
- The SSH public key(s), as a string or (since Ansible 1.9) url (https://github.com/username.keys).
|
||||
- You can also use V(file://) prefix to search localy or remote for a file with SSH key(s) depending on O(remote_src) value.
|
||||
type: str
|
||||
required: true
|
||||
path:
|
||||
@@ -80,6 +81,13 @@ options:
|
||||
- Follow path symlink instead of replacing it.
|
||||
type: bool
|
||||
default: false
|
||||
remote_src:
|
||||
description:
|
||||
- Influence whether key needs to be transferred or already is present remotely.
|
||||
- If V(false), it will search for src on the controller node.
|
||||
- If V(true) it will search for src on the managed (remote) node.
|
||||
type: bool
|
||||
default: false
|
||||
author: Ansible Core Team
|
||||
'''
|
||||
|
||||
@@ -96,6 +104,13 @@ EXAMPLES = r'''
|
||||
state: present
|
||||
key: https://github.com/charlie.keys
|
||||
|
||||
- name: Set authorized keys taken from path on controller node
|
||||
ansible.posix.authorized_key:
|
||||
user: charlie
|
||||
state: present
|
||||
key: file:///home/charlie/.ssh/id_rsa.pub
|
||||
remote_src: true
|
||||
|
||||
- name: Set authorized keys taken from url using lookup
|
||||
ansible.posix.authorized_key:
|
||||
user: charlie
|
||||
@@ -554,10 +569,11 @@ def enforce_state(module, params):
|
||||
exclusive = params.get("exclusive", False)
|
||||
comment = params.get("comment", None)
|
||||
follow = params.get('follow', False)
|
||||
remote_src = params.get('remote_src', False)
|
||||
error_msg = "Error getting key from: %s"
|
||||
|
||||
# if the key is a url, request it and use it as key source
|
||||
if key.startswith("http"):
|
||||
# if the key is a url or file, request it and use it as key source
|
||||
if key.startswith("http") or (key.startswith("file") and remote_src):
|
||||
try:
|
||||
resp, info = fetch_url(module, key)
|
||||
if info['status'] != 200:
|
||||
@@ -682,6 +698,7 @@ def main():
|
||||
comment=dict(type='str'),
|
||||
validate_certs=dict(type='bool', default=True),
|
||||
follow=dict(type='bool', default=False),
|
||||
remote_src=dict(type='bool', default=False),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user