# Pipeline in command error

**URL:** <https://forum.ansible.com/t/pipeline-in-command-error/15663>\
**Category:** Ansible Project\
**Created:** [July 14, 2014, 2:05pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663 "2014-07-14T14:05:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paco\_p](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Paco\_p](https://forum.ansible.com/u/Paco_p)\
**Post date:** [July 14, 2014, 2:05pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/1 "2014-07-14T14:05:50Z")

</div>

Hello, I need interact with a script, so I have a script as(/tmp/a.sh):

`  
read var

if [[$var == “y”]];  
then  
exit 0;  
else  
exit 1;  
fi

`

And in my playbook

`

- name: execute script  
command: “yes | bash /tmp/a.sh”

`

And I am getting the following:

`  
failed: [192.168.1.104] =\> {“failed”: true, “item”: “”, “parsed”: false}  
invalid output was: SUDO-SUCCESS-pmmitceeyaxmudspoxnoywwlhxsrkopg  
Killed

`

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [July 14, 2014, 7:08pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/2 "2014-07-14T19:08:24Z")

</div>

You’ll need to use the “shell:” version of the module for the piping of commands:

- name: execute script  
shell: “yes | bash /tmp/a.sh”

---

<div class="post-metadata">

**Author:** ![Paco\_p](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Paco\_p](https://forum.ansible.com/u/Paco_p)\
**Post date:** [July 15, 2014, 2:06pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/3 "2014-07-15T14:06:58Z")

</div>

I continued following the same issue:

\<192.168.1.104\> ESTABLISH CONNECTION FOR USER: pi  
\<192.168.1.104\> REMOTE\_MODULE command yes | bundle exec rake gitlab:setup RAILS\_ENV=production chdir=/home/gitlab/hd/gitlab #USE\_SHELL  
\<192.168.1.104\> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=pi’, ‘-o’, ‘ConnectTimeout=10’, ‘192.168.1.104’, “/bin/sh -c ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1405431909.52-211323817066995 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1405431909.52-211323817066995 && echo $HOME/.ansible/tmp/ansible-tmp-1405431909.52-211323817066995’”]  
\<192.168.1.104\> PUT /tmp/tmpXQj46R TO /home/pi/.ansible/tmp/ansible-tmp-1405431909.52-211323817066995/command  
\<192.168.1.104\> EXEC [‘ssh’, ‘-C’, ‘-tt’, ‘-vvv’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘KbdInteractiveAuthentication=no’, ‘-o’, ‘PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey’, ‘-o’, ‘PasswordAuthentication=no’, ‘-o’, ‘User=pi’, ‘-o’, ‘ConnectTimeout=10’, ‘192.168.1.104’, u’/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=lvabfvouobbyzqqcpklpxtvljduerijf] password: " -u root /bin/sh -c '”'“'echo SUDO-SUCCESS-lvabfvouobbyzqqcpklpxtvljduerijf; LC\_CTYPE=C LANG=C /usr/bin/python /home/pi/.ansible/tmp/ansible-tmp-1405431909.52-211323817066995/command; rm -rf /home/pi/.ansible/tmp/ansible-tmp-1405431909.52-211323817066995/ \>/dev/null 2\>&1'”'"''']  
failed: [192.168.1.104] =\> {“failed”: true, “item”: “”, “parsed”: false}  
invalid output was: SUDO-SUCCESS-lvabfvouobbyzqqcpklpxtvljduerijf  
Killed  
OpenSSH\_6.6.1, OpenSSL 1.0.1f 6 Jan 2014  
debug1: Reading configuration data /home/user/.ssh/config  
debug1: /home/user/.ssh/config line 19: Applying options for 192.168.1.104  
debug1: Reading configuration data /etc/ssh/ssh\_config  
debug1: /etc/ssh/ssh\_config line 19: Applying options for \*  
debug1: auto-mux: Trying existing master  
debug2: fd 3 setting O\_NONBLOCK  
debug2: mux\_client\_hello\_exchange: master version 4  
debug3: mux\_client\_forwards: request forwardings: 0 local, 0 remote  
debug3: mux\_client\_request\_session: entering  
debug3: mux\_client\_request\_alive: entering  
debug3: mux\_client\_request\_alive: done pid = 4217  
debug3: mux\_client\_request\_session: session request sent  
debug1: mux\_client\_request\_session: master session id: 2  
debug3: mux\_client\_read\_packet: read header failed: Broken pipe  
debug2: Received exit status from master 0  
Shared connection to 192.168.1.104 closed.

FATAL: all hosts have already failed – aborting

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 15, 2014, 3:38pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/4 "2014-07-15T15:38:38Z")

</div>

Right, you’re not going to get that particular error because of shell vs command. Though you should use shell for the shell operations.

What versions of Ansible are you running, what OSes are you connecting from and to?

Anything particularly interesting about the sudoers configuration?

---

<div class="post-metadata">

**Author:** ![Paco\_p](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Paco\_p](https://forum.ansible.com/u/Paco_p)\
**Post date:** [July 15, 2014, 4:44pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/5 "2014-07-15T16:44:08Z")

</div>

Ansible 1.6

Host machine: Ubuntu 14.04 LTS, kernel: 3.13.0-24-generic.

`  
paco@paco-K53SD:~$ lsb\_release -a  
No LSB modules are available.  
Distributor ID: Ubuntu  
Description: Ubuntu 14.04 LTS  
Release: 14.04  
Codename: trusty

`

Server machine: Raspbian

`  
pi@raspberrypi /etc/owncloud $ lsb\_release -a  
No LSB modules are available.  
Distributor ID: Debian  
Description: Debian GNU/Linux 7.5 (wheezy)  
Release: 7.5  
Codename: wheezy

`

I have no special settings in sudo:

`  
sudo cat /etc/sudoers  
Defaults env\_reset  
Defaults mail\_badpass  
Defaults secure\_path=“/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”

# User privilege specification

root ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command

%sudo ALL=(ALL:ALL) ALL

#includedir /etc/sudoers.d  
pi ALL=(ALL) NOPASSWD: ALL

`

site.yml:

`  
user: pi  
sudo: true  
roles:

- gitlab

`

roles/gitlab/tasks/main.yml

`

- name: initialize db  
shell: yes | bundle exec rake gitlab:setup RAILS\_ENV=production chdir=/home/gitlab/hd/gitlab  
`

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 15, 2014, 5:38pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/6 "2014-07-15T17:38:35Z")

</div>

While it may not be a factor, the latest version of Ansible is 1.6.6 - please check with the latest if you don’t mind, but I suspect it’s the sudoers response from Raspbian (or the SSH prompts) that is the problem, given it’s a bit non-standish.

Previously we did some work to deal with dropbear, for instance, and the MOTD gets sent every single time. (Though that’s dealt with)

If you’re so inclined, some debugging could be interesting.

---

<div class="post-metadata">

**Author:** ![Paco\_p](https://avatars.discourse-cdn.com/v4/letter/p/ac91a4/32.png) [@Paco\_p](https://forum.ansible.com/u/Paco_p)\
**Post date:** [July 16, 2014, 12:32pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/7 "2014-07-16T12:32:45Z")

</div>

I have tried with  
sudo: no

And the output is:

`  
failed: [192.168.1.104] =\> {“failed”: true, “parsed”: false}  
invalid output was: Kille

`

I am checking output with -v, -vvv, -vvvv but anything show enough information, any recommended flag?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 16, 2014, 11:49pm UTC](https://forum.ansible.com/t/pipeline-in-command-error/15663/8 "2014-07-16T23:49:30Z")

</div>

Unclear. I don’t have one of these systems around to debug with.

Possibly play around with connection\_plugins/ssh.py and you may be able to learn a bit more.

Sorry for deferring this, but Raspberry Pis – despite being amazingly awesome - really aren’t in our test matrix 🙂

I would like to see this work though, as I do know people using them with Ansible (without problem) on various projects.

Unclear about Raspbian.
