Maybe I don't understand how cmd is working, but here is some of the config I am using. This used to be a jruby install but we are moving to MRI, hence the jruby username:
/home/jruby/tmp/rvm-install.tgz:
file.managed:
- source: salt://canned/rvm-1.26.11-install_files.tgz
- makedirs: True
- user: jruby
- group: jruby
- mode: 0644
- require:
- user: jruby
rvm-install:
cmd.run:
- name: "tar xzf tmp/rvm-install.tgz"
- cwd: /home/jruby
- shell: /bin/bash
- user: jruby
- group: jruby
- require:
- pkg: ruby-deps
- file: /home/jruby/tmp/rvm-install.tgz
bash-init:
file.append:
- name: /home/jruby/.bash_profile
- user: jruby
- group: jruby
- text:
- '[[ -r $HOME/.rvm/scripts/rvm ]] && . "$HOME/.rvm/scripts/rvm"'
- "export RACK_ENV={{ grains[ 'rack_env' ] }}"
- "export GITHUB_BRANCH={{ grains[ 'github'] }}"
- require:
- cmd: rvm-install
ruby-223:
cmd.run:
- name: "cd /home/jruby/api && rvm install ruby-2.2.3"
- shell: /bin/bash
- user: jruby
- group: jruby
- require:
- file: bash-init
bundler-install:
cmd.run:
- name: "cd /home/jruby/api && gem install bundler && bundle install"
- cwd: /home/jruby/api
- user: jruby
- group: jruby
- shell: /bin/bash
- require:
- cmd: ruby-223
- git: jruby-api-source
And this is the salt-highstate.log specifically where it is crashing. I have no idea how gem install bundler will succeed, but then the bundle install will fail (/home/jruby/api is where the git repo is checked out). Due to rvm needed a cd to update the path, I am adding a cd in there.
ID: bundler-install
Function: cmd.run
Name: cd /home/jruby/api && gem install bundler && bundle install
Result: False
Comment: Command "cd /home/jruby/api && gem install bundler && bundle install" run
Started: 21:26:52.595969
Duration: 6576.993 ms
Changes:
----------
pid:
21192
retcode:
1
stderr:
/usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- io/console (LoadError)
from /usr/share/ruby/vendor_ruby/2.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/lib/bundler/vendor/thor/lib/thor/shell/basic.rb:2:in `<top (required)>'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/lib/bundler/ui/shell.rb:12:in `initialize'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/lib/bundler/cli.rb:12:in `new'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/lib/bundler/cli.rb:12:in `rescue in start'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/lib/bundler/cli.rb:10:in `start'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/exe/bundle:19:in `block in <top (required)>'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/lib/bundler/friendly_errors.rb:7:in `with_friendly_errors'
from /home/jruby/.gem/ruby/2.0/gems/bundler-1.11.2/exe/bundle:17:in `<top (required)>'
from /home/jruby/bin/bundle:23:in `load'
from /home/jruby/bin/bundle:23:in `<main>'
stdout:
Successfully installed bundler-1.11.2
Parsing documentation for bundler-1.11.2
Installing ri documentation for bundler-1.11.2
Done installing documentation for bundler after 4 seconds
1 gem installed