chef_fixie 0.3.0 → 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: a2d39d757f223a6cf8f364906e91d8051ce19a61
4
- data.tar.gz: 8cbc7287d4ec7ac58e9a800fd1dd76b23b674d10
2
+ SHA256:
3
+ metadata.gz: a42c53078d0d4728a6a2efa5e157d8aefee5d0672c530d61b2b50bc0694def17
4
+ data.tar.gz: cefac5cee97b8813b48237c4711a0aeab6f2975bd01e359d8c8151a54b5206c3
5
5
  SHA512:
6
- metadata.gz: 6970a5ff33b2a6448b57584e5641a99c55837803a67d209b6246bbbe344466f51f445884f1c596f06429e30e27312c8755a93721b471b56043fc99c987b3545d
7
- data.tar.gz: f1c93aba31fa3afc3cb3ba952539a052260a6a890b176bc45d0609aaa471182e74f4011b14a3e104b5def87a40c21562bf5a5eb6d777d3e016ef1835e13cdd6d
6
+ metadata.gz: e6153d4cb98e6f62ac9148d6ba373edd770fa4e19253f41d4da25777f53a68a5f8b2424d0d3a531bf7cef0d1f568bbfca24ea7560af4fb8588c295bb1b63f342
7
+ data.tar.gz: 2d14e3079d2142adfdf6b61c414ca195f3a05c7fa9fd847995bce4962c78f37f32d6c28a2eff17a54abdb0f8e670e5982a85cf81df81f913dff85e3f98aa6305
@@ -9,12 +9,23 @@ points
9
9
 
10
10
  First of all, run the automated org association checker:
11
11
 
12
- fixie:0 > Fixie::CheckOrgAssociations.check_associations("acme")
13
- Org acme is ok (6 users)
12
+ fixie:0 > Fixie::CheckOrgAssociations.check_associations("acme")
13
+ Org acme is ok (6 users)
14
14
 
15
15
  If it reports a problem with a user, you may be able to fix it
16
16
  automatically:
17
17
 
18
- fixie:0 > Fixie::CheckOrgAssociations.fix_association("acme", "mary")
18
+ fixie:0 > Fixie::CheckOrgAssociations.fix_association("acme", "mary")
19
19
 
20
20
  This might need to be run multiple times to fix all of the errors.
21
+
22
+
23
+ Removing a user completely from an org
24
+ -----------
25
+
26
+ [1] fixie(main)> ChefFixie::CheckOrgAssociations.remove_association('the_org', 'the_user')
27
+
28
+ This removes the user from the org, and removes them from all org
29
+ groups. However, if the user has been individually added to an ACL we
30
+ don't fix that up; it would require enumeration of the whole org, and
31
+ that hasn't been implemented.
@@ -57,6 +57,13 @@ module ChefFixie
57
57
  end
58
58
  end
59
59
 
60
+ def usag_for_user(org, user)
61
+ user = make_user(user)
62
+ org = make_org(org)
63
+ org.groups[user.id]
64
+
65
+ end
66
+
60
67
  def self.check_association(org, user, global_admins = nil)
61
68
  # magic to make usage easier
62
69
  org = make_org(org)
@@ -201,41 +208,31 @@ module ChefFixie
201
208
  end
202
209
  return true
203
210
  end
204
-
205
-
206
- ## TODO: Port this
211
+
207
212
  def self.remove_association(org, user)
208
213
  # magic to make usage easier
209
- org = orgs[org] if org.is_a?(String)
210
- user = users[user] if user.is_a?(String)
211
-
214
+ org = make_org(org)
215
+ user = make_user(user)
216
+
212
217
  # remove USAG
213
- delete_usag_for_user(orgname,username)
218
+ usag = org.groups[user.id]
219
+ usag.delete if usag
214
220
 
221
+ # remove from any groups they are in
222
+ org.groups.all(:all).each do |g|
223
+ g.group_delete(user) if g.member?(user)
224
+ end
225
+
215
226
  # remove read ACE
216
- u_aid = user.authz_id
217
- ga = OrgMapper::CouchSupport.doc_from_view("#{orgname}_global_admins", "#{Group}/by_groupname")
218
- ga_aid = user_to_authz(ga["_id"])
219
-
220
- read_ace = OrgMapper::RawAuth.get("actors/#{u_aid}/acl/read")
221
- read_ace["groups"] -= [ga_aid]
222
- OrgMapper::RawAuth.put("actors/#{u_aid}/acl/read", read_ace)
227
+ user.ace_delete(:read, org.global_admins)
223
228
 
