summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSean Walberg <sean@ertw.com>2015-04-05 00:10:57 -0500
committerSean Walberg <sean@ertw.com>2015-04-05 00:10:57 -0500
commit4cdce72a39b6f2e9ad0eb3029d861c99494738f0 (patch)
tree7da84564e60bee3eef0f0266d818d6230cf98219 /lib
parent361ba778a36b9da6e29ece85c124babcbfaabdd8 (diff)
downloadchef-4cdce72a39b6f2e9ad0eb3029d861c99494738f0.tar.gz
Allow tags to be set on a node during bootstrap
I can set attributes, environment, and run_list, but why not tags? Some of our recipes are driven off of tags, such as for sudo access or membership in a load balancing pool. If this patch is accepted then I will add the corresponding feature to knife-vsphere. This patch only works with the new vault method, not the validator key method. If someone has some pointers on where to add it in the validator method I'd be happy to amend.
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/knife/bootstrap.rb6
-rw-r--r--lib/chef/knife/bootstrap/client_builder.rb3
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index a4095e8402..157c815a98 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -143,6 +143,12 @@ class Chef
:proc => lambda { |o| o.split(/[\s,]+/) },
:default => []
+ option :tags,
+ :long => "--tags TAGS",
+ :description => "Comma separated list of tags to apply to the node",
+ :proc => lambda { |o| o.split(/[\s,]+/) },
+ :default => []
+
option :first_boot_attributes,
:short => "-j JSON_ATTRIBS",
:long => "--json-attributes",
diff --git a/lib/chef/knife/bootstrap/client_builder.rb b/lib/chef/knife/bootstrap/client_builder.rb
index b9c1d98bec..32258f6fa5 100644
--- a/lib/chef/knife/bootstrap/client_builder.rb
+++ b/lib/chef/knife/bootstrap/client_builder.rb
@@ -140,6 +140,9 @@ class Chef
node.run_list(normalized_run_list)
node.normal_attrs = first_boot_attributes if first_boot_attributes
node.environment(environment) if environment
+ (knife_config[:tags] || []).each do |tag|
+ node.tags << tag
+ end
node
end
end