Don't use ~/
in your path; this is why the creates
line was not working to prevent the execute
resource from being run when the file already existed.
execute 'change sources to our gem server' do
command "#{remove_rubygems} && gem sources -a http://mygemserver"
creates "/root/.gemrc"
end
Alternately, if you want to check whether the file contains a specific line:
execute 'change sources to our gem server' do
command "#{remove_rubygems} && gem sources -a http://mygemserver"
not_if "grep -F -q -e http://mygemserver/ ~/.gemrc" # this uses a shell, so the
# tilde should work here.
end