224
229
  # remove association record
230
+ assoc = assocs.by_org_id_user_id(org.id,user.id)
231
+ assoc.delete if assoc
225
232
 
226
- org_assoc = OrgMapper::CouchSupport.associations_for_org(orgname)
227
- doc = org_assoc.select {|x| x[:uid] == user.id}.first
228
-
229
- OrgMapper::CouchSupport.delete_account_doc(doc[:id])
230
-
231
- # clean up excess invites
232
- invites = OrgMapper::CouchSupport.invites_for_org(orgname)
233
- invite_map = invites.inject({}) {|a,e| a[e[:name]] = e; a}
234
-
235
- if invite_map.has_key?(username)
236
- invite = invite_map[username]
237
- OrgMapper::CouchSupport.delete_account_doc(invite[:id])
238
- end
233
+ # remove any invites
234
+ invite = invites.by_org_id_user_id(org.id,user.id)
235
+ invite.delete if invite
239
236
  end
240
237
  end
241
238
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2014-2015 Chef Software Inc.
2
+ # Copyright (c) 2014-2015 Chef Software Inc.
3
3
  # License :: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
21
21
  require 'singleton'
22
22
  require 'ffi_yajl'
23
23
  require 'pathname'
24
+ require 'veil'
24
25
 
25
26
  module ChefFixie
26
27
  def self.configure
@@ -29,11 +30,11 @@ module ChefFixie
29
30
 
30
31
  def self.load_config(config_file = nil)
31
32
  if config_file
32
- puts "loading config: #{config_file}..."
33
+ puts "loading config: #{config_file}..." if ChefFixie::Console.started_from_command_line?
33
34
  Kernel.load(config_file)
34
35
  else
35
36
  path = "/etc/opscode"
36
- puts "loading config from #{path}"
37
+ puts "loading config from #{path}" if ChefFixie::Console.started_from_command_line?
37
38
  ChefFixie::Config.instance.load_from_pc(path)
38
39
  end
39
40
  end
@@ -104,23 +105,25 @@ module ChefFixie
104
105
  config_files = %w(chef-server-running.json)
105
106
  config = load_json_from_path([configdir], config_files)
106
107
 
108
+ secrets = load_secrets_from_path([configdir], %w(private-chef-secrets.json) )
109
+
107
110
  authz_config = config['private_chef']['oc_bifrost']
108
111
  authz_vip = authz_config['vip']
109
112
  authz_port = authz_config['port']
110
113
  @authz_uri = "http://#{authz_vip}:#{authz_port}"
111
-
112
- @superuser_id = authz_config['superuser_id']
114
+
115
+ @superuser_id = dig(secrets,['oc_bifrost','superuser_id']) || authz_config['superuser_id']
113
116
 
114
117
  sql_config = config['private_chef']['postgresql']
115
118
  erchef_config = config['private_chef']['opscode-erchef']
116
-
119
+
117
120
  sql_user = sql_config['sql_user'] || erchef_config['sql_user']
118
- sql_pw = sql_config['sql_password'] || erchef_config['sql_password']
121
+ sql_pw = dig(secrets, ['opscode_erchef', 'sql_password']) || sql_config['sql_password'] || erchef_config['sql_password']
119
122
  sql_vip = sql_config['vip']
120
123
  sql_port = sql_config['port']
121
-
124
+
122
125
  @sql_database = "postgres://#{sql_user}:#{sql_pw}@#{sql_vip}/opscode_chef"
123
-
126
+
124
127
  @pivotal_key = configdir + "pivotal.pem"
125
128
  end
126
129
 
@@ -136,5 +139,35 @@ module ChefFixie
136
139
  end
137
140
  end
138
141
  end
