opscode/chef — pull request #1824 by jdmundrawala (2014-08-13 22:47:06+00:00)
Title: Jdmundrawala/dsc script

@adamedx @btm Here are the changes required to correctly(hopefully?) determine if a dsc requires changing the system state. Piggy-backing with that is improved descriptions for converge_by.

Below is an example run:
The environment var 'dscenv3' does not exist
The file C:\foobar.txt exists
The file C:\foobar1.txt does not exists

The recipe
```ruby
dsc_script 'myenv' do
code <<-EOH
environment "env3"
{
Name = 'dscenv3'
Value = 'itsthere'
}
EOH
end

dsc_script 'myfile' do
code <<-EOH
File OtherFile
{
Ensure = "Absent"
DestinationPath = "C:\\Foobar.txt"
}
EOH
end

dsc_script 'myfile1' do
code <<-EOH
File OtherFile
{
Ensure = "Absent"
DestinationPath = "C:\\Foobar1.txt"
}
EOH
end
```
Chef-client run before this patch
```
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* [myenv] action run
- Would DSC resource script for configuration 'myenv'
* [myfile] action run
- Would DSC resource script for configuration 'myfile'
* [myfile1] action run
- Would DSC resource script for configuration 'myfile1'
```
This is incorrect as [myfile1] should not run since it would not change the state of the system

Chef-client run after this patch
```
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* [myenv] action run
- Would DSC resource script for configuration 'myenv'
- Would (CREATE) Environment variable 'dscenv3' with value 'itsthere'
* [myfile] action run
- Would DSC resource script for configuration 'myfile'
- Would [C:\Foobar.txt] Deleting the object
* [myfile1] action run (up to date)
```