ansible.posix icon indicating copy to clipboard operation
ansible.posix copied to clipboard

synchronize not working with executable=/bin/bash

Open PhracturedBlue opened this issue 4 years ago • 11 comments

Migrated from: https://github.com/ansible/ansible/issues/71220

SUMMARY

In our environment, for most systems, /bin/sh is linked to /bin/bash, but on some hosts it is /bin/dash. We use 'set -eo pipefail' in our shell rules, so we need to always use /bin/bash. To simplify having to set this in every task, we set executable=/bin/bash in ansible.cfg Doing so causes an error using the synchronize module:

synchronize works fine without this setting. On the controller, /bin/sh is symlinked to /bin/dash On the inventory_host, /bin/sh is symlinked to /bin/bash /bin/bash is available on both hosts

ISSUE TYPE
  • Bug Report
COMPONENT NAME

synchronize

ANSIBLE VERSION

ansible 2.9.10 config file = /home/user/ansible/ansible.cfg configured module search path = [u'/home/user/ansible/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/share/ansible/local/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]

CONFIGURATION

ANSIBLE_PIPELINING(/home/user/ansible/ansible.cfg) = True ANSIBLE_SSH_ARGS(/home/user/ansible/ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=60s -o HostKeyAlgorithms=+ssh-dss DEFAULT_BECOME_METHOD(/home/user/ansible/ansible.cfg) = su DEFAULT_EXECUTABLE(/home/user/ansible/ansible.cfg) = /bin/bash DEFAULT_GATHER_TIMEOUT(/home/user/ansible/ansible.cfg) = 30 DEFAULT_REMOTE_PORT(/home/user/ansible/ansible.cfg) = 22222 DEFAULT_TIMEOUT(//hme/user/ansible/ansible.cfg) = 30 DEFAULT_VAULT_PASSWORD_FILE(/home/user/ansible/ansible.cfg) = /home/user/ansible/scripts/passwordgen.sh HOST_KEY_CHECKING(/home/user/ansible/ansible.cfg) = False INTERPRETER_PYTHON(/home/user/ansible/ansible.cfg) = /usr/local/bin/python3.6.3a

OS / ENVIRONMENT

Controller OS: Ubuntu 16.04 Iventory host OS: SLES11SP4

STEPS TO REPRODUCE

playbook:

- hosts:
    inventory_hostname
- tasks:
  - name: broken
     synchronize:
     src: localdir/
     dest: /remotedir/
     owner: no
     group: no
     perms: no
EXPECTED RESULTS

synchornize should succeed

ACTUAL RESULTS

Results:

TASK [broken] *******************************************************************************************************************************************************************
fatal: [hostname]: FAILED! => {"msg": "Could not find the shell plugin required (bash)."}

PhracturedBlue avatar Aug 12 '20 16:08 PhracturedBlue

What distro and release is the controller as well as the remote hosts in the inventory?

needs_info

maxamillion avatar Aug 13 '20 04:08 maxamillion

It is specified in the ticket. Controller: Ubuntu 16.04 Inventory host: SLES11SP4

PhracturedBlue avatar Aug 13 '20 11:08 PhracturedBlue

@PhracturedBlue sorry I missed that .... will take a look, thank you.

maxamillion avatar Aug 20 '20 17:08 maxamillion

Same issue Task

  - name: rsync
    synchronize:
      mode: pull
      src: /root/test
      dest: /root/test

Output

TASK [rsync] ************************************************************************************************************************************************************************************************
fatal: [host]: FAILED! => {"msg": "Could not find the shell plugin required (bash)."}

Ansible 2.9.10 Controller: Debian 9.12 Host: Debian 9.8

itdoginfo avatar Aug 28 '20 09:08 itdoginfo

I have the same issue. Ansible: 2.9.13 Controller: Fedora 31 Host: Ubuntu 20.04

Is there any news?

shipilovds avatar Oct 17 '20 11:10 shipilovds

I'm hitting this issue too, tested with ansible host being Ubuntu 20.04 and centos 7, with remote host being RHEL 7

Has there been any movement on this?

rbkaspr avatar Nov 02 '20 14:11 rbkaspr

same problem here ubuntu 20.04 and centos 8 remote: Python 3.6.8 local: Python 3.8.5, ansible 2.10.3 in ~/.ansible.cfg I have:

executable = /bin/bash

It only happens when try to sync controller to remote:

ansible.posix.synchronize:
        src: /tmp/test-src
        dest: /tmp/test-dest

between 2 remote dirs or 2 local dirs are fine:

ansible.posix.synchronize:
        src: /tmp/test-src
        dest: /tmp/test-dest
      delegate_to: "{{ inventory_hostname }}"

if remote the line in .ansible.cfg but use ansible_shell_executable: /bin/bash in playbook, it works again

vars:
    ansible_shell_executable: /bin/bash

braindevices avatar Nov 20 '20 20:11 braindevices

Same issue here:

ansible 2.9.21 Controler and hosts:
Description: Debian GNU/Linux 10 (buster) Codename: buster

synchronize: src: /mydir/ dest: /otherdir/ mode: pull delete: yes

FAILED! => {"msg": "Could not find the shell plugin required (bash)."}

pffont avatar May 21 '21 23:05 pffont

Same issue here:

Controller: Linux 5.14.5-arch1-1 GNU/Linux

ansible [core 2.11.5] config file = /home/nuc7ear/.ansible.cfg configured module search path = ['/home/nuc7ear/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.9/site-packages/ansible ansible collection location = /home/nuc7ear/.ansible/collections:/usr/share/ansible/collections executable location = /usr/bin/ansible python version = 3.9.7 (default, Aug 31 2021, 13:28:12) [GCC 11.1.0] jinja version = 3.0.1 libyaml = True

Remote: Python 2.7.5 Linux 3.10.0-1160.15.2.el7.x86_64 GNU/Linux

Nuc7ear avatar Sep 22 '21 17:09 Nuc7ear

Same issue, change the ansible.cfg executable = /bin/bash to executable = /bin/sh will work well.

workaround 1: I create PR https://github.com/mamh-mixed/ansible.posix/commit/429de5c0c6885110645262e4080dc611793730a8 try to solve this issue, and add vars ansible_shell_type: sh to yaml file

workaround 2: https://github.com/mamh-mixed/ansible.posix/commit/714e42bf30e43c88b3495917a4dec184149a209a remove all code that reassign the self._play_context.shell and self._play_context.executable

mamh2021 avatar Oct 13 '22 04:10 mamh2021

any updates?

erlangparasu avatar Apr 08 '24 04:04 erlangparasu