salt icon indicating copy to clipboard operation
salt copied to clipboard

Expect support in salt stack

Open majo83 opened this issue 13 years ago • 8 comments

Hey folks,

I recently learned about the very cool unix utility expect, which is basically a tool script a unix terminal (and not just just the shell, like in a ordinary shell script). See here http://manpages.ubuntu.com/manpages/hardy/man1/expect.1.html . It's very handy to automate install dialogs and the like, and I am surprised that also other config-management solutions (like e.g. puppet) seem to lack proper support for that tool.

I think that would be a very handy together with salt stack. There's also a python version lying around here: http://sourceforge.net/projects/pexpect/

See also here: http://en.wikipedia.org/wiki/Expect

Best regards, majo83

majo83 avatar Aug 15 '13 08:08 majo83

Can you provide a use case?

terminalmage avatar Aug 15 '13 15:08 terminalmage

@majo83, expect is a very cool tool, and IIRC we used to use pexpect extensively in salt-cloud (until we switched to sshpass, which made life even simpler for ssh). If a use case arises where (p)expect makes sense, we have no qualms with using it.

techhat avatar Aug 15 '13 16:08 techhat

Also, when it comes to expect, the main use case is with ssh, and we have a lot of new ssh command wrappers and capabilities coming in 0.17.0

thatch45 avatar Aug 15 '13 17:08 thatch45

@majo83, just want to point out that we're not trying to discourage using (p)expect. Like I said, it's a great tool. What specifically are you thinking about using it for?

techhat avatar Aug 15 '13 17:08 techhat

My case: I recently had to use it together with salt stack to install sentry (see here: https://getsentry.com/welcome/ and here: https://sentry.readthedocs.org/en/latest/quickstart/index.html ): It runs on django, the installation is somewhat burdensome: Somewhere in the installation you have to add a django superuser by using an interactive dialog. I had to write an expect script for that.

That would be my main usage intent: Handling interactive dialogs. Might come also handy for install-configuration of ubuntu/redhat packages.

majo83 avatar Aug 16 '13 06:08 majo83

@majo83 sounds like not only a pretty classic use case, but also a perfect example of the kind of thing that would do well as a salt formula. If I created a repo for sentry inside the https://github.com/saltstack-formulas organization, would you be interested in sharing some of your work with the community?

techhat avatar Aug 16 '13 14:08 techhat

+1 for expect/pexpect integration... maybe in the cmd state... ssh is not the only usecase; Other cases are all these commands that prompts for user input but does not accept command line arguments.

Some examples:

  • create a samba user: 'smbpasswd -a user' does not accept password as command argument but asks on prompt.
  • ispconfig installation asks for user input and does not accept command arguments
  • checkout a svn repo with invalid certificate (wrong hostname) that need "accept permanently" prompt explicitly (--trust-server-cert is not enough)
  • Many others

parruc avatar Nov 08 '13 10:11 parruc

I am closing this ticket due to inactivity. If anyone feels that this feature needs more attention feel free to reopen it.

arroyoc avatar Jan 14 '16 20:01 arroyoc