You are absolutely right.
I think I am realizing that when I need to check something before I DO something within Chef, I run into having to know a bit of Ruby syntax. Trying to learn that now.
For example, BEFORE I tell Chef to run a execute block, I know that I can use the guard not_if
to check for something.
e.g.
execute "unzip #{folder}/installer.zip -d #{node[:app][:installer_dir]}" do
user node[:app][:user]
group node[:app][:group]
not_if { File.exists?("#{node[:app][:installer_dir]}/app") }
end
What I need to figure out is some examples and "possible options that I can use" for the not_if
section.
For example, if I can run a bash command and grep for a particular exit code or output AS PART OF the not_if block, I can then determine if the cert already exists and if so, not execute the "import cert" execute block and that way make the "import cert" execute block idempotent.
Regards
Aravind