142
+ def load_secrets_from_path(pathlist, filelist)
143
+ pathlist.each do |path|
144
+ filelist.each do |file|
145
+ configfile = path + file
146
+ if configfile.file?
147
+ data = Veil::CredentialCollection::ChefSecretsFile.from_file(configfile)
148
+ return data
149
+ end
150
+ end
151
+ end
152
+ nil
153
+ end
154
+
155
+ def dig(hash, list)
156
+ if hash.respond_to?(:get)
157
+ hash.get(*list)
158
+ elsif hash.nil?
159
+ nil?
160
+ elsif list.empty?
161
+ hash
162
+ else
163
+ element = list.shift
164
+ if hash.has_key?(element)
165
+ dig(hash[element], list)
166
+ else
167
+ nil
168
+ end
169
+ end
170
+ end
171
+
139
172
  end
140
173
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright (c) 2015 Chef Software Inc.
2
+ # Copyright (c) 2015 Chef Software Inc.
3
3
  # License :: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -30,6 +30,7 @@ module ChefFixie
30
30
  extend self
31
31
 
32
32
  def start
33
+ @@started_from_command_line = true
33
34
  configure
34
35
  ChefFixie.setup
35
36
  configure_pry
@@ -87,5 +88,9 @@ HALP
87
88
  end
88
89
  end
89
90
 
91
+ def started_from_command_line?
92
+ @@started_from_command_line == true
93
+ end
94
+
90
95
  end
91
96
  end
@@ -145,9 +145,13 @@ module ChefFixie
145
145
  def global_admins
146
146
  name = self.name
147
147
  global_admins_name = "#{name}_global_admins"
148
- ChefFixie::Sql::Groups.new["#{name}_global_admins"]
148
+ read_access_name = "#{name}_read_access_group"
149
+ ChefFixie::Sql::Groups.new[global_admins_name] || \
150
+ ChefFixie::Sql::Groups.new[read_access_name]
149
151
  end
150
152
 
153
+ alias read_access_group global_admins
154
+
151
155
  # Iterators for objects in authz; using containers to enumerate things
152
156
  # It might be better to metaprogram this up instead,
153
157
  #
@@ -1,3 +1,3 @@
1
1
  module ChefFixie
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef_fixie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-24 00:00:00.000000000 Z
11
+ date: 2018-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -106,6 +106,20 @@ dependencies:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: 2.1.3
109
+ - !ruby/object:Gem::Dependency
110
+ name: veil
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :runtime
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
109
123
  - !ruby/object:Gem::Dependency
110
124
  name: bundler
111
125
  requirement: !ruby/object:Gem::Requirement
@@ -158,42 +172,11 @@ extra_rdoc_files: []
158
172
  files:
159
173
  - LICENSE
160
174
  - README.md
161
- - bin/bundler
162
- - bin/chef-apply
163
- - bin/chef-client
164
- - bin/chef-shell
165
- - bin/chef-solo
166
- - bin/chef-zero
167
175
  - bin/chef_fixie
168
- - bin/coderay
169
- - bin/edit_json.rb
170
- - bin/erubis
171
- - bin/ffi-yajl-bench
172
- - bin/fixie~
173
- - bin/htmldiff
174
- - bin/knife
175
- - bin/ldiff
176
- - bin/net-dhcp
177
- - bin/ohai
178
- - bin/prettify_json.rb
179
- - bin/pry
180
- - bin/rackup
181
- - bin/rake
182
- - bin/rdoc
183
- - bin/restclient
184
- - bin/ri
185
- - bin/rspec
186
- - bin/s3sh
187
- - bin/sequel
188
- - bin/serverspec-init
189
176
  - doc/AccessingSQL.md
190
- - doc/AccessingSQL.md~
191
177
  - doc/BulkFixup.md
192
- - doc/BulkFixup.md~
193
178
  - doc/CommonTasks.md
194
- - doc/CommonTasks.md~
195
179
  - doc/GETTING_STARTED.md
196
- - doc/GETTING_STARTED.md~
197
180
  - fixie.conf.example
198
181
  - lib/chef_fixie.rb
199
182
  - lib/chef_fixie/authz_mapper.rb
@@ -209,12 +192,9 @@ files:
209
192
  - lib/chef_fixie/version.rb
210
193
  - spec/chef_fixie/acl_spec.rb
211
194
  - spec/chef_fixie/assoc_invite_spec.rb
212
- - spec/chef_fixie/assoc_invite_spec.rb~
213
195
  - spec/chef_fixie/check_org_associations_spec.rb
