ansible角色未在服务器上执行

时间:2018-01-24 03:36:53

标签: ubuntu amazon-ec2 ansible

我正在运行一个ansible playbook来在linux(ubuntu)ec2机器上安装新版本的ruby。

Playbook任务似乎正在运行但是当我检查服务器时没有任何改变。

---
- name: upgrade
  action: apt update_cache=yes upgrade=yes

- name: install ruby dependencies
  action: apt pkg={{item}} state=installed
  with_items:
    - build-essential
    - automake
    - bison
    - autoconf
    - pkg-config
    - libreadline6
    - libreadline6-dev
    - openssl
    - libssl-dev
    - curl
    - git-core
    - zlib1g
    - zlib1g-dev
    - libyaml-dev
    - libsqlite3-dev
    - libxml2-dev
    - libxslt1-dev
    - curl
    - libmagickwand-dev
    - imagemagick

- name: Install app dependencies
  action: apt pkg={{item}} state=installed
  with_items:
    - libpq-dev
    - nodejs
    - imagemagick
  tags: package

从这一点开始,我会跳过并更改,但服务器没有更改。

- name: ruby-from-src | ensure directory temporary ruby download directory is present
  file: state=directory path={{rubyTmpDir}}

- name: ruby-from-src | Download ruby source
  get_url: url={{rubyUrl}} dest={{rubyTmpDir}}

- name: ruby-from-src | ensure ruby is extracted
  command: tar -xf {{rubyCompressedFile}} chdir={{rubyTmpDir}} creates={{tmpRubyPath}}

- name: ruby-from-src | ensure ruby is configured
  command: ./configure chdir={{tmpRubyPath}} creates={{tmpRubyPath}}/Makefile

- name: ruby-from-src | ensure ruby is compiled
  command: make chdir={{tmpRubyPath}} creates={{tmpRubyPath}}/ruby

- name: ruby-from-src | ensure ruby is installed
  command: make install chdir={{tmpRubyPath}} creates=/usr/local/bin/ruby

- name: Install Bundler
  command: gem install bundler

我缺少什么。安装ruby依赖项就是这样做的,

输出

TASK [webserver : Install app dependencies] *************************************************************************
ok: [ec2-52-200-1-13.compute-1.amazonaws.com] => (item=[u'libpq-dev', u'nodejs', u'imagemagick'])

TASK [webserver : ruby-from-src | ensure directory temporary ruby download directory is present] ********************
ok: [ec2-52-200-1-13.compute-1.amazonaws.com]

TASK [webserver : ruby-from-src | Download ruby source] *************************************************************
changed: [ec2-52-200-1-13.compute-1.amazonaws.com]

TASK [webserver : ruby-from-src | ensure ruby is extracted] *********************************************************
skipping: [ec2-52-200-1-13.compute-1.amazonaws.com]

TASK [webserver : ruby-from-src | ensure ruby is configured] ********************************************************
skipping: [ec2-52-200-1-13.compute-1.amazonaws.com]

TASK [webserver : ruby-from-src | ensure ruby is compiled] **********************************************************
skipping: [ec2-52-200-1-13.compute-1.amazonaws.com]

TASK [webserver : ruby-from-src | ensure ruby is installed] *********************************************************
skipping: [ec2-52-200-1-13.compute-1.amazonaws.com]

TASK [webserver : Install Bundler] **********************************************************************************
skipping: [ec2-52-200-1-13.compute-1.amazonaws.com]

1 个答案:

答案 0 :(得分:0)

  

我正在运行一个ansible playbook来安装新版本的ruby

如果红宝石已经存在,则该剧本不会更新 你到处都有creates=标志。例如:

- name: ruby-from-src | ensure ruby is installed
  command: make install chdir={{tmpRubyPath}} creates=/usr/local/bin/ruby

只有在没有make install文件的情况下,此任务才会执行/usr/local/bin/ruby

从你的问题我认为你确实安装了ruby。在这种情况下,playbook会按预期跳过所有配置/安装任务。