0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[ chef ]data_bagsの書き方と取り出し方その2(配列パターン)

Posted at

1. data_bags

data_bags/sample/sample002.json
{
    "id":"sample002",
    "samplekey02":[
        "value001",
        "value002",
        "value003",
        "value004",
        "value005"
    ],

    (...中略)

}

key(i.e."samplekey02")にひもづく配列を格納する。この場合は[]で配列の要素を囲む。

2. recipe

recipe/sample.rb
array_item = data_bag_item('sample','sample002')['samplekey02']
tmp_array << array_item

例えばこのように配列ごとdata_bagsから取り出して、別の配列tmp_arrayに追加することができる。
またはeach文で繰り返し処理などでも使える。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?