這裏是我的劇本負責從源下載和建設的紅寶石部分:Ansible:定義當命令沒有運行(從源代碼構建紅寶石)
vars:
ruby_version: '2.0.0-p247'
ruby_url: 'ftp://ftp.ruby-lang.org//pub/ruby/2.0/ruby-{{ ruby_version }}.tar.gz'
tasks:
- name: Ensure ruby dependencies are installed
apt: pkg=$item state=installed update-cache=yes
sudo: yes
with_items:
- build-essential
- git-core
- libreadline6-dev
- libyaml-dev
- libsqlite3-dev
- sqlite3
- libgdbm-dev
- libncurses5-dev
- libtool
- bison
- libffi-dev
- libdigest-hmac-perl
- unzip
- zlib1g
- zlib1g-dev
- name: Ensure the ruby source is downloaded
get_url: url=$ruby_url dest=/home/vagrant/ruby-{{ ruby_version }}.tar
- name: Ensure the ruby source is extracted
command: tar -zxf /home/vagrant/ruby-$ruby_version.tar creates=/home/vagrant/ruby-{{ ruby_version }}
- name: Ensure ruby is installed
command: $item chdir=/home/vagrant/ruby-$ruby_version
with_items:
- ./configure
- make
- sudo make install
的最後一個任務(配置化妝並進行安裝)在每個配置中運行。
我可以檢查ruby是否已經安裝了正確的版本ruby -v
。我如何在我的劇本中定義這是執行此步驟的條件?
另外,有沒有辦法讓這成爲整個任務列表的一個條件,而不僅僅是最後一個?
而如果ruby沒有安裝呢? – kovpack