0

I don't like the default behavior of this command:

knife node run_list add myserver '"role[THISISATEST]"'

It adds THIISATEST even if the role doesn't exists. Is there a switch or argument that will prevent knife from adding a role/recipe to a node if it does not exist?

red888
  • 27,709
  • 55
  • 204
  • 392

2 Answers2

0

I don't think so. I suppose you could always do it with a script.

#!/usr/bin/env ruby

role = 'THISISATEST' # or ARGV.first
if %x(knife role list).include? role
  %x(knife node run_list add myserver 'role[#{role}]')
else
  puts 'No such role'
end
DigitalRoss
  • 143,651
  • 25
  • 248
  • 329
0

You would probably do this with a knife exec script of some form, but it's hard to know exactly what code to use without more information.

coderanger
  • 52,400
  • 4
  • 52
  • 75