【vagrant】ERROR! ‘yum’ is not a valid attribute for a Play エラー

ああ、ansibleに早く慣れたい・・・。

- hosts: all
  user: vagrant
  tasks:
    - name: install mysql
      yum: name=mysql state=installed

- name: Install requirements library
  yum: name={{ item }} state=latest update_cache=yes
  with_items:
    - git
    - gcc
    - gcc-c++
    - openssl-devel
    - readline-devel
    - zlib-devel

これで、

ERROR! 'yum' is not a valid attribute for a Play

The error appears to have been in '/vagrant/ansible/site.yml': line 6, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

      yum: name=mysql state=installed
- name: Install requirements library
  ^ here

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

このエラーが出ます。

yamlのインデントがおかしいので、解釈できないようです。

ちなみに次のようにだと・・

- hosts: all
  user: vagrant
  tasks:
    - name: install mysql
      yum: name=mysql state=installed

  - name: Install requirements library
    yum: name={{ item }} state=latest update_cache=yes
    with_items:
      - git
      - gcc
      - gcc-c++
      - openssl-devel
      - readline-devel
      - zlib-devel

  - name: Clone rbenv repository
    git: repo=git://github.com/sstephenson/rbenv.git dest=/usr/local/src/rbenv accept_hostkey=yes

  - name: Clone ruby-build repository
    git: repo=git://github.com/sstephenson/ruby-build.git dest=/usr/local/src/rbenv/plugins/ruby-build accept_hostkey=yes

  - name: Add /etc/profile.d/rbenv.sh
    copy: src=rbenv.sh dest=/etc/profile.d

  - name: Register ruby version status
    command: /bin/bash -lc "rbenv versions | grep 2.3.0 | wc -l"
    register: ruby_version_stat

  - block:

      - name: Install ruby
        command: /bin/bash -lc "rbenv install 2.3.0"
      - name: Use ruby version
        command: /bin/bash -lc "rbenv global 2.3.0"

    when: ruby_version_stat.stdout != "1"
ERROR! Syntax Error while loading YAML.

The error appears to have been in '/vagrant/ansible/site.yml': line 7, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  - name: Install requirements library
  ^ here

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

普通に文法がおかしいとエラーを返してもらえます。

はー、ansibleでサクサク環境構築できるのはいつになるやら。

スポンサーリンク

シェアする

  • このエントリーをはてなブックマークに追加

フォローする

スポンサーリンク