おじさんAのプログラムメモ

30代のおじさんの主にプログラムについてのブログです

Itamaeで、templateでvariablesによる置換がうまくいかなかったのが解決した話

Itamaeを使っているんだが、templateでのvariablesの置換がうまくいかない。 置換できる変数と、置換できない変数がある。

以下実際に試してみたもの。

 # test_recipe.rb
 template "/home/vagrant/unko.txt" do
      action :create
      source "template.erb"
      variables(message: "World")
      variables(app: "APPPPP")
      variables(proj: "PROJJJJJJJJ")
      variables(python: "PYTHONNNNNN")
 end


 # template.erb
 Hello, <%= @message %>
 proj, <%= @proj %>
 app, <%= @app %>
 python, <%= @python %>

実行

 itamae ssh --vagrant test_recipe.rb -l debug

で、実際出来たのが

 # /home/vagrant/unko.txt
 Hello,
 proj,
 app,
 python, PYTHONNNNNN

Why???

解決編

と、ここまで書いていて気がついた

 variables(message: "World", proj: "PROJJJJJJJJ", app: "APPPPP", python: "PYTHONNNNNN")

こうか。。。 Rubyだもんね。。。