214
- - spec/chef_fixie/check_org_associations_spec.rb~
215
196
  - spec/chef_fixie/groups_spec.rb
216
197
  - spec/chef_fixie/org_spec.rb
217
- - spec/chef_fixie/org_spec.rb~
218
198
  - spec/chef_fixie/orgs_spec.rb
219
199
  - spec/spec_helper.rb
220
200
  homepage: https://github.com/chef/fixie
@@ -237,18 +217,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
217
  version: '0'
238
218
  requirements: []
239
219
  rubyforge_project:
240
- rubygems_version: 2.2.2
220
+ rubygems_version: 2.7.6
241
221
  signing_key:
242
222
  specification_version: 4
243
223
  summary: Low level manipulation tool for Chef Server 12 and later
244
224
  test_files:
245
225
  - spec/chef_fixie/acl_spec.rb
246
226
  - spec/chef_fixie/assoc_invite_spec.rb
247
- - spec/chef_fixie/assoc_invite_spec.rb~
248
227
  - spec/chef_fixie/check_org_associations_spec.rb
249
- - spec/chef_fixie/check_org_associations_spec.rb~
250
228
  - spec/chef_fixie/groups_spec.rb
251
229
  - spec/chef_fixie/org_spec.rb
252
- - spec/chef_fixie/org_spec.rb~
253
230
  - spec/chef_fixie/orgs_spec.rb
