【发布时间】:2016-01-07 23:28:50
【问题描述】:
我正在尝试在来宾 VM 上配置 Ruby + Rails。这是我在playbook.yml 中的内容:
---
- hosts: all
sudo: true
tasks:
- apt: update_cache=yes
- apt: name={{ item }} state=present
with_items:
- build-essential
- git-core
- zlib1g-dev
- libssl-dev
- libreadline-dev
- libmysqlclient-dev
- libyaml-dev
- libxml2-dev
- libxslt1-dev
- libcurl4-openssl-dev
- python-software-properties
- libffi-dev
- curl
- command: git clone git://github.com/sstephenson/rbenv.git .rbenv
- shell: echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
- shell: echo 'eval "$(rbenv init -)"' >> ~/.bashrc
- shell: exec $SHELL
- command: git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
- shell: echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
- shell: exec $SHELL
- command: git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
- command: rbenv install 2.2.3
- command: rbenv global 2.2.3
- shell: echo 'gem{{":"}} --no-ri --no-rdoc' >> ~/.gemrc
- command: gem install bundler
- command: add-apt-repository -y ppa:chris-lea/node.js
- apt: update_cache=yes
- apt: name=nodejs state=present
- command: gem install rails -v 4.2.2
- command: rbenv rehash
配置时,Ansible 总是在任务 - shell: exec $SHELL 处挂起并且不会返回。但是当我通过 SSH 连接到机器并运行 exec $SHELL 时,它会执行并返回。当我在我的剧本中使用 - command: exec $SHELL 时,Ansible 会打印此错误:
failed: [default] => {"cmd": "exec /bin/bash", "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory
我可以确认/bin/bash 存在。
发生了什么事?我已经为此苦苦挣扎了半天了。请指教。
【问题讨论】:
标签: bash vagrant ansible ansible-playbook