- From: Chris Burroughs <
>
- To:
- Subject: [chef] Re: Re: renaming a role
- Date: Tue, 29 Apr 2014 10:03:22 -0400
Thanks for the pointer.
I've put something together with knife-exec that seems to work.
(Although warning to copy and pasters, has not been run in production yet.)
role_from = ARGV[2] # format role[foo]'
role_to = ARGV[3]
if ARGV.length > 3 and ARGV[4] == 'dry-run'
dry_run = true
else
dry_run = false
end
puts role_from
nodes.all do |node|
if node.run_list.include?(role_from)
puts "match #{node}, current run_list #{node.run_list}"
if node.run_list.include?(role_to)
puts "ERROR #{node} has #{role_from} and #{role_to} skipping"
next
end
pos = -1
node.run_list.each_with_index do |item, index|
if item == role_from
pos = index
break
end
end
node.run_list.run_list_items[pos] =
node.run_list.coerce_to_run_list_item(role_to)
puts "\tchange @pos=#{pos} new run list #{node.run_list}"
if dry_run == false
node.save()
puts "\tsaving node #{node}"
end
end
end
exit 0
On 04/25/2014 02:58 PM, Matt Ray wrote:
Sounds like a job for knife exec?
http://docs.opscode.com/knife_exec.html
Thanks,
Matt Ray
Director of Partner Integration :: Chef
512.731.2218 ::
mattray :: GitHub :: IRC :: Twitter
On Fri, Apr 25, 2014 at 1:56 PM, Chris Burroughs
<
>
wrote:
We have a bunch of roles called foo-abc-123 that we would like to rename
bar-abc-123. I've done several naive searches like on how to rename or
change role names without finding anything.
Obviously for local purposes I can do git mv && unload-new-name, but that
would leave all of the nodes with $OLD_NAME in a lurch.
Ideally I'd like to find some sort of integrated rename mechanism. Lacking
that I think my question becomes: How do I change the run lists of all nodes
with role[foo] to role[bar] without changing anything else about the run
list?
Archive powered by MHonArc 2.6.16.