Chef - 防止执行多个资源
Chef - Prevent execution of multiple resources
假设我有 3 个 execute
资源 'Create users'、'Install client' 和 'Verify client'.
如果满足一个条件,我如何才能阻止执行所有这些资源?
类似于:
block 'Manage client' do
execute 'Create users' do
cwd scripts_path
command './installClient.sh -create_users'
end
execute 'Install client' do
cwd scripts_path
command '/installClient.sh -installClient'
end
execute 'Verify client' do
cwd scripts_path
command './installClient.sh -verifyClient'
end
not_if { ::File.exists?('/tmp/client_configured_success') }
end
像在任何其他 Ruby 代码中一样使用正常的 if/unless
条件。
unless File.exist?('/tmp/client_configured_success')
execute 'Create users' do
cwd scripts_path
command './installClient.sh -create_users'
end
execute 'Install client' do
cwd scripts_path
command '/installClient.sh -installClient'
end
execute 'Verify client' do
cwd scripts_path
command './installClient.sh -verifyClient'
end
end
假设我有 3 个 execute
资源 'Create users'、'Install client' 和 'Verify client'.
如果满足一个条件,我如何才能阻止执行所有这些资源?
类似于:
block 'Manage client' do
execute 'Create users' do
cwd scripts_path
command './installClient.sh -create_users'
end
execute 'Install client' do
cwd scripts_path
command '/installClient.sh -installClient'
end
execute 'Verify client' do
cwd scripts_path
command './installClient.sh -verifyClient'
end
not_if { ::File.exists?('/tmp/client_configured_success') }
end
像在任何其他 Ruby 代码中一样使用正常的 if/unless
条件。
unless File.exist?('/tmp/client_configured_success')
execute 'Create users' do
cwd scripts_path
command './installClient.sh -create_users'
end
execute 'Install client' do
cwd scripts_path
command '/installClient.sh -installClient'
end
execute 'Verify client' do
cwd scripts_path
command './installClient.sh -verifyClient'
end
end