我正在尝试在Ubuntu 12.04上使用nginx运行乘客Web服务器的安装,使用Ansible 1.4.1似乎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
留下问题以供其他人参考
答案 0 :(得分:3)
由于您使用的是Ubuntu,只需使用Ansible通过apt-get安装the Phusion Passenger Debian packages(点击“Ubuntu”)。它与apt-getting其他任何东西完全相同,比使用RubyGems安装要容易得多,甚至为你安装所有必需的依赖项(包括Ruby本身!)
答案 1 :(得分:2)
中断,因为Ansible现在默认使用user_install选项进行gem安装,从Ansible 1.3开始
http://docs.ansible.com/gem_module.html#gem-manage-ruby-gems