Open joelwilson opened 9 years ago
I looked through the code and now think that these methods maybe don't need to be implemented. Would it make sense to just not set file attributes for Windows nodes? They will get their attributes inherited anyway.
# In chef/provider/machine_file.rb
action :upload do
if new_resource.content
machine.write_file(action_handler, new_resource.path, new_resource.content)
else
machine.upload_file(action_handler, new_resource.local_path, new_resource.path)
end
### Wrap with this statement?
unless machine.kind_of?(Chef::Provisioning::Machine::WindowsMachine)
attributes = {}
attributes[:group] = new_resource.group if new_resource.group
attributes[:owner] = new_resource.owner if new_resource.owner
attributes[:mode] = new_resource.mode if new_resource.mode
end
machine.set_attributes(action_handler, new_resource.path, attributes)
end
Monkey-patching on my machine seems to work. In any case, this could be a workaround until attribute support for Windows is added, no?
Yeah. We can do one or the other, but one or the other we must do. Adding to the 1.0 ready queue :)
+1 on fixing this!
Still running into this one a year+ later. Seems like @joelwilson 's solution is an easy fix. Can we, can we?
One correction however. The machine.set_attributes line needs to be inside the block. A la...
### Wrap with this statement?
unless machine.kind_of?(Chef::Provisioning::Machine::WindowsMachine)
attributes = {}
attributes[:group] = new_resource.group if new_resource.group
attributes[:owner] = new_resource.owner if new_resource.owner
attributes[:mode] = new_resource.mode if new_resource.mode
machine.set_attributes(action_handler, new_resource.path, attributes)
end
Using the machine_file resource to upload a file to a windows machine results in an error:
The cause is pretty obvious; the
set_attributes
andget_attributes
in WindowsMachine.rb are not implemented in the windows machine provider.Reproduce:
Full error message
I know very little Ruby and nothing about writing custom Chef code, but I'd be willing to give it a try if somebody can point me in the right direction (Ex. code to port this functionality from).