sprinkle-tool / sprinkle

Sprinkle is a software provisioning tool you can use to build remote servers with. eg. to install a Rails, or Sinatra stack on a brand new slice directly after its been created
https://github.com/sprinkle-tool/sprinkle
MIT License
1.15k stars 138 forks source link

--gecos flag needs a space before it #110

Closed kimptoc closed 11 years ago

kimptoc commented 11 years ago

Hi,

Maybe I am not passing the correct options, but when I add a user, it seems to stall on the user input bit, eg asking for Full Name.

package:

package :add_user do
  add_user opts[:username], :flags => "--disabled-password"
  #add_user opts[:username], :flags => "--ingroup sudo --disabled-password"

  #verify do
  #  has_user opts[:username]
  #end
end

The run below hangs, until I pressed CTRL-C, which gave the stack trace shown.

error:

$ sprinkle -v -c -s init_server.rb                 
[myapp]
--> Cloud hierarchy for policy myapp
  * requires package ubuntu_version
  * requires package add_user
--> Normalized installation order for all packages: ubuntu_version, add_user

  * ubuntu_version
ubuntu_version install sequence: lsb_release -r for roles: app

    --> Running Sprinkle::Installers::Runner for roles: app
ssh: lsb_release -r
stdout said-->
Release:    12.04

success
process returning ["xxx"]
    --> INSTALLED for roles: app
  * add_user
add_user install sequence: adduser --disabled-password kimptoc for roles: app

    --> Running Sprinkle::Installers::User for roles: app
ssh: adduser --disabled-password kimptoc
stdout said-->
Adding user `kimptoc' ...
Adding new group `kimptoc' (1000) ...

stdout said-->
Adding new user `kimptoc' (1000) with group `kimptoc' ...

stdout said-->
Creating home directory `/home/kimptoc' ...
Copying files from `/etc/skel' ...

stdout said-->
Changing the user information for kimptoc
Enter the new value, or press ENTER for the default
    Full Name []:

s

^C/Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/net-ssh-2.6.7/lib/net/ssh/ruby_compat.rb:30:in `select': Interrupt
    from /Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/net-ssh-2.6.7/lib/net/ssh/ruby_compat.rb:30:in `io_select'
    from /Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/net-ssh-2.6.7/lib/net/ssh/connection/session.rb:204:in `process'
    from /Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/net-ssh-2.6.7/lib/net/ssh/connection/session.rb:164:in `block in loop'
    from /Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/net-ssh-2.6.7/lib/net/ssh/connection/session.rb:164:in `loop'
    from /Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/net-ssh-2.6.7/lib/net/ssh/connection/session.rb:164:in `loop'
    from /Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/sprinkle-0.5.2/lib/sprinkle/actors/ssh.rb:227:in `channel_runner'
    from /Users/kimptoc/.rvm/gems/ruby-2.0.0-p195@p-box-mgr/gems/sprinkle-0.5.2/lib/sprinkle/actors/ssh.rb:188:in `ssh'
joshgoebel commented 11 years ago

Looks like you're using an old version of sprinkle. The latest should always call add user with --gecos ,,, which avoids all the prompts.

https://github.com/sprinkle-tool/sprinkle/blob/bfbd0d7995debbdbffb49ab514aaeff54b18804f/lib/sprinkle/installers/user.rb#L41

joshgoebel commented 11 years ago

Ref: https://github.com/sprinkle-tool/sprinkle/issues/88

kimptoc commented 11 years ago

Using 0.5.2 - will give the github/head version a go.

kimptoc commented 11 years ago

Could do with an extra space... :)

my package line is:

  add_user 'kimptoc', :flags => "--ingroup sudo --disabled-password"

But get error:

ssh: adduser --ingroup sudo --disabled-password--gecos ,,, kimptoc
stderr said -->
Unknown option: disabled-password--gecos

stdout said-->
adduser [--home DIR] [--shell SHELL] [--no-create-home] [--uid ID]
[--firstuid ID] [--lastuid ID] [--gecos GECOS] [--ingroup GROUP | --gid ID]
[--disabled-password] [--disabled-login] [--encrypt-home] USER
   Add a normal user
kimptoc commented 11 years ago

In 0.5.2, I was doing the following to get parameters/options passed into a package, like this:

  requires :add_user, :username => 'kimptoc', :sudo => true

and then in my add_user package, I did this:

  add_user opts[:username], :flags => "--ingroup sudo --disabled-password"

But this does not work in 0.6 - is there a suggested way of doing this in 0.6?

Many Thanks, Chris

joshgoebel commented 11 years ago

The latter should still work just fine. If not please open another issue for it with further details and full example code. The logic that makes that work hasn't changed much that I recall between 0.5 and 0.6.

I've added a space to the flags and will pus 0.6.1 soon.

kimptoc commented 11 years ago

Thank you.