Compare commits

...

7 commits

Author SHA1 Message Date
Mark Asbach
f49e1113ad
Merge 230e5f2a98 into 12a1c25f5e 2023-07-07 23:19:45 +01:00
softwarefactory-project-zuul[bot]
12a1c25f5e
Merge pull request #478 from maxamillion/test/rhel_updates
Update azure-pipelines for new RHEL versions

SUMMARY

Change to the CI system annnounced in the following required this change:
ansible-collections/news-for-maintainers#47
2023-07-06 22:34:53 +00:00
Adam Miller
7062be892e only for devel
Signed-off-by: Adam Miller <admiller@redhat.com>
2023-07-06 10:19:58 -05:00
softwarefactory-project-zuul[bot]
20c2c30d23
Merge pull request #477 from saito-hideki/issue/476/1
Update CI tests to address changes on ansible-core

SUMMARY
Replace Python3.9 with 3.12 for ansible-test

Addresses issue #476

ISSUE TYPE

CI Test Pull Request

COMPONENT NAME

ansible.posix

ADDITIONAL INFORMATION
None
2023-07-04 01:39:12 +00:00
Hideki Saito
4f1e6b4a6d Drop Python3.9 and update versions of RHEL,Fedora and FreeBSD for ansible-core:devel
* Addresses issue #476
* Drop Python3.9
* Replace Fedora 37 with 38
* Replace FreeBSD13.1 with 13.2
* Replace RHEL 8.7 with 8.8
* Replace RHEL 9.1 with 9.2

Signed-off-by: Hideki Saito <saito@fgrep.org>
2023-07-04 09:15:24 +09:00
Adam Miller
806ab9ef9d Update azure-pipelines for new RHEL versions
Change to the CI system annnounced in the following required this
change:

  https://github.com/ansible-collections/news-for-maintainers/issues/47

Signed-off-by: Adam Miller <admiller@redhat.com>
2023-06-29 10:57:49 -05:00
Mark Asbach
230e5f2a98 allowing synchronize to elevate permissions when sudo requires password entry - implements #334 2022-03-13 00:29:22 +01:00
7 changed files with 43 additions and 16 deletions

View file

@ -53,8 +53,8 @@ stages:
targets:
- name: CentOS 7
test: centos7
- name: Fedora 37
test: fedora37
- name: Fedora 38
test: fedora38
- name: openSUSE 15 py3
test: opensuse15
- name: Ubuntu 20.04
@ -213,14 +213,14 @@ stages:
test: macos/13.2
- name: RHEL 7.9
test: rhel/7.9
- name: RHEL 8.7
test: rhel/8.7
- name: RHEL 9.1
test: rhel/9.1
- name: RHEL 8.8
test: rhel/8.8
- name: RHEL 9.2
test: rhel/9.2
- name: FreeBSD 12.4
test: freebsd/12.4
- name: FreeBSD 13.1
test: freebsd/13.1
- name: FreeBSD 13.2
test: freebsd/13.2
- stage: Remote_2_15
displayName: Remote 2.15
dependsOn: []

View file

@ -0,0 +1,3 @@
---
minor_changes:
- synchronize - elevating privileges now works even when `sudo` requires entering the `become_pass`

View file

@ -0,0 +1,3 @@
---
trivial:
- "Drop Python3.9 and update versions of RHEL,Fedora and FreeBSD for ansible-core:devel test(https://github.com/ansible-collections/ansible.posix/issues/476)."

View file

@ -580,7 +580,7 @@ Notes
- The user and permissions for the synchronize `dest` are those of the `remote_user` on the destination host or the `become_user` if `become=yes` is active.
- In Ansible 2.0 a bug in the synchronize module made become occur on the "local host". This was fixed in Ansible 2.0.1.
- Currently, synchronize is limited to elevating permissions via passwordless sudo. This is because rsync itself is connecting to the remote machine and rsync doesn't give us a way to pass sudo credentials in.
- Currently, synchronize is limited to elevating permissions via sudo. This now even works when password entry is required.
- Currently there are only a few connection types which support synchronize (ssh, paramiko, local, and docker) because a sync strategy has been determined for those connection types. Note that the connection for these must not need a password as rsync itself is making the connection and rsync does not provide us a way to pass a password to the connection.
- Expect that dest=~/x will be ~<remote_user>/x even if using sudo.
- Inspect the verbose output to validate the destination user/host/path are what was expected.

