Saltstack 找不到软件包

Saltstack 找不到软件包

也许我不明白 cmd 是如何工作的,但这是我正在使用的一些配置。这曾经是一个 jruby 安装,但我们正在转向 MRI,因此使用 jruby 用户名:

/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

这是 salt-highstate.log 中崩溃的具体位置。我不知道 gem install bundler 是如何成功的,但 bundle install 会失败(/home/jruby/api 是 git repo 签出的位置)。由于 rvm 需要 cd 来更新路径,我在其中添加了一个 cd。

      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

答案1

你最好使用 rvm 状态,然后执行所有命令逻辑

https://docs.saltstack.com/en/latest/ref/states/all/salt.states.rvm.html

相关内容