ansible.posix
ansible.posix copied to clipboard
synchronize error: "msg": "Failed to find required executable \"rsync\" in paths: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
SUMMARY
I am trying to run an rsync from db1 to backup1 of a directory. When I run the playbook containing this task, I get the error
"msg": "Failed to find required executable \"rsync\" in paths: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ISSUE TYPE
- Bug Report
COMPONENT NAME
ansible.posix.synchronize
ANSIBLE VERSION
% ansible-playbook --version
ansible-playbook [core 2.13.5]
config file = /home/ansible/ansible.cfg
configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.10/site-packages/ansible
ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible-playbook
python version = 3.10.7 (main, Sep 13 2022, 01:42:44) [GCC 10.2.1 20210110]
jinja version = 3.1.2
libyaml = True
I am running ansible-playbook out of an ansible container I built.
COLLECTION VERSION
% ansible-galaxy collection list ansible.posix
# /usr/local/lib/python3.10/site-packages/ansible_collections
Collection Version
------------- -------
ansible.posix 1.4.0
CONFIGURATION
% ansible-config dump --only-changed
DEFAULT_PRIVATE_KEY_FILE(/home/ansible/ansible.cfg) = /home/ansible/.ssh/id_rsa
DEFAULT_REMOTE_USER(/home/ansible/ansible.cfg) = ubuntu
HOST_KEY_CHECKING(/home/ansible/ansible.cfg) = False
Playbook:
% cat playbooks/database_backup/playbook.yml
---
- hosts: all
become: yes
tasks:
- name: manually backup postgres db dumps to backup server
ansible.posix.synchronize:
private_key: "/root/keys/fnetbackup/id_ssh_rsa"
src: "/var/lib/postgresql/dumps/"
dest: "rsync://backup1/backup/{{ ansible_host }}/postgres/"
OS / ENVIRONMENT
Ansible controller: pop_os 22.04 LTS Ansible hosts: Ubuntu 22.04.1 LTS
ansible container built from the following Dockerfile
% cat Dockerfile
FROM python:3-slim
RUN apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends openssh-client sshpass sudo \
&& pip install pip --upgrade \
&& pip install ansible \
&& useradd -g users -m ansible
USER ansible
RUN mkdir -p /home/ansible/.ssh \
&& echo "UserKnownHostsFile=/dev/null" > /home/ansible/.ssh/config \
&& echo "StrictHostKeyChecking=noknown_hosts" >> /home/ansible/.ssh/config
WORKDIR /home/ansible
STEPS TO REPRODUCE
% alias ansible-playbook
ansible-playbook='docker run --net=host --rm -it -e SSH_AUTH_SOCK=/ssh-agent -v /etc/resolv.conf:/etc/resolv.conf:ro -v ${SSH_AUTH_SOCK}:/ssh-agent -v $(pwd):/home/ansible -v ~/.ssh:/home/ansible/.ssh:ro jforman/ansible:latest ansible-playbook'
EXPECTED RESULTS
I expected the command to be run on db1, as root:
rsync -avz /var/lib/postgresql/dumps/ rsync://backup1/backup/db1/postgres/
ACTUAL RESULTS
The full traceback is:
File "/tmp/ansible_ansible.posix.synchronize_payload_59vnefw9/ansible_ansible.posix.synchronize_payload.zip/ansible/module_utils/basic.py", line 1435, in get_bin_path
bin_path = get_bin_path(arg=arg, opt_dirs=opt_dirs)
File "/tmp/ansible_ansible.posix.synchronize_payload_59vnefw9/ansible_ansible.posix.synchronize_payload.zip/ansible/module_utils/common/process.py", line 42, in get_bin_path
raise ValueError('Failed to find required executable "%s" in paths: %s' % (arg, os.pathsep.join(paths)))
fatal: [db1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"_local_rsync_password": null,
"_local_rsync_path": "rsync",
"_substitute_controller": false,
"archive": true,
"checksum": false,
"compress": true,
"copy_links": false,
"delay_updates": true,
"delete": false,
"dest": "rsync://backup1/backup/db1/postgres/",
"dest_port": null,
"dirs": false,
"existing_only": false,
"group": null,
"link_dest": null,
"links": null,
"mode": "push",
"owner": null,
"partial": false,
"perms": null,
"private_key": "/root/keys/fnetbackup/id_ssh_rsa",
"recursive": null,
"rsync_opts": [],
"rsync_path": "sudo -u root rsync",
"rsync_timeout": 0,
"set_remote_user": true,
"src": "/var/lib/postgresql/dumps/",
"ssh_args": null,
"ssh_connection_multiplexing": false,
"times": null,
"verify_host": false
}
},
"msg": "Failed to find required executable \"rsync\" in paths: /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
}
rsync is definitely installed:
ubuntu@db1:~$ which rsync
/usr/bin/rsync
Same here.
Tested with: rsync_path: "su -c rsync"
or rsync_path: "/usr/bin/rsync"
or without setting rsync_path
.
which -a rsync
/usr/bin/rsync
/bin/rsync
Ubuntu 22.04.4 LTS