Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Created March 11, 2016 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chewmanfoo/49d3872bbbfcb1294326 to your computer and use it in GitHub Desktop.
Save chewmanfoo/49d3872bbbfcb1294326 to your computer and use it in GitHub Desktop.
ruby file write doesn't work
require 'tmpdir'
require 'fileutils'
_role="test"
Dir.mktmpdir do |dir|
git_dir="#{dir}"
`git clone http://10.23.227.82/control/corpit-env_control.git #{dir}`
File.open("#{dir}/Puppetfile.temp", "w") do |out_file|
File.foreach("#{dir}/Puppetfile") do |line|
out_file.puts line unless (line.include? "profile_#{_role}")
end
end
FileUtils.mv("#{dir}/Puppetfile", "#{dir}/Puppetfile.temp")
`ls #{dir}`
`cat #{dir}/Puppetfile.temp`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment