Compare commits

..

9 commits

Author SHA1 Message Date
Александр Бакановский
0de02365d8
Add remote_src 2024-09-26 16:19:27 +03:00
Александр Бакановский
69c04cd5bd
Update integration tests 2024-09-17 17:56:04 +03:00
Александр Бакановский
f7f346f823
Update CHANGELOG 2024-09-17 17:41:20 +03:00
Александр Бакановский
76e3baa72d
Update integration tests 2024-09-17 17:26:35 +03:00
Александр Бакановский
1ec0718e7b
Allow path for authorized_key 2024-09-17 17:26:17 +03:00
softwarefactory-project-zuul[bot]
7e4d5dd7a9
Merge pull request #567 from saito-hideki/pr/remove_version_added
Remove wrong version_added section from mount module

SUMMARY
Remove the wrong version_added section from the mount module. It's not the collection version; it should be the ansible-core version.
ISSUE TYPE

Docs Pull Request

COMPONENT NAME
ansible.posix.mount
ADDITIONAL INFORMATION

None
2024-09-13 06:44:06 +00:00
Hideki Saito
e05b8507a4
Remove wrong version_added section from mount module
Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-13 15:15:04 +09:00
softwarefactory-project-zuul[bot]
4f0114eb57
Merge pull request #566 from saito-hideki/pr/bump_up_version_1.6.1
Bump version to 1.6.1 to prepare the next release

SUMMARY

Bump version to 1.6.1 to prepare the next release
Update document site link

ISSUE TYPE

Docs Pull Request

COMPONENT NAME
ansible.posix
ADDITIONAL INFORMATION
None
2024-09-12 02:13:53 +00:00
Hideki Saito
6ab2053005
Maintain galaxy.yml
* Bump version to 1.6.1 to prepare the next release
* Update document site link

Signed-off-by: Hideki Saito <saito@fgrep.org>
2024-09-12 10:41:07 +09:00
6 changed files with 22 additions and 21 deletions

View file

@ -0,0 +1,3 @@
---
trivial:
- Bump version to 1.6.1 for next release.

View file

@ -0,0 +1,3 @@
---
trivial:
- mount - remove wrong version_added section from ``opts_no_log``.

View file

@ -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

View file

@ -24,7 +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 remote for a file with SSH key(s). - 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:
@ -81,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
''' '''
@ -102,6 +109,7 @@ EXAMPLES = r'''
user: charlie user: charlie
state: present state: present
key: file:///home/charlie/.ssh/id_rsa.pub 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:
@ -561,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 or file, 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:
@ -577,20 +586,6 @@ def enforce_state(module, params):
# resp.read gives bytes on python3, convert to native string type # resp.read gives bytes on python3, convert to native string type
key = to_native(key, errors='surrogate_or_strict') key = to_native(key, errors='surrogate_or_strict')
file_prefix = "file://"
if key.startswith(file_prefix):
# if the key is an absolute path, check for existense and use it as a key source
key_path = key[len(file_prefix):]
if not os.path.exists(key_path):
module.fail_json(msg="Path to a key file not found: %s" % key_path)
if not os.path.isfile(key_path):
module.fail_json(msg="Path to a key is a directory and must be a file: %s" % key_path)
try:
with open(key_path, 'r') as source_fh:
key = source_fh.read()
except OSError as e:
module.fail_json(msg="Failed to read key file %s : %s" % (key_path, to_native(e)))
# extract individual keys into an array, skipping blank lines and comments # extract individual keys into an array, skipping blank lines and comments
new_keys = [s for s in key.splitlines() if s and not s.startswith('#')] new_keys = [s for s in key.splitlines() if s and not s.startswith('#')]
@ -703,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,
) )

View file

@ -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)).

View file

@ -8,7 +8,7 @@
- name: Add key using path - name: Add key using path
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: root user: root
key: file://{{ key_path }} key: "{{ key_path }}"
state: present state: present
path: "{{ output_dir | expanduser }}/authorized_keys" path: "{{ output_dir | expanduser }}/authorized_keys"
register: result register: result
@ -21,7 +21,7 @@
- name: Add key using path again - name: Add key using path again
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: root user: root
key: file://{{ key_path }} key: "{{ key_path }}"
state: present state: present
path: "{{ output_dir | expanduser }}/authorized_keys" path: "{{ output_dir | expanduser }}/authorized_keys"
register: result register: result