Skip to content

Instantly share code, notes, and snippets.

@jasherai
Forked from adamhjk/knife-app.txt
Created December 11, 2009 00:55
Show Gist options
  • Save jasherai/253872 to your computer and use it in GitHub Desktop.
Save jasherai/253872 to your computer and use it in GitHub Desktop.
Usage: ./knife-app sub-command (options)
-k, --key KEY API Client Key, defaults to OPSCODE_KEY
-c, --config CONFIG The configuration file to use
-e, --editor EDITOR Set the editor to use for interactive commands
-l, --log_level LEVEL Set the log level (debug, info, warn, error, fatal)
-L, --logfile LOGLOCATION Set the log file location, defaults to STDOUT
-u, --user USER API Client Username, defaults to OPSCODE_USER
-p, --print-after Show the data after a destructive operation
-v, --version Show chef version
-y, --yes Say yes to all prompts for confirmation
-h, --help Show this message
Sub-Command: node bulk delete (options)
-r, --regex [REGEX] Narrow the operation via regular expression
Sub-Command: node delete NODE (options)
Sub-Command: node edit NODE (options)
-a, --attribute [ATTR] Edit only one attribute
Sub-Command: node list (options)
-w, --with-uri Show corresponding URIs
Sub-Command: node run_list add [NODE] [ENTRY] (options)
-a, --after [ITEM] Place the ENTRY in the run list after ITEM
Sub-Command: node run_list remove [NODE] [ENTRY] (options)
Sub-Command: node show NODE (options)
-a, --attribute [ATTR] Show only one attribute
-r, --run-list Show only the run list
Sub-Command: role create ROLE (options)
-d, --description The role description
Sub-Command: role list (options)
-w, --with-uri Show corresponding URIs
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2009 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'chef/knife'
require 'chef/role'
require 'json'
class Chef
class Knife
class RoleCreate < Knife
banner "Sub-Command: role create ROLE (options)"
option :description,
:short => "-d",
:long => "--description",
:description => "The role description"
def run
role = Chef::Role.new
role.name(@name_args[0])
role.description(config[:description]) if config[:description]
output = edit_data(role)
output.save
Chef::Log.info("Created (or updated) #{output}")
json_pretty_print(output) if config[:print_after]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment