Help us understand the problem. What is going on with this article?

Chef v13でtimezone-iiを使う(なるべく使わない方が良い)

More than 1 year has passed since last update.

前任者から引き継いだ開発環境(Vagrant + Chef)が起動できなかったのでメモ。
今更感がすごい気がしますが。。

実施環境

  • OS: macOS Sierra (10.12.6)
  • Vagrant: 1.9.8
  • Virtualbox: 5.1.26 r117224
  • Chef Client: 13.3.42
  • Ruby: 2.4.1p111
  • Box: ubuntu/trusty64

エラー

NoMethodError
-------------
undefined method `tz=' for #<Chef::Node...>

原因

timezone-iiがハッシュでドット記法を使っているため。

対応

1. timezone-iiを使わない(推奨)

プロジェクト自体が死んでいるようなので、そもそも使わない方が良い。
PRはたくさん出ているが全くマージされていない(後述の修正を含むPRも出ている)。

2. ドット記法を修正する

こんな感じでcookbookを編集する。

attributes/default.rb
// 修正前
default.tz = value_for_platform_family(
  〜中略〜
)

// 修正後
default['tz'] = value_for_platform_family(
  〜中略〜
)

一括置換
Atomとか: ([a-zA-Z]).([a-zA-Z_]+) を \$1['$2']
Vim: %s/(\a).([a-zA-Z_]+)/\1['\2']/g

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした