Issue #8415 has been updated by Dan Bode.

Branch set to 
https://github.com/bodepd/puppet-cloudpack/tree/issue/master/8415_fix_tmp_file


----------------------------------------
Bug #8415: script tmp file does not always exist when we try to scp it
https://projects.puppetlabs.com/issues/8415

Author: Dan Bode
Status: Unreviewed
Priority: High
Assignee: 
Category: 
Target version: 
Keywords: 
Branch: 
https://github.com/bodepd/puppet-cloudpack/tree/issue/master/8415_fix_tmp_file


The symptom of this issue is the following error message:

<pre>
err: No such file or directory - 
/var/folders/co/coFoByf5E3GCBRvVpQOD6E+++TI/-Tmp-/install_script20110713-12603-hrci3m-0
err: Try 'puppet help node install' for usage
</pre>

The problem appears to be that I was writing to a temporary file without 
closing it properly.

The following code seems to resolve the issue:

<pre>
-      tmp_install_script = Tempfile.new('install_script').path
-      File.open(tmp_install_script, 'w') do |fh|
-        fh.write(install_script)
+
+      # create a temp file to write compiled script to
+      # capture the name of the path as tmp_install_script
+      tmp_install_script = begin
+        f = Tempfile.open('install_script')
+        f.write(install_script)
+        f.path
+      ensure
+        f.close
       end
</pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to