微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby – 如何从Ansible安装passenger-nginx?

我正在尝试使用Ansible 1.4.1在Ubuntu 12.04上使用Nginx运行乘客Web服务器的安装.似乎gem安装正在搞乱或者其他什么,因为ansible找不到命令,当我重新安装时宝石手工制作.我究竟做错了什么?

# ruby.yml

- name: "install ruby"
  script: scripts/install_ruby.sh

- name: "Install bundler"
  gem: name=bundler state=latest

- name: "Install passenger"
  gem: name=passenger state=latest

- name: "copy Nginx upstart"
  copy: src=Nginx.conf dest=/etc/init/Nginx.conf mode=0644 owner=root group=root

- name: Install passenger-Nginx
  command: passenger-install-Nginx-module --auto-download --auto --prefix=/opt/Nginx --extra-configure-flags='--with-http_gzip_static_module --with-http_secure_link_module --with-http_realip_module --with-http_ssl_module' creates=/opt/Nginx

- name: "Enable Nginx"
  service: name=Nginx state=started enabled=yes

错误

TASK: [common | install ruby] *************************************************
changed: [staging-2.coinvalley.com]

TASK: [common | Install bundler] **********************************************
ok: [staging-2.coinvalley.com]

TASK: [common | Install passenger] ********************************************
ok: [staging-2.coinvalley.com]

TASK: [common | copy Nginx upstart] *******************************************
ok: [staging-2.coinvalley.com]

TASK: [common | Install passenger-Nginx] **************************************
Failed: [staging-2.coinvalley.com] => {"cmd": ["passenger-install-Nginx-module", "--auto-download", "--auto", "--prefix=/opt/Nginx", "--extra-configure-flags=--with-http_gzip_static_module --with-http_secure_link_module --with-http_realip_module --with-http_ssl_module"], "Failed": true, "item": "", "rc": 2}
msg: [Errno 2] No such file or directory

FATAL: all hosts have already Failed -- aborting

当我进去时,我看到宝石存在:

root @staging-2:〜#gem list

*** LOCAL GEMS ***

bigdecimal (1.2.3)
bundler (1.5.2)
daemon_controller (1.1.8)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
passenger (4.0.36)
psych (2.0.2)
rack (1.5.2)
rake (10.1.0)
rdoc (4.1.0)
test-unit (2.1.0.0)

但是,当我尝试运行install命令时,它仍然无法正常工作:

root@staging-2:~# passenger-install-Nginx-module
passenger-install-Nginx-module: command not found

它只有在重新运行时才有效:

gem install passenger

Ruby是从源代码安装的,这是我的gem env

root@staging-2:~# gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.0
  - RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /root/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.1.0
     - /root/.gem/ruby/2.1.0
  - GEM CONfigURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games

我看到GEM PATH目录中的可执行文件

- /root/.gem/ruby/2.1.0

但显然这不会被添加到主要路径?

Ansible的gem模块可以在幕后使用–user-install option吗?

好吧,显然它是:http://docs.ansible.com/gem_module.html#gem-manage-ruby-gems

留下问题供其他人参考

解决方法:

因为你在Ubuntu上,只需使用Ansible通过apt-get安装the Phusion Passenger Debian packages(点击“Ubuntu”).它与apt-getting其他任何东西完全相同,比使用RubyGems安装要容易得多,甚至为你安装所有必需的依赖项(包括Ruby本身!)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