LoginSignup
2
2

More than 5 years have passed since last update.

Itamae | Node Attributes #devops #itamae

Posted at

Itamae | Node Attributes #devops #itamae

概要

プロビジョニングツール Itamae

Node Attributes について。

json ファイルで定義した Node Attributes を利用して、
レシピの内容を動的に変更して、柔軟性を高めることが出来ます。
例えば、version指定を Node Attributes にすることで、
別バージョンを指定するだけのレシピを何度も作成せずに、
一つのレシピで管理出来ます。

前提

試行

レシピを作成

require 'itamae/plugin/resource/toilet'

node[:toilets].each do |t|
  t[:text]
  toilet t[:text] do
    filters t[:filters] if t[:filters]
  end
end

Gemfile を作成

source 'http://your_gem_server:your_port/'

gem 'itamae'
gem 'itamae-plugin-resource-toilet'
# geminabox(private gem server) から itamae-plugin-resource-toilet を install
$ bundle install
$ gem list | grep itamae
itamae (1.0.1)
itamae-plugin-resource-toilet (0.0.1)

node.json を作成

{
  "toilets": [
    {
      "text": "hoge",
      "filters": ["gay"]
    },
    {
      "text": "hige",
      "filters": ["gay", "flip"]
    },
    {
      "text": "hage",
      "filters": ["gay", "border"]
    },
    {
      "text": "hege"
    }
  ]
}

実行

※実行前に toilet はインストール済みとする

$ bundle exec itamae local --node-json node.json recipe.rb
 INFO : Starting Itamae...
 INFO : Loading node data from /home/vagrant/node_attributes_test/node.json...
 INFO : Recipe: /home/vagrant/node_attributes_test/recipe.rb
 INFO :    toilet[hoge]
 INFO :       action: run
 INFO :
#
 # mm    mmm    mmmm   mmm
 #"  #  #" "#  #" "#  #"  #
 #   #  #   #  #   #  #""""
 #   #  "#m#"  "#m"#  "#mm"
                m  #
                 ""
 INFO :    toilet[hige]
 INFO :       action: run
 INFO :
"        #
  mmm   mmmm     mmm   mm #
 #  "#  #" "#    #    #  "#
 """"#  #   #    #    #   #
 "mm#"  #"m#"  mm#mm  #   #
        #  m
         ""
 INFO :    toilet[hage]
 INFO :       action: run
 INFO :
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
x                            x
x #                          x
x # mm    mmm    mmmm   mmm  x
x #"  #  "   #  #" "#  #"  # x
x #   #  m"""#  #   #  #"""" x
x #   #  "mm"#  "#m"#  "#mm" x
x                m  #        x
x                 ""         x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
 INFO :    toilet[hege]
 INFO :       action: run
 INFO :
#
 # mm    mmm    mmmm   mmm
 #"  #  #"  #  #" "#  #"  #
 #   #  #""""  #   #  #""""
 #   #  "#mm"  "#m"#  "#mm"
                m  #
                 ""

node_attributes.png

参照

2
2
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
2
2