mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-13 08:05:19 +01:00
Compare commits
9 commits
d8393d0624
...
0de02365d8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0de02365d8 | ||
|
|
69c04cd5bd | ||
|
|
f7f346f823 | ||
|
|
76e3baa72d | ||
|
|
1ec0718e7b | ||
|
|
7e4d5dd7a9 | ||
|
|
e05b8507a4 | ||
|
|
4f0114eb57 | ||
|
|
6ab2053005 |
9 changed files with 67 additions and 5 deletions
3
changelogs/fragments/566_bump_version_161.yml
Normal file
3
changelogs/fragments/566_bump_version_161.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
trivial:
|
||||||
|
- Bump version to 1.6.1 for next release.
|
||||||
3
changelogs/fragments/567_remove_version_added.yml
Normal file
3
changelogs/fragments/567_remove_version_added.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
trivial:
|
||||||
|
- mount - remove wrong version_added section from ``opts_no_log``.
|
||||||
3
changelogs/fragments/568_update_authorized_key.yml
Normal file
3
changelogs/fragments/568_update_authorized_key.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- authorized_keys - allow using absolute path to a file as a SSH key(s) source (https://github.com/ansible-collections/ansible.posix/pull/568)
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
namespace: ansible
|
namespace: ansible
|
||||||
name: posix
|
name: posix
|
||||||
version: 1.6.0
|
version: 1.6.1
|
||||||
readme: README.md
|
readme: README.md
|
||||||
authors:
|
authors:
|
||||||
- Ansible (github.com/ansible)
|
- Ansible (github.com/ansible)
|
||||||
|
|
@ -10,6 +10,6 @@ license_file: COPYING
|
||||||
tags: [posix, networking, shell, unix]
|
tags: [posix, networking, shell, unix]
|
||||||
dependencies: {}
|
dependencies: {}
|
||||||
repository: https://github.com/ansible-collections/ansible.posix
|
repository: https://github.com/ansible-collections/ansible.posix
|
||||||
documentation: https://github.com/ansible-collections/ansible.posix/tree/main/docs
|
documentation: https://docs.ansible.com/ansible/latest/collections/ansible/posix/
|
||||||
homepage: https://github.com/ansible-collections/ansible.posix
|
homepage: https://github.com/ansible-collections/ansible.posix
|
||||||
issues: https://github.com/ansible-collections/ansible.posix
|
issues: https://github.com/ansible-collections/ansible.posix
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ options:
|
||||||
key:
|
key:
|
||||||
description:
|
description:
|
||||||
- The SSH public key(s), as a string or (since Ansible 1.9) url (https://github.com/username.keys).
|
- 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
|
type: str
|
||||||
required: true
|
required: true
|
||||||
path:
|
path:
|
||||||
|
|
@ -80,6 +81,13 @@ options:
|
||||||
- Follow path symlink instead of replacing it.
|
- Follow path symlink instead of replacing it.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
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
|
author: Ansible Core Team
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
@ -96,6 +104,13 @@ EXAMPLES = r'''
|
||||||
state: present
|
state: present
|
||||||
key: https://github.com/charlie.keys
|
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
|
- name: Set authorized keys taken from url using lookup
|
||||||
ansible.posix.authorized_key:
|
ansible.posix.authorized_key:
|
||||||
user: charlie
|
user: charlie
|
||||||
|
|
@ -554,10 +569,11 @@ def enforce_state(module, params):
|
||||||
exclusive = params.get("exclusive", False)
|
exclusive = params.get("exclusive", False)
|
||||||
comment = params.get("comment", None)
|
comment = params.get("comment", None)
|
||||||
follow = params.get('follow', False)
|
follow = params.get('follow', False)
|
||||||
|
remote_src = params.get('remote_src', False)
|
||||||
error_msg = "Error getting key from: %s"
|
error_msg = "Error getting key from: %s"
|
||||||
|
|
||||||
# if the key is a url, request it and use it as key source
|
# if the key is a url or file, request it and use it as key source
|
||||||
if key.startswith("http"):
|
if key.startswith("http") or (key.startswith("file") and remote_src):
|
||||||
try:
|
try:
|
||||||
resp, info = fetch_url(module, key)
|
resp, info = fetch_url(module, key)
|
||||||
if info['status'] != 200:
|
if info['status'] != 200:
|
||||||
|
|
@ -682,6 +698,7 @@ def main():
|
||||||
comment=dict(type='str'),
|
comment=dict(type='str'),
|
||||||
validate_certs=dict(type='bool', default=True),
|
validate_certs=dict(type='bool', default=True),
|
||||||
follow=dict(type='bool', default=False),
|
follow=dict(type='bool', default=False),
|
||||||
|
remote_src=dict(type='bool', default=False),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ options:
|
||||||
- Do not log opts.
|
- Do not log opts.
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
version_added: 1.6.0
|
|
||||||
dump:
|
dump:
|
||||||
description:
|
description:
|
||||||
- Dump (see fstab(5)).
|
- Dump (see fstab(5)).
|
||||||
|
|
|
||||||
|
|
@ -35,3 +35,5 @@ multiple_keys_comments: |
|
||||||
ssh-rsa DATA_BASIC 1@testing
|
ssh-rsa DATA_BASIC 1@testing
|
||||||
# I like adding comments yo-dude-this-is-not-a-key INVALID_DATA 2@testing
|
# I like adding comments yo-dude-this-is-not-a-key INVALID_DATA 2@testing
|
||||||
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
|
ecdsa-sha2-nistp521 ECDSA_DATA 4@testing
|
||||||
|
|
||||||
|
key_path: /tmp/id_rsa.pub
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
- name: Create key file for test
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "{{ key_path }}"
|
||||||
|
content: "{{ rsa_key_basic }}"
|
||||||
|
mode: "0600"
|
||||||
|
|
||||||
|
- name: Add key using path
|
||||||
|
ansible.posix.authorized_key:
|
||||||
|
user: root
|
||||||
|
key: "{{ key_path }}"
|
||||||
|
state: present
|
||||||
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert that the key was added
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- result.changed == true
|
||||||
|
|
||||||
|
- name: Add key using path again
|
||||||
|
ansible.posix.authorized_key:
|
||||||
|
user: root
|
||||||
|
key: "{{ key_path }}"
|
||||||
|
state: present
|
||||||
|
path: "{{ output_dir | expanduser }}/authorized_keys"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: Assert that no changes were applied
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- result.changed == false
|
||||||
|
|
@ -31,3 +31,6 @@
|
||||||
|
|
||||||
- name: Test for the management of comments with key
|
- name: Test for the management of comments with key
|
||||||
ansible.builtin.import_tasks: comments.yml
|
ansible.builtin.import_tasks: comments.yml
|
||||||
|
|
||||||
|
- name: Test for specifying key as a path
|
||||||
|
ansible.builtin.import_tasks: setup_steps.yml
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue