What is the easiest way to ignore a certain resource from the command-line?
I am using chef-solo
Some users of our product would like to leave a certain file or template unchanged by a chef-run for testing-purposes, and I was hoping for a flexible way to implement this functionality.
You can use action for template,
action :create_if_missing
This way, template will be created only if file is not existing.
If you want to specify more complex statement, use only_if
only_if { node[:some_value] }
You can make attributes like
default['template']['exclude_FILENAME'] = true
and then use it in Chef code. This way you could have file excludes.rb in attributes directory and change these options if you want.
Simple example:
template 'Some template you want to decide if it should be excluded' do
path '/tmp/somefile'
source 'template.erb'
only_if { node['template']['exclude_FILENAME'] }
end
This is not ignoring from command line, but you can give them excludes.rb file to edit... Or write simple shell script that asks user if it want to exclude resource and stores info in this file.
I hope this helps.