knife-opc 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3257cb3b536d35a41ec3fccb5c73162012fa9953
4
- data.tar.gz: a439aff11ffa9bde8fe771cc4d39800875c26ae0
2
+ SHA256:
3
+ metadata.gz: 21e309366d62a87b653421397ba19dbc9d2c794bf15e6afd523c22b012c465cb
4
+ data.tar.gz: 2e71da62849d8b082b194ada7ac061150ee79a0d9b07f9bf178fa72350e46718
5
5
  SHA512:
6
- metadata.gz: 3195effbdcb420a5a81d75dcbdede8345174b733e0b6a8cfe0e71cded805592b5c941a09848d4cbbf09e0429128a42702949b9ef1b25901f5184c00ac698a1c2
7
- data.tar.gz: df351c0d42dadc75f675121a6e39bb4da13a5e7abca00dd0392f2aae521300f5959549ad8d10ef69321777397050349ac164c6cf29f664d9993b4e76059dc91a
6
+ metadata.gz: 758d67e9f2dc3b87559729cddeb03a265a7803f1651fac7aacf6c63c62bb758f2aed2373861d5db2d87b52c9cfdfe389c7ee0a3b95a5e95869cba38896fc5c7e
7
+ data.tar.gz: 60553dd5d5ed676f9b94582654b832860e59956597b707d37b066ba1fda78582910a00002e4e3b1977acdad5d028f280dfb84dd6d5d395c824294a932cc39456
data/README.md CHANGED
@@ -1,175 +1,138 @@
1
- # knife OPC #
1
+ # knife OPC
2
2
 