254
231
  - spec/spec_helper.rb
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'bundler' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('bundler', 'bundler')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'chef-apply' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('chef', 'chef-apply')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'chef-client' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('chef', 'chef-client')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'chef-shell' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('chef', 'chef-shell')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'chef-solo' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('chef', 'chef-solo')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'chef-zero' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('chef-zero', 'chef-zero')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'coderay' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('coderay', 'coderay')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'edit_json.rb' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('json', 'edit_json.rb')
data/bin/erubis DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'erubis' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('erubis', 'erubis')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ffi-yajl-bench' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('ffi-yajl', 'ffi-yajl-bench')
data/bin/fixie~ DELETED
@@ -1,231 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "rubygems"
4
- require "bundler/setup"
5
-
6
- $:.unshift(File.dirname(__FILE__) + '/../lib/')
7
-
8
- require 'optparse'
9
- require 'irb'
10
- require 'irb/init'
11
- require 'irb/completion'
12
- require 'irb/ext/history'
13
- require 'pp'
14
- require 'pry'
15
-
16
- require 'fixie/config'
17
-
18
- require 'fixie'
19
-
20
- # IRB tries to overwrite our custom settings when it loads, so we have to hax0r
21
- # it to work.
22
- module IRB
23
- class << self
24
- alias :run_original_config :run_config
25
-
26
- def run_config
27
- run_original_config
28
- ::Fixie::Console.configure_irb
29
- end
30
- end
31
- end
32
-
33
-
34
- module Fixie
35
-
36
- module Context
37
-
38
- def describe_orgs
39
- OrgMetrics.org_stats(orgs)
40
- end
41
-
42
- def orgs
43
- Fixie::Organizations.new
44
- end
45
-
46
- def jobs
47
- Fixie::Jobs.new
48
- end
49
-
50
- def users
51
- Fixie::Users.new
52
- end
53
-
54
- def global_groups
55
- Fixie::GlobalGroups.new
56
- end
57
-
58
- def help
59
- puts(<<-HALP)
60
- ** ORGS **
61
- * access with ORGS or ORGS
62
- * access a specific org: ORGS['orgname']
63
-
64
- ** USERS **
65
- * users.find('clownco-org-admin')
66
- * users.grep :clownco
67
- * users.usernames
68
-
69
- ** RAW SQL ACCESS**
70
- * sql[:users].select(:column, :column).where(:column => "condition").all
71
-
72
- ** irb Help **
73
- irb_help
74
-
75
- HALP
76
- :COOL_STORY_BRO
77
- end
78
-
79
- def sql
80
- Opscode::Mappers.default_connection
81
- end
82
-
83
- def associate_user(username, orgname)
84
- unless user = users.find(username)
85
- raise ArgumentError, "No users matched '#{username}'"
86
- end
87
- unless org = ORGS[orgname]
88
- raise ArgumentError, "No orgs matched '#{orgname}'"
89
- end
90
-
91
- Fixie::Associator.associate_user(org, user)
92
- end
93
-
94
- def dissociate_user(username, orgname)
95
- unless user = users.find(username)
96
- raise ArgumentError, "No users matched '#{username}'"
97
- end
98
- unless org = ORGS[orgname]
99
- raise ArgumentError, "No orgs matched '#{orgname}'"
100
- end
101
-
102
- Fixie::Dissociator.dissociate_user(org, user)
103
- end
104
-
105
- end
106
-
107
- module Console
108
- extend self
109
-
110
- def irb_conf
111
- IRB.conf
112
- end
113
-
114
- def start
115
- # FUGLY HACK: irb gives us no other choice.
116
- irb_help = [:help, :irb_help, IRB::ExtendCommandBundle::NO_OVERRIDE]
117
- IRB::ExtendCommandBundle.instance_variable_get(:@ALIASES).delete(irb_help)
118
-
119
- # This has to come before IRB.setup b/c IRB.setup eats ARGV.
120
- configure
121
-
122
- # HACK: this duplicates the functions of IRB.start, but we have to do it
123
- # to get access to the main object before irb starts.
124
- ::IRB.setup(nil)
125
-
126
- irb = IRB::Irb.new
127
-
128
- setup(irb.context.main)
129
-
130
-
131
- irb_conf[:IRB_RC].call(irb.context) if irb_conf[:IRB_RC]
132
- irb_conf[:MAIN_CONTEXT] = irb.context
133
-
134
- trap("SIGINT") do
135
- irb.signal_handle
136
- end
137
-
138
- catch(:IRB_EXIT) do
139
- irb.eval_input
140
- end
141
- end
142
-
143
- def configure
144
-
145
- if ARGV.first && ARGV[0].chars.first != "-" && config_file = ARGV.shift
146
- config_file = File.expand_path(config_file)
147
-
148
- load_config_file = true
149
- end
150
-
151
- options = {}
152
- OptionParser.new do |opt|
153
- opt.banner = "Usage: orgmapper [config] [options]"
154
- opt.on('--couchdb-uri COUCH_URI', 'The URI of the couchdb server to connect to') { |v| options[:couchdb_uri] = v }
155
- opt.on("--database ACCOUNT_DATABASE", 'The name of the opscode account database') { |v| options[:database] = v }
156
- opt.on('--auth-uri AUTH_URI', "The URI of the opscode authz service") { |v| options[:auth_uri] =v }
157
- opt.on_tail('-h', '--help', 'Show this message') do
158
- puts opt
159
- puts "\nExample configuration file:\n\n"
160
- puts Fixie::Config.instance.example_config
161
- puts "\n"
162
- exit(1)
163
- end
164
- opt.parse!(ARGV)
165
- end
166
- pp :cli_opts => options if ENV["DEBUG"]
167
-
168
- if load_config_file
169
- puts "loading config: #{config_file}..."
170
- Kernel.load(config_file)
171
- end
172
-
173
- Fixie::Config.instance.merge_opts(options)
174
- puts Fixie::Config.instance.to_text
175
- end
176
-
177
- def setup(context)
178
- Object.send(:include, Mixlib::Authorization::AuthHelper)
179
- Object.const_set(:PLATFORM_BACKEND, Fixie::Backend.new(*Config.instance.to_ary))
180
- Object.const_set(:ORGS, Fixie::Organizations.new)
181
- Object.const_set(:JOBS, Fixie::Jobs.new)
182
- Object.const_set(:USERS, Fixie::Users.new)
183
- Object.const_set(:GLOBAL_GROUPS, Fixie::GlobalGroups.new)
184
-
185
- context.extend(Context)
186
-
187
- end
188
-
189
- # Configure IRB how we like it. This needs to be hooked into IRB.run_config
190
- Object.send(:include, Mixlib::Authorization::AuthHelper)
191
- Object.const_set(:PLATFORM_BACKEND, Fixie::Backend.new(*Config.instance.to_ary))
192
- Object.const_set(:ORGS, Fixie::Organizations.new)
193
- Object.const_set(:JOBS, Fixie::Jobs.new)
194
- Object.const_set(:USERS, Fixie::Users.new)
195
- Object.const_set(:GLOBAL_GROUPS, Fixie::GlobalGroups.new)
196
-
197
- context.extend(Context)
198
-
199
- end
200
-
201
- # Configure IRB how we like it. This needs to be hooked into IRB.run_config
202
- # because much of IRB's code is anachronistic
203
- def configure_irb
204
- IRB.init_config(__FILE__)
205
-
206
- IRB.conf[:HISTORY_FILE] = "~/.orgmapper_history"
207
- IRB.conf[:SAVE_HISTORY]=1000
208
- IRB.conf[:USE_READLINE]=true
209
- IRB.conf[:PROMPT][:ORGMAPPER] = { # name of prompt mode
210
- :PROMPT_I => "orgmapper:%i > ", # normal prompt
211
- :PROMPT_S => "..%l ", # prompt for continuing strings
212
- :PROMPT_C => "... ", # prompt for continuing statement
213
- :RETURN => "%s\n" # format to return value
214
- }
215
-
216
- IRB.conf[:PROMPT_MODE] = :ORGMAPPER
217
-
218
- begin
219
- require 'wirble'
220
- Wirble.init
221
- Wirble.colorize
222
- rescue LoadError
223
- end
224
-
225
- end
226
-
227
- end
228
- end
229
-
230
- Fixie::Console.start
231
-
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'htmldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/knife DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'knife' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('chef', 'knife')
data/bin/ldiff DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ldiff' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('diff-lcs', 'ldiff')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'net-dhcp' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('net-dhcp', 'net-dhcp')
data/bin/ohai DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ohai' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('ohai', 'ohai')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'prettify_json.rb' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('json', 'prettify_json.rb')
data/bin/pry DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'pry' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('pry', 'pry')
data/bin/rackup DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rackup' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rack', 'rackup')
data/bin/rake DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rake' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rake', 'rake')
data/bin/rdoc DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rdoc' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rdoc', 'rdoc')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'restclient' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rest-client', 'restclient')
data/bin/ri DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'ri' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rdoc', 'ri')
data/bin/rspec DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rspec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('rspec-core', 'rspec')
data/bin/s3sh DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 's3sh' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('aws-s3', 's3sh')
data/bin/sequel DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'sequel' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('sequel', 'sequel')
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'serverspec-init' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('serverspec', 'serverspec-init')
@@ -1,32 +0,0 @@
1
-
2
- Basics:
3
- -------
4
-
5
- Underneath everything is the Ruby Sequel library; there are a number
6
- of ways to access it.
7
-
8
-
9
-
10
- fixie:0 > o.groups.by_name(cl.id).inner.count
11
- 1
12
- fixie:0 > o.groups.by_name(cl.id).inner.delete
13
- 1
14
- fixie:0 > o.groups.by_name(cl.id).inner.count
15
-
16
-
17
- * Changing email for user in fixie
18
-
19
- USERS.by_username('anujbiyani').inner.update(:email=>"anujbiyani01@gmail.com")
20
-
21
-
22
-
23
- * Adding a record
24
- ```ruby
25
- u=USERS['a_username']
26
- o=ORGS['an_org']
27
-
28
- pivotal = USERS['pivotal']
29
-
30
- ASSOCS.inner.insert(:org_id=>o.id, :user_id=>u.id, :last_updated_by=>pivotal.authz_id,
31
- :created_at=>:NOW.sql_function, :updated_at=>:NOW.sql_function) )
32
- ```
@@ -1,28 +0,0 @@
1
- Restoring acl permissions globally
2
- ============
3
-
4
-
5
-
6
-
7
- * If a key group is deleted (such as users)
8
-
9
- Create/restore the group
10
-
11
- Add the users/groups back to the group
12
-
13
- Set the group ACL appropriately
14
-
15
- Restore users to the appropriate container ACLs
16
- ```ruby
17
- o = ORGS[THE_ORG]
18
- cl = %w(cookbooks data nodes roles environments policies policy_groups cookbook_artifacts)
19
- cl.each {|c| o.containers[c].ace_add([:create,:read,:update,:delete], o.groups['users']) }
20
- %w(clients).each { |c| o.containers[c].ace_add([:read,:delete], o.groups['users']) }
21
- %w(groups containers).each { |c| o.containers[c].ace_add([:read], o.groups['users']) }
22
- %w(sandboxes).each { |c| o.containers[c].ace_add([:create], o.groups['users']) }
23
- ```
24
-
25
- Then update the objects from the containers:
26
- ```ruby
27
- Fixie::BulkEditPermissions::copy_from_containers(o)
28
- ```
File without changes
@@ -1,6 +0,0 @@
1
-
2
- Installing fixie
3
- -------
4
-
5
- Configuring fixie
6
- -------
@@ -1,26 +0,0 @@
1
-
2
- require 'rspec'
3
- require "spec_helper"
4
- require 'fixie'
5
- require 'fixie/config'
6
-
7
- RSpec.describe Fixie::Sql::Orgs, "Organizations access" do
8
- let (:test_org_name) { "ponyville" }
9
- let (:orgs) { Fixie::Sql::Orgs.new }
10
- let (:test_org) { orgs[test_org_name]}
11
-
12
- context "Basic functionality of org accessor" do
13
-
14
- it "Org has a name and id" do
15
- expect(test_org.name).to eq(test_org_name)
16
- expect(test_org.id).not_to be_nil
17
- end
18
-
19
- it "Org has a global admins group" do
20
- expect(test_org.global_admins.name).to eq(test_org_name + "_global_admins")
21
- end
22
-
23
- end
24
-
25
-
26
- end
@@ -1,34 +0,0 @@
1
-
2
- require 'rspec'
3
- require "spec_helper"
4
- require 'fixie'
5
- require 'fixie/config'
6
-
7
- RSpec.describe Fixie::Sql::Groups, "Group access" do
8
- let (:test_org_name) { "ponyville"}
9
- let (:orgs) { Fixie::Sql::Orgs.new }
10
- let (:users) { Fixie::Sql::Users.new }
11
- let (:test_org) { orgs[test_org_name] }
12
-
13
- # TODO this should use a freshly created object and purge it afterwords.
14
- # But we need to write the create object feature still
15
-
16
- context "Groups" do
17
- let (:testgroup) { test_org.groups['admins'] }
18
- let (:adminuser) { users['rainbowdash'] }
19
- let (:notadminuser) { users['mary'] }
20
-
21
- it "Members are part of the group" do
22
- expect(testgroup.member?(adminuser)).to be true
23
- end
24
- it "Members are not part of the group" do
25
- expect(testgroup.member?(notadminuser)).to be false
26
- end
27
-
28
-
29
- end
30
-
31
-
32
-
33
-
34
- end
@@ -1,53 +0,0 @@
1
-
2
- require 'rspec'
3
- require "spec_helper"
4
- require 'fixie'
5
- require 'fixie/config'
6
-
7
- RSpec.describe Fixie::Sql::Orgs, "Organizations access" do
8
- let (:test_org) { "ponyville"}
9
-
10
- context "Basic access to orgs" do
11
- let (:orgs) { Fixie::Sql::Orgs.new }
12
- it "We find more than one org" do
13
- expect(orgs.inner.count).to be > 0
14
- end
15
-
16
- it "We can list orgs" do
17
- # array matcher requires a splat. (I didn't know this )
18
- expect(orgs.list).to include( * %w(acme ponyville wonderbolts) )
19
- end
20
- it "We can list orgs with a limit" do
21
- # array matcher requires a splat. (I didn't know this )
22
- expect(orgs.list(1)).to eq(:too_many_results)
23
- end
24
-
25
- it "We can find an org" do
26
- expect(orgs[test_org].name).to eq(test_org)
27
- end
28
-
29
- end
30
-
31
- context "Search accessors work correctly" do
32
- let (:orgs) { Fixie::Sql::Orgs.new }
33
- let (:the_org) { orgs[test_org] }
34
-
35
- it "We can find an org by name" do
36
- expect(orgs.by_name(test_org).all.count).to eq(1)
37
- expect(orgs.by_name(test_org).all.first.name).to eq(the_org.name)
38
- end
39
-
40
- # TODO: Automatically extract this from the filter by field
41
- %w(name, id, full_name, authz_id).each do |accessor|
42
- it "We can access an org by #{accessor}" do
43
- expect(orgs.by_name(test_org).all.count).to eq(1)
44
- expect(orgs.by_name(test_org).all.first.name).to eq(the_org.name)
45
- end
46
- end
47
-
48
- end
49
-
50
-
51
-
52
-
53
- end