View file

@ -390,10 +390,24 @@ class ActionModule(ActionBase):
# If no rsync_path is set, become was originally set, and dest is
# remote then add privilege escalation here.
if self._play_context.become_method == 'sudo':
if self._play_context.become_user:
rsync_path = 'sudo -u %s rsync' % self._play_context.become_user
# if become is set, we can either rely on passwordless sudo or pass the password
if self._play_context.become_pass is None:
rsync_path = 'sudo '
else:
rsync_path = 'sudo rsync'
# pass the become password using the environment so that the synchronize module
# can wrap ssh on the host with a shell script that injects the password into
# stdin, allowing for `sudo -S` on the target machine to retrieve the password
if hasattr(self._task, 'environment'):
self._task.environment = []
self._task.environment.append({'BECOME_PASS': self._play_context.become_pass})
_tmp_args['_ssh_wrapper'] = True
rsync_path = 'sudo -S '
if self._play_context.become_user:
rsync_path += '-u %s rsync' % self._play_context.become_user
else:
rsync_path += 'rsync'
# TODO: have to add in the rest of the become methods here
# We cannot use privilege escalation on the machine running the

View file

@ -198,7 +198,7 @@ notes:
delegate_to host when delegate_to is used).
- The user and permissions for the synchronize `dest` are those of the `remote_user` on the destination host or the `become_user` if `become=yes` is active.
- In Ansible 2.0 a bug in the synchronize module made become occur on the "local host". This was fixed in Ansible 2.0.1.
- Currently, synchronize is limited to elevating permissions via passwordless sudo. This is because rsync itself is connecting to the remote machine
- Currently, synchronize is limited to elevating permissions via sudo. This now even works when password entry is required.
and rsync doesn't give us a way to pass sudo credentials in.
- Currently there are only a few connection types which support synchronize (ssh, paramiko, local, and docker) because a sync strategy has been
determined for those connection types. Note that the connection for these must not need a password as rsync itself is making the connection and
@ -414,6 +414,7 @@ def main():
rsync_opts=dict(type='list', default=[], elements='str'),
ssh_args=dict(type='str'),
ssh_connection_multiplexing=dict(type='bool', default=False),
_ssh_wrapper=dict(type='bool', default=False),
partial=dict(type='bool', default=False),
verify_host=dict(type='bool', default=False),
delay_updates=dict(type='bool', default=True),
@ -456,6 +457,7 @@ def main():
rsync_opts = module.params['rsync_opts']
ssh_args = module.params['ssh_args']
ssh_connection_multiplexing = module.params['ssh_connection_multiplexing']
ssh_wrapper = module.params['_ssh_wrapper']
verify_host = module.params['verify_host']
link_dest = module.params['link_dest']
delay_updates = module.params['delay_updates']
@ -550,6 +552,13 @@ def main():
ssh_cmd_str = ' '.join(shlex_quote(arg) for arg in ssh_cmd)
if ssh_args:
ssh_cmd_str += ' %s' % ssh_args
# When `become: yes` is set but the account on the target requires a password for sudo, we have to supply
# it from the host side by wrapping the remote shell and inserting the password into stdin.
# In the ActionPlugin, the password is assigned to the BECOME_PASS environment variable, so we will not have
# to make it visible if anyone logs the command issued by ansible.
# Adapted from https://askubuntu.com/a/1263657
if ssh_wrapper:
ssh_cmd_str = '/bin/sh -c "{ echo $BECOME_PASS; cat - ; } | ' + ssh_cmd_str + ' $0 $* &"'
cmd.append('--rsh=%s' % shlex_quote(ssh_cmd_str))
if rsync_path:

View file

@ -145,9 +145,7 @@ function cleanup
fi
if [ "${process_coverage}" ]; then
# use python 3.9 for coverage to avoid running out of memory during coverage xml processing
# only use it for coverage to avoid the additional overhead of setting up a virtual environment for a potential no-op job
virtualenv --python /usr/bin/python3.9 ~/ansible-venv
python3 -m venv ~/ansible-venv
set +ux
. ~/ansible-venv/bin/activate
set -ux