pawnee 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/docs/TODO.md +1 -0
- data/lib/pawnee/pawnee/actions/user.rb +14 -1
- data/lib/pawnee/pawnee/base.rb +6 -4
- data/lib/pawnee/pawnee/version.rb +1 -1
- data/spec/vagrant/.vagrant +1 -1
- metadata +3 -3
data/docs/TODO.md
CHANGED
@@ -9,6 +9,7 @@ TODO: Need to make a clear way for pawnee gems (and recipes) to provide actions
|
|
9
9
|
TODO: Run actions in threads (across multiple servers)
|
10
10
|
TODO: Test to make sure arguments work directly as well (they probably don't right now)
|
11
11
|
TODO: System to check for and register updates/modifications
|
12
|
+
TODO: Add apt-get update to package stuff
|
12
13
|
|
13
14
|
|
14
15
|
def setup
|
@@ -2,6 +2,19 @@ require 'pawnee/actions/base_model'
|
|
2
2
|
|
3
3
|
module Pawnee
|
4
4
|
module Actions
|
5
|
+
# Adds the user (specified by login) to the group
|
6
|
+
def add_user_to_group(login, group)
|
7
|
+
user = self.user(login)
|
8
|
+
user.groups << group
|
9
|
+
user.groups = user.groups.sort.uniq
|
10
|
+
user.save
|
11
|
+
end
|
12
|
+
|
13
|
+
# Return the user object for the login
|
14
|
+
def user(login)
|
15
|
+
return User.new(self, {:login => login})
|
16
|
+
end
|
17
|
+
|
5
18
|
def create_user(attributes)
|
6
19
|
User.new(self, attributes).save
|
7
20
|
end
|
@@ -61,7 +74,7 @@ module Pawnee
|
|
61
74
|
if exit_code == 0
|
62
75
|
# The login exists, load in more data
|
63
76
|
@gid = exec("id -g #{login}").strip
|
64
|
-
@groups = exec("groups #{login}").gsub(/^[^:]+[:]/, '').strip.split(/ /)
|
77
|
+
@groups = exec("groups #{login}").gsub(/^[^:]+[:]/, '').strip.split(/ /).sort
|
65
78
|
self.new_record = false
|
66
79
|
|
67
80
|
# Reject any ones we just changed, so its as if we did a find with these
|
data/lib/pawnee/pawnee/base.rb
CHANGED
@@ -142,18 +142,18 @@ module Pawnee
|
|
142
142
|
# role.
|
143
143
|
next unless server.is_a?(String) || server.is_a?(Net::SSH::Connection::Session) || (server['roles'] && server['roles'].include?(self.class.class_role))
|
144
144
|
|
145
|
-
# Set the server for this call
|
146
|
-
self.server = server.is_a?(String) ? server : server['domain']
|
147
|
-
|
148
145
|
# Setup the connection to the server
|
149
146
|
if server.is_a?(Net::SSH::Connection::Session)
|
150
147
|
self.destination_connection = server
|
148
|
+
self.server = server.host
|
151
149
|
elsif server.is_a?(String)
|
152
150
|
# Server name is a string, asume ubuntu
|
153
151
|
self.destination_connection = Net::SSH.start(server, 'ubuntu')
|
152
|
+
self.server = server
|
154
153
|
else
|
155
154
|
# Server is a hash
|
156
155
|
self.destination_connection = Net::SSH.start(server['domain'], server['user'] || 'ubuntu')
|
156
|
+
self.server = server['domain']
|
157
157
|
end
|
158
158
|
|
159
159
|
|
@@ -165,7 +165,9 @@ module Pawnee
|
|
165
165
|
|
166
166
|
# Close the connection
|
167
167
|
if self.destination_connection
|
168
|
-
|
168
|
+
# Close the conection only if we created it. If it was passed in as a connection
|
169
|
+
# then the creator is responsible for closing it
|
170
|
+
self.destination_connection.close unless server.is_a?(Net::SSH::Connection::Session)
|
169
171
|
self.destination_connection = nil
|
170
172
|
end
|
171
173
|
end
|
data/spec/vagrant/.vagrant
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"active":{"default":"
|
1
|
+
{"active":{"default":"9a7fbb28-386f-478a-b11c-6ce30056d085"}}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pawnee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -307,7 +307,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
307
307
|
version: '0'
|
308
308
|
segments:
|
309
309
|
- 0
|
310
|
-
hash:
|
310
|
+
hash: -3847734814061536168
|
311
311
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
312
|
none: false
|
313
313
|
requirements:
|
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
316
|
version: '0'
|
317
317
|
segments:
|
318
318
|
- 0
|
319
|
-
hash:
|
319
|
+
hash: -3847734814061536168
|
320
320
|
requirements: []
|
321
321
|
rubyforge_project:
|
322
322
|
rubygems_version: 1.8.22
|