Pipeline in command error

620 views
Skip to first unread message

Paco p

unread,
Jul 14, 2014, 10:05:50 AM7/14/14
to ansible...@googlegroups.com
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



James Cammarata

unread,
Jul 14, 2014, 3:08:28 PM7/14/14
to ansible...@googlegroups.com
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"



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/1da79ca0-c2f6-4359-b657-49757189e76c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paco p

unread,
Jul 15, 2014, 10:06:59 AM7/15/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Jul 15, 2014, 11:38:41 AM7/15/14
to ansible...@googlegroups.com
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?


Paco p

unread,
Jul 15, 2014, 12:44:08 PM7/15/14
to ansible...@googlegroups.com
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

Michael DeHaan

unread,
Jul 15, 2014, 1:38:40 PM7/15/14
to ansible...@googlegroups.com
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.




Paco p

unread,
Jul 16, 2014, 8:32:45 AM7/16/14
to ansible...@googlegroups.com
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?

Michael DeHaan

unread,
Jul 16, 2014, 7:49:33 PM7/16/14
to ansible...@googlegroups.com
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.




Reply all
Reply to author
Forward
0 new messages