3
- * Documentation: http://docs.opscode.com/
4
- * Tickets/Issues: http://tickets.opscode.com
5
- * IRC: [#chef](irc://irc.freenode.net/chef) and [#chef-hacking](irc://irc.freenode.net/chef-hacking) on Freenode
6
- * Mailing list: http://lists.opscode.com
3
+ [![Gem Version](https://badge.fury.io/rb/knife-opc.svg)](https://rubygems.org/gems/knife-opc) [![Build Status](https://travis-ci.org/chef/knife-opc.svg?branch=master)](https://travis-ci.org/chef/knife-opc)
7
4
 
8
- # Description
5
+ This knife plugin supports basic organization and user operations in Enterprise Chef (formerly Opscode Private Chef) and Chef Server 12.
9
6
 
10
- This knife plugin supports basic organization and user operations in
11
- Enterprise Chef (formerly Opscode Private Chef) and Chef Server 12.
7
+ - Documentation: <https://github.com/chef/knife-opc/blob/master/README.md>
8
+ - Source: <http://github.com/chef/knife-opc/tree/master>
9
+ - Issues: <https://github.com/chef/knife-opc/issues>
10
+ - Slack: <http://community-slack.chef.io/>
11
+ - Mailing list: <https://discourse.chef.io/>
12
12
 
13
- # Installation
13
+ ## Installation
14
14
 
15
- This knife plugin is packaged as a gem. To install it, run:
15
+ Using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the Gem:
16
16
 
17
- gem install knife-opc
17
+ ```bash
18
+ chef gem install knife-opc
19
+ ```
18
20
 
19
- If you are using ChefDK, run:
21
+ ## Configuration
20
22
 
21
- chef gem install knife-opc
23
+ ### knife.rb
22
24
 
23
- ## Development version
25
+ Unlike other knife subcommands the subcommands in the knife-opc plugin make API calls against the root of your OPC installations API endpoint.
24
26
 
25
- To install the latest development version:
27
+ Typically the chef_server_url for your OPC installation may look like this:
26
28
 
27
- git clone https://github.com/opscode/knife-opc.git
28
- cd knife-opc
29
- gem build knife-opc.gemspec
30
- gem install knife-opc-0.3.2.gem
29
+ ```
30
+ chef_server_url https://chef.yourdomain.com/organizations/ORGNAME
31
+ ```
31
32
 
32
- # Configuration
33
+ To configure knife-opc, set the `chef_server_root` option to the root of your OPC installation:
33
34
 
34
- ## knife.rb
35
- Unlike other knife subcommands the subcommands in the knife-opc
36
- plugin make API calls against the root of your OPC installations API
37
- endpoint.
35
+ ```
36
+ chef_server_root https://chef.yourdomain.com/
37
+ ```
38
38
 
39
- Typically the chef_server_url for your OPC installation may look like
40
- this:
39
+ Note that most users in an OPC installation lack the permissions to run most of the commands from this plugin. On Chef Server 12, the majority of the commands provided by this plugin can be accessed via `chef-server-ctl` wrapper commands that properly configure knife-opc for administrative action. We recommend you use the wrapper commands whenever possible
41
40
 
42
- chef_server_url https://chef.yourdomain.com/organizations/ORGNAME
41
+ When using knife-opc directly, many of the commands require special permissions. For instance, in order to use commands such as `knife opc org create`, you must authenticate as the 'pivotal' user.
43
42
 
44
- To configure knife-opc, set the `chef_server_root` option to the root
45
- of your OPC installation:
43
+ Note that the key for the pivotal user is in /etc/opscode on any node in your Chef Server cluster. We recommend that you only use the pivotal user from a Chef Server itself and not copy this key off the machine. In that case, you should run knife opc on the **Frontend server** as root, with a `knife.rb` in root's home directory.
46
44
 
47
- chef_server_root https://chef.yourdomain.com/
45
+ ```ruby
46
+ current_dir = File.dirname(__FILE__)
47
+ log_level :info
48
+ log_location STDOUT
49
+ node_name "pivotal"
50
+ client_key "/etc/opscode/pivotal.pem"
51
+ chef_server_root "https://chef.yourdomain.com/"
52
+ ```
48
53
 
49
- Note that most users in an OPC installation lack the permissions to
50
- run most of the commands from this plugin. On Chef Server 12, the
51
- majority of the commands provided by this plugin can be accessed via
52
- `chef-server-ctl` wrapper commands that properly configure knife-opc
53
- for administrative action. We recommend you use the wrapper commands
54
- whenever possible
54
+ ## Knife Sub Commands
55
55
 
56
- When using knife-opc directly, many of the commands require special
57
- permissions. For instance, in order to use commands such as `knife opc
58
- org create`, you must authenticate as the 'pivotal' user.
56
+ ### knife opc user list (options)
59
57
 
60
- Note that the key for the pivotal user is in /etc/opscode on any node
61
- in your Chef Server cluster. We recommend that you only use the
62
- pivotal user from a Chef Server itself and not copy this key off the
63
- machine. In that case, you should run knife opc on the **Frontend
64
- server** as root, with a `knife.rb` in root's home directory.
58
+ _Options_
65
59
 
66
- current_dir = File.dirname(__FILE__)
67
- log_level :info
68
- log_location STDOUT
69
- node_name "pivotal"
70
- client_key "/etc/opscode/pivotal.pem"
71
- chef_server_root "https://chef.yourdomain.com/"
72
-
73
- # Subcommands
74
-
75
- ## knife opc user list (options)
76
-
77
- *Options*
78
-
79
- * `-w`, `--with-uri`:
80
- Show corresponding URIs
60
+ - `-w`, `--with-uri`: Show corresponding URIs
81
61
 
82
62
  Show a list of all users in your OPC installation.
83
63
 
84
- ## knife opc user show USERNAME (options)
64
+ ### knife opc user show USERNAME (options)
85
65
 
86
- * `-l`, `--with-orgs`:
87
- Show the organizations of which the user is a member.
66
+ - `-l`, `--with-orgs`: Show the organizations of which the user is a member.
88
67
 
89
68
  Shows the details of a user in your OPC installation.
90
69
 
91
- ## knife opc user create USERNAME FIRST_NAME [MIDDLE_NAME] LAST_NAME EMAIL PASSWORD (options)
70
+ ### knife opc user create USERNAME FIRST_NAME [MIDDLE_NAME] LAST_NAME EMAIL [PASSWORD] (options)
92
71
 
93
- * `-f FILENAME`, `--filename FILENAME`:
94
- Write private key to FILENAME rather than STDOUT.
72
+ - `-f FILENAME`, `--filename FILENAME`: Write private key to FILENAME rather than STDOUT.
73
+ - `-p`, `--prompt-for-password`: Prompt for password rather than providing it on the command line.
95
74
 
96
- Creates a new user in your OPC installation. The user's private key
97
- will be returned in response. Without this key, the user will need to
98
- log into the WebUI and regenerate their key before they can use knife.
75
+ Creates a new user in your OPC installation. The user's private key will be returned in response. Without this key, the user will need to log into the WebUI and regenerate their key before they can use knife.
99
76
 
100
- ## knife opc user delete USERNAME [-d]
77
+ ### knife opc user delete USERNAME [-d]
101
78
 
102
79
  Deletes the given OPC user.
103
80
 
104
- ## knife opc user edit USERNAME
81
+ ### knife opc user edit USERNAME
105
82
 
106
83
  Will open $EDITOR. When finished, Knife will update the given OPC user.
107
84
 
108
- ## knife opc user password USERNAME [PASSWORD | --enable_external_auth]
85
+ ### knife opc user password USERNAME [PASSWORD | --enable_external_auth]
109
86
 
110
87
  Command for managing password and authentication for a user.
111
88
 
112
89
  The last argument should either be a string you want the password to or you can pass --enable_external_auth instead of a password to enable external authentication for this user.
113
90
 
114
- ## knife opc org list
91
+ ### knife opc org list
115
92
 
116
- * `-w`, `--with-uri`:
117
- Show corresponding URIs
118
-
119
- * `-a`, `--all-orgs`:
120
- Display hidden orgs
93
+ - `-w`, `--with-uri`: Show corresponding URIs
94
+ - `-a`, `--all-orgs`: Display hidden orgs
121
95
 
122
96
  Show a list of all organizations in your OPC installation.
123
97
 
124
- ## knife opc org show ORG_NAME
98
+ ### knife opc org show ORG_NAME
125
99
 
126
100
  Shows description of given ORG_NAME.
127
101
 
128
- ## knife opc org create ORG_NAME ORG_FULL_NAME
129
-
130
- * `-f FILENAME`, `--filename FILENAME`:
131
- Write private key to FILENAME rather than STDOUT.
102
+ ### knife opc org create ORG_NAME ORG_FULL_NAME
132
103
 
133
- * `-a USERNAME`, `--association_user USERNAME`,
134
- Associate USERNAME with the organization after creation.
104
+ - `-f FILENAME`, `--filename FILENAME`: Write private key to FILENAME rather than STDOUT.
105
+ - `-a USERNAME`, `--association_user USERNAME`, Associate USERNAME with the organization after creation.
135
106
 
136
- Creates a new OPC Organization. The private key for the organization's
137
- validator client is returned.
107
+ Creates a new OPC Organization. The private key for the organization's validator client is returned.
138
108
 
139
- ## knife opc org delete ORG_NAME
109
+ ### knife opc org delete ORG_NAME
140
110
 
141
111
  Deletes the given OPC organization.
142
112
 
143
- ## knife opc org user add ORGNAME USERNAME
113
+ ### knife opc org user add ORGNAME USERNAME
114
+
115
+ Adds a user to an organization. Requires that the named organization and user both exist.
144
116
 
145
- Adds a user to an organization. Requires that the named organization
146
- and user both exist.
117
+ ### knife opc org user remove ORGNAME USERNAME
147
118
 
148
- ## knife opc org user remove ORGNAME USERNAME
119
+ Removes a user from an organization. Requires that the named organization and user both exist, and that the user is currently associated with the organization.
149
120
 
150
- Removes a user from an organization. Requires that the named
151
- organization and user both exist, and that the user is currently
152
- associated with the organization.
121
+ ## KNOWN ISSUES
153
122
 
154
- # KNOWN ISSUES
123
+ - Attempting to delete and immediately recreate an organization will result in an error (a 500 or a 409 Conflict depending on the server version). This is because of a server-side cache that must be cleared. Restarting the frontend services before recreating the org is necessary to avoid the error.
155
124
 
156
- * Attempting to delete and immediately recreate an organization will
157
- result in an error (a 500 or a 409 Conflict depending on the server
158
- version). This is because of a server-side cache that must be
159
- cleared. Restarting the frontend services before recreating the org
160
- is necessary to avoid the error.
125
+ ## Contributing
161
126
 
162
- # TODO
127
+ For information on contributing to this project see <https://github.com/chef/chef/blob/master/CONTRIBUTING.md>
163
128
 
164
- * `--with-users` option for `org show` subcommand.
129
+ ## License
165
130
 
166
- ## License ##
131
+ Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
167
132
 
168
- | | |
169
- |:---------------------|:-----------------------------------------|
170
- | **Copyright:** | Copyright (c) 2011-2014 Opscode, Inc.
171
- | **License:** | Apache License, Version 2.0
133
+ License:: Apache License, Version 2.0
172
134
 
135
+ ```text
173
136
  Licensed under the Apache License, Version 2.0 (the "License");
174
137
  you may not use this file except in compliance with the License.
175
138
  You may obtain a copy of the License at
@@ -181,3 +144,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
181
144
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
182
145
  See the License for the specific language governing permissions and
183
146
  limitations under the License.
147
+ ```
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Steven Danna (<steve@opscode.com>)
3
- # Copyright:: Copyright 2011 Opscode, Inc.
2
+ # Author:: Steven Danna (<steve@chef.io>)
3
+ # Copyright:: Copyright 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,20 +22,20 @@ module Opc
22
22
  banner "knife opc org create ORG_SHORT_NAME ORG_FULL_NAME (options)"
23
23
 
24
24
  option :filename,
25
- :long => '--filename FILENAME',
26
- :short => '-f FILENAME',
27
- :description => 'Write validator private key to FILENAME rather than STDOUT'
25
+ :long => "--filename FILENAME",
26
+ :short => "-f FILENAME",
27
+ :description => "Write validator private key to FILENAME rather than STDOUT"
28
28
 
29
29
  option :association_user,
30
- :long => '--association_user USERNAME',
31
- :short => '-a USERNAME',
32
- :description => 'Invite USERNAME to the new organization after creation'
30
+ :long => "--association_user USERNAME",
31
+ :short => "-a USERNAME",
32
+ :description => "Invite USERNAME to the new organization after creation"
33
33
 
34
34
  attr_accessor :org_name, :org_full_name
35
35
 
36
36
  deps do
37
- require 'chef/org'
38
- require 'chef/org/group_operations'
37
+ require "chef/org"
38
+ require "chef/org/group_operations"
39
39
  end
40
40
 
41
41
  def run
@@ -47,8 +47,8 @@ module Opc
47
47
  exit 1
48
48
  end
49
49
 
50
- org = Chef::Org.from_hash({ 'name' => org_name,
51
- 'full_name' => org_full_name}).create
50
+ org = Chef::Org.from_hash({ "name" => org_name,
51
+ "full_name" => org_full_name }).create
52
52
  if config[:filename]
53
53
  File.open(config[:filename], "w") do |f|
54
54
  f.print(org.private_key)
@@ -59,8 +59,8 @@ module Opc
59
59
 
60
60
  if config[:association_user]
61
61
  org.associate_user(config[:association_user])
62
- org.add_user_to_group('admins', config[:association_user])
63
- org.add_user_to_group('billing-admins', config[:association_user])
62
+ org.add_user_to_group("admins", config[:association_user])
63
+ org.add_user_to_group("billing-admins", config[:association_user])
64
64
  end
65
65
  end
66
66
  end
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Steven Danna (<steve@opscode.com>)
3
- # Copyright:: Copyright 2011 Opscode, Inc.
2
+ # Author:: Steven Danna (<steve@chef.io>)
3
+ # Copyright:: Copyright 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- require 'chef/mixin/root_rest'
18
+ require "chef/mixin/root_rest"
19
19
 
20
20
  module Opc
21
21
  class OpcOrgDelete < Chef::Knife
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Steven Danna (<steve@opscode.com>)
3
- # Copyright:: Copyright 2011 Opscode, Inc.
2
+ # Author:: Steven Danna (<steve@chef.io>)
3
+ # Copyright:: Copyright 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- require 'chef/mixin/root_rest'
18
+ require "chef/mixin/root_rest"
19
19
 
20
20
  module Opc
21
21
  class OpcOrgEdit < Chef::Knife
@@ -33,7 +33,7 @@ module Opc
33
33
 
34
34
  include Chef::Mixin::RootRestv0
35
35
 
36
- original_org = root_rest.get("organizations/#{org_name}")
36
+ original_org = root_rest.get("organizations/#{org_name}")
37
37
  edited_org = edit_data(original_org)
38
38
 
39
39
  if original_org == edited_org
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Steven Danna (<steve@opscode.com>)
3
- # Copyright:: Copyright 2011 Opscode, Inc.
2
+ # Author:: Steven Danna (<steve@chef.io>)
3
+ # Copyright:: Copyright 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- require 'chef/mixin/root_rest'
18
+ require "chef/mixin/root_rest"
19
19
 
20
20
  module Opc
21
21
  class OpcOrgList < Chef::Knife
@@ -35,9 +35,9 @@ module Opc
35
35
  include Chef::Mixin::RootRestv0
36
36
 
37
37
  def run
38
- results = root_rest.get("organizations")
38
+ results = root_rest.get("organizations")
39
39
  unless config[:all_orgs]
40
- results = results.select { |k,v| !(k.length == 20 && k =~ /^[a-z]+$/) }
40
+ results = results.select { |k, v| !(k.length == 20 && k =~ /^[a-z]+$/) }
41
41
  end
42
42
  ui.output(ui.format_list_for_display(results))
43
43
  end
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Steven Danna (<steve@opscode.com>)
3
- # Copyright:: Copyright 2011 Opscode, Inc.
2
+ # Author:: Steven Danna (<steve@chef.io>)
3
+ # Copyright:: Copyright 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- require 'chef/mixin/root_rest'
18
+ require "chef/mixin/root_rest"
19
19
 
20
20
  module Opc
21
21
  class OpcOrgShow < Chef::Knife
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Marc Paradise (<marc@getchef.com>)
3
- # Copyright:: Copyright 2014 Chef Software, Inc
2
+ # Author:: Marc Paradise (<marc@chef.io>)
3
+ # Copyright:: Copyright 2014-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,13 +23,13 @@ module Opc
23
23
  attr_accessor :org_name, :username
24
24
 
25
25
  option :admin,
26
- :long => '--admin',
27
- :short => '-a',
28
- :description => 'Add user to admin group'
26
+ :long => "--admin",
27
+ :short => "-a",
28
+ :description => "Add user to admin group"
29
29
 
30
30
  deps do
31
- require 'chef/org'
32
- require 'chef/org/group_operations'
31
+ require "chef/org"
32
+ require "chef/org/group_operations"
33
33
  end
34
34
 
35
35
  def run
@@ -52,8 +52,9 @@ module Opc
52
52
  end
53
53
  end
54
54
  if config[:admin]
55
- org.add_user_to_group('admins', @username)
56
- org.add_user_to_group('billing-admins', @username)
55
+ org.add_user_to_group("admins", @username)
56
+ org.add_user_to_group("billing-admins", @username)
57
+ ui.msg "User #{username} is added to admins and billing-admins group"
57
58
  end
58
59
  end
59
60
  end