【发布时间】:2018-05-29 08:53:46
【问题描述】:
我正在使用厨师来执行此操作:
我试图让一个 bash 块只在前一个运行之后运行,很简单,我使用通知。我还希望在初始运行和第二次运行时进行锁定文件检查(有没有更好的方法来确保它仅在前一个 bash 块运行时运行?)。
这是我目前的厨师代码:
if not File.exist? tsm_login_lock
bash 'login_tsm' do
user tableau_user
cwd tableau_user_home
code <<-EOH
source /etc/profile.d/tableau_server.sh
tsm login -u #{tableau_user} -p #{password}
tsm settings import -f /home/analytics/setting_file.json
tsm pending-changes apply
tsm licenses activate -k #{key}
tsm register --file #{registration}
tsm pending-changes apply
EOH
notifies :run, "bash[tsm_init]", :immediately
end
file tsm_login_lock do
mode '0644'
content 'tableau server stareted'
end
end
if not File.exist? tsm_init_lock
bash 'tsm_init' do
user tableau_user
cwd tableau_user_home
code <<-EOH
tsm initialize --start-server --request-timeout 1800
EOH
notifies :run, "bash[tsm_2]", :immediately
end
file tsm_init_lock do
mode '0644'
content 'tableau server initialized'
end
end
【问题讨论】:
标签: ruby bash chef-infra chef-recipe