Salt states fail with error 'Failed to return clean data' when using salt-ssh in Amazon EC2
Salt states fail with error 'Failed to return clean data' when using salt-ssh in Amazon EC2 when applying a state as non-root user
Expected Behavior
States should successfully apply over Salt SSH if sudo: True is set when the SSH connection is from a non-root user that is in the sodoers.
- WORKING command
salt-ssh test-minion status.uptime - EXPECTED WORKING command
salt-ssh test-minion state.sls setup.test
Actual Behavior
- EXPECTED WORKING command
salt-ssh test-minion state.sls setup.test
# key fragments from large output
...
_error:
Failed to return clean data
...
retcode:
0
stderr:
Connection to 172.31.5.246 closed.
...
Steps to Reproduce Issue
Create 2 CentOS 6.5 or CentOS 7.x image VMS in AWS. Install Salt master and Salt-ssh on one VM Setup roster in the following format:
# file: /etc/salt/roster (fragment)
test-minion:
host : <your-IP>
priv: /etc/salt/your_key.pem
user: <your-non-root-user>
sudo: True
tty: True
Create a simple state:
# test state
push_text:
file.managed:
- name: /etc/foobar.txt
- contents:
- 'version: 2.0'
- 'Test'
Run the following command to see the error:
salt-ssh test-minion state.sls setup.test
or
salt-ssh test-minion state.sls setup.test |less
NOTE: Re-created in VirtualBox on local workstation, but does not exhibit any errors.
If I use a new CentOS 7.0 AWS image that uses a non-root 'ec2-user' account then it appears that I make an salt-ssh connection, but it disconnects immediately and does not apply the state.
I first tried running the master in a virtualbox on my workstation and then salt-ssh to minions in AWS. This has worked for months if the image allows for root ssh. However, thinking that there might be a network issue between my workstation and AWS, I created a VM in AWS in the same VPC and then tried the salt-ssh again with the same error. The ec2-user is in the sudo's file so system permissions seem to be set correctly.
I did run into bug https://github.com/saltstack/salt/issues/18425 , but manually applied the fix and got past that.
Versions Report
* Provided by running salt --versions-report*
# salt-ssh --versions-report
Salt Version:
Salt: 2015.8.7
Dependency Versions:
Jinja2: 2.2.1
M2Crypto: 0.20.2
Mako: Not Installed
PyYAML: 3.11
PyZMQ: 14.5.0
Python: 2.6.6 (r266:84292, Jul 23 2015, 15:22:56)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.0.5
cffi: Not Installed
cherrypy: 3.2.2
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libgit2: 0.20.0
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: 0.20.3
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: centos 6.5 Final
machine: x86_64
release: 2.6.32-431.el6.x86_64
system: CentOS 6.5 Final
Relevant Logs, Configs, or States
See attachement for full log. salt-ssh-err.txt
Possibly related to #31236 and #31074.
i am also seeing this, anything i can do to help diagnose?
note: i'm not using EC2, but openstack. trying to use the same version of salt-ssh to state.sls
@jakeswenson, I've never worked on salt-ssh, but you're welcome to start looking through the code if you have the time.
I believe this is related to the usage of tty: True. Can you confirm that removing that option gives the expected return data?
I ran into this bug this week. Centos 7 targets running on linode, Mac OS X running salt-ssh 2015.8.8.2 as the master.
Following @cachedout's suggestion I tried playing with the tty option. With "tty: True" I encountered the bug. After removing "Defaults requiretty" from the minion's sudoers and setting "tty: False" in the roster I was no longer affected by this bug.
@cachedout, @grep4linux, for what it's worth, I've isolated the place in the code where all the opts are dumped into the output and have extracted the error message although this does not fix the tty problem itself.
diff --git a/salt/client/ssh/__init__.py b/salt/client/ssh/__init__.py
index d9a61b3f..9e041b7 100644
--- a/salt/client/ssh/__init__.py
+++ b/salt/client/ssh/__init__.py
@@ -799,7 +799,7 @@ class Single(object):
if '_error' in opts_pkg:
# Refresh failed
- ret = json.dumps({'local': opts_pkg})
+ ret = json.dumps({'local': {'return': opts_pkg['_error']}})
retcode = opts_pkg['retcode']
return ret, retcode
This issue is related to #28073 and #32264.
There are a few commits which alternate this line, 0a3bed9db6a220a1fa44350def60708855feb7f8, 2669a09c974ab22fcee9a888f46efc833d0ac296, 074448bd56c4acf49faf158b1a03ee3e19c99bb8, 6795d6aef04e853038d58e8c3b1a986f86f74e1b, but when I try the form in #32218, SSH.handle_ssh never returns.
I have also encountered the same problem, now has been resolved:
0 : salt-ssh -i '' --roster-file roster state.sls init.init saltenv=base
0-1: Failed to return clean data
process:
1 debug with this comand: salt-ssh -i '' -l trace --roster-file roster test.ping
2 stdout:
# ERROR: No scp binary. openssh-clients package required
now,I know the reason。
resolved:
In the salt-ssh-client :
yum install openssh-clients -y
again, OK.
今天有遇到了相同的问题,巧合的是网上找了半天资料最总又回到了我发表的这个评论上,真是太巧了!
这次的问题yum install openssh-clients -y却没有解决,最后依靠老方法解决:
salt-ssh -i '10.162.2.6' -l trace --roster-file roster test.ping
使用最简单的模块检测是否运行正常,以精简输出,本次的数据结果是:
#省略部分输出...
File "/var/tmp/.root_be0ac5_salt/py2/salt/transport/ipc.py", line 10, in
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.