cult 0.1.1.pre → 0.1.2.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +48 -28
  3. data/cult +1 -1
  4. data/cult.gemspec +4 -4
  5. data/doc/images/masthead@0.5x.png +0 -0
  6. data/exe/cult +2 -5
  7. data/lib/cult/artifact.rb +2 -1
  8. data/lib/cult/bundle.rb +26 -0
  9. data/lib/cult/cli/common.rb +2 -0
  10. data/lib/cult/cli/console_cmd.rb +11 -11
  11. data/lib/cult/cli/cri_extensions.rb +1 -2
  12. data/lib/cult/cli/fleet_cmd.rb +37 -0
  13. data/lib/cult/cli/init_cmd.rb +0 -2
  14. data/lib/cult/cli/node_cmd.rb +54 -22
  15. data/lib/cult/cli/task_cmd.rb +25 -9
  16. data/lib/cult/commander.rb +78 -52
  17. data/lib/cult/definition.rb +4 -7
  18. data/lib/cult/driver.rb +1 -1
  19. data/lib/cult/drivers/common.rb +8 -21
  20. data/lib/cult/drivers/digital_ocean_driver.rb +41 -48
  21. data/lib/cult/drivers/linode_driver.rb +12 -19
  22. data/lib/cult/drivers/load.rb +0 -3
  23. data/lib/cult/drivers/vultr_driver.rb +33 -44
  24. data/lib/cult/named_array.rb +62 -14
  25. data/lib/cult/node.rb +43 -8
  26. data/lib/cult/project.rb +0 -8
  27. data/lib/cult/project_context.rb +23 -0
  28. data/lib/cult/provider.rb +0 -3
  29. data/lib/cult/role.rb +30 -50
  30. data/lib/cult/singleton_instances.rb +43 -0
  31. data/lib/cult/skel.rb +2 -2
  32. data/lib/cult/task.rb +30 -8
  33. data/lib/cult/template.rb +18 -70
  34. data/lib/cult/transaction.rb +44 -0
  35. data/lib/cult/transferable.rb +2 -5
  36. data/lib/cult/user_refinements.rb +65 -0
  37. data/lib/cult/version.rb +1 -1
  38. data/lib/cult.rb +26 -0
  39. data/skel/roles/all/tasks/sync +24 -0
  40. data/skel/roles/bootstrap/files/cult-motd +1 -1
  41. metadata +19 -14
  42. data/lib/cult/config.rb +0 -22
  43. data/lib/cult/drivers/script_driver.rb +0 -27
  44. data/skel/keys/.keep +0 -0
@@ -0,0 +1,65 @@
1
+ require 'json'
2
+ require 'shellwords'
3
+
4
+ # These are refinements we enable in a user-facing context, e.g., the console
5
+ # or template files.
6
+
7
+ module Cult
8
+ module UserRefinements
9
+ # Alright! We found a use for refinements!
10
+ module Util
11
+ module_function
12
+ def squote(s)
13
+ "'" + s.gsub("'", "\\\\\'") + "'"
14
+ end
15
+
16
+
17
+ def dquote(s)
18
+ s.to_json
19
+ end
20
+
21
+
22
+ def slash(s)
23
+ Shellwords.escape(s)
24
+ end
25
+ end
26
+
27
+
28
+ refine String do
29
+ def dquote
30
+ Util.squote(self)
31
+ end
32
+ alias_method :dq, :dquote
33
+ alias_method :q, :dquote
34
+
35
+ def squote
36
+ Util.squote(self)
37
+ end
38
+ alias_method :sq, :squote
39
+
40
+ def slash
41
+ Util.slash(self)
42
+ end
43
+ end
44
+
45
+
46
+ refine Array do
47
+ def dquote(sep = ' ')
48
+ map {|v| Util.dquote(v) }.join(sep)
49
+ end
50
+ alias_method :dq, :dquote
51
+ alias_method :q, :dquote
52
+
53
+ def squote(sep = ' ')
54
+ map {|v| Util.squote(v) }.join(sep)
55
+ end
56
+ alias_method :sq, :squote
57
+
58
+
59
+
60
+ def slash(sep = ' ')
61
+ map {|v| Util.slash(v) }.join(sep)
62
+ end
63
+ end
64
+ end
65
+ end
data/lib/cult/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cult
2
- VERSION = '0.1.1.pre'
2
+ VERSION = '0.1.2.pre'
3
3
  end
data/lib/cult.rb CHANGED
@@ -1,4 +1,30 @@
1
+ require 'cult/artifact'
2
+ require 'cult/bundle'
3
+ require 'cult/commander'
4
+ require 'cult/definition'
5
+ require 'cult/driver'
6
+ require 'cult/named_array'
7
+ require 'cult/node'
8
+ require 'cult/project'
9
+ require 'cult/project_context'
10
+ require 'cult/provider'
11
+ require 'cult/role'
12
+ require 'cult/singleton_instances'
13
+ require 'cult/skel'
14
+ require 'cult/task'
15
+ require 'cult/template'
16
+ require 'cult/transaction'
17
+ require 'cult/transferable'
1
18
  require 'cult/version'
2
19
 
20
+
3
21
  module Cult
22
+ class << self
23
+ attr_accessor :project
24
+
25
+ attr_writer :singletons
26
+ def singletons?
27
+ @singletons
28
+ end
29
+ end
4
30
  end
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ # This file generates a map of all hosts on each node, in an /etc/hosts like
5
+ # format. Because it's included in all, it'll be executed before your custom
6
+ # roles' sync task. That means you can parse the cultmap instead of using
7
+ # custom Ruby templating, if that's not your thing.
8
+ #
9
+ # Keep in mind that this file is evaluated on the local machine, and its result
10
+ # is sent to the remote host.
11
+ #
12
+ # The output format is:
13
+ #
14
+ # 192.168.1.1 node-name # all role1 role2 role3
15
+ #
16
+
17
+ CULTMAP="$HOME/cult/hosts"
18
+ mkdir -p $(basename "$CULTMAP")
19
+ sudo rm -f "$CULTMAP"
20
+
21
+ <% nodes.each do |n| %>
22
+ <% roles = n.build_order.map(&:name).join " " %>
23
+ echo "<%= n.ipv4_private %> <%= n.name %> # <%= roles %>" | sudo tee -a "$CULTMAP"
24
+ <% end %>
@@ -20,7 +20,7 @@ colorize() {
20
20
  }
21
21
 
22
22
  inf() {
23
- TEXT=$(echo "$1" | fold -s -w 60 | fmt -s -c -w 78)
23
+ TEXT=$(echo "$1" | fold -s -w 78 | fmt -s -c -w 78)
24
24
  printf '\e[38;5;8m%s\e[0m\n' "$TEXT"
25
25
  }
26
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cult
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.pre
4
+ version: 0.1.2.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Owens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-28 00:00:00.000000000 Z
11
+ date: 2016-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cri
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.7.0
19
+ version: '2.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.7.0
26
+ version: '2.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: net-ssh
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.0
33
+ version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.2.0
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-scp
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.1
47
+ version: '1.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.1
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rainbow
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.1.0
61
+ version: '2.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.1.0
68
+ version: '2.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -109,13 +109,16 @@ files:
109
109
  - Rakefile
110
110
  - cult
111
111
  - cult.gemspec
112
+ - doc/images/masthead@0.5x.png
112
113
  - doc/welcome.txt
113
114
  - exe/cult
114
115
  - lib/cult.rb
115
116
  - lib/cult/artifact.rb
117
+ - lib/cult/bundle.rb
116
118
  - lib/cult/cli/common.rb
117
119
  - lib/cult/cli/console_cmd.rb
118
120
  - lib/cult/cli/cri_extensions.rb
121
+ - lib/cult/cli/fleet_cmd.rb
119
122
  - lib/cult/cli/init_cmd.rb
120
123
  - lib/cult/cli/load.rb
121
124
  - lib/cult/cli/node_cmd.rb
@@ -123,33 +126,35 @@ files:
123
126
  - lib/cult/cli/role_cmd.rb
124
127
  - lib/cult/cli/task_cmd.rb
125
128
  - lib/cult/commander.rb
126
- - lib/cult/config.rb
127
129
  - lib/cult/definition.rb
128
130
  - lib/cult/driver.rb
129
131
  - lib/cult/drivers/common.rb
130
132
  - lib/cult/drivers/digital_ocean_driver.rb
131
133
  - lib/cult/drivers/linode_driver.rb
132
134
  - lib/cult/drivers/load.rb
133
- - lib/cult/drivers/script_driver.rb
134
135
  - lib/cult/drivers/vultr_driver.rb
135
136
  - lib/cult/named_array.rb
136
137
  - lib/cult/node.rb
137
138
  - lib/cult/project.rb
139
+ - lib/cult/project_context.rb
138
140
  - lib/cult/provider.rb
139
141
  - lib/cult/role.rb
142
+ - lib/cult/singleton_instances.rb
140
143
  - lib/cult/skel.rb
141
144
  - lib/cult/task.rb
142
145
  - lib/cult/template.rb
146
+ - lib/cult/transaction.rb
143
147
  - lib/cult/transferable.rb
148
+ - lib/cult/user_refinements.rb
144
149
  - lib/cult/version.rb
145
150
  - skel/.cultconsolerc
146
151
  - skel/.cultrc.erb
147
152
  - skel/README.md.erb
148
- - skel/keys/.keep
149
153
  - skel/nodes/.keep
150
154
  - skel/providers/.keep
151
155
  - skel/roles/all/role.json
152
156
  - skel/roles/all/tasks/00000-do-something-cool
157
+ - skel/roles/all/tasks/sync
153
158
  - skel/roles/bootstrap/files/cult-motd
154
159
  - skel/roles/bootstrap/role.json
155
160
  - skel/roles/bootstrap/tasks/00000-set-hostname
@@ -176,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
181
  version: 1.3.1
177
182
  requirements: []
178
183
  rubyforge_project:
179
- rubygems_version: 2.6.6
184
+ rubygems_version: 2.5.1
180
185
  signing_key:
181
186
  specification_version: 4
182
187
  summary: Fleet Management like its 1990
data/lib/cult/config.rb DELETED
@@ -1,22 +0,0 @@
1
- module Cult
2
- module_function
3
- def project=(project)
4
- @project = project
5
- end
6
-
7
- def project
8
- @project
9
- end
10
-
11
- # This is a a mode we're considering: when it's set, certain objects
12
- # will be frozen when they're created, and creating a "logically the same"
13
- # instance (e.g., role with same name in the same project) will return
14
- # the actual same object each time.
15
- #
16
- # I'm not sure if we'll commit to this, but having this toggle lets us
17
- # easily see what breaks.
18
- def immutable?
19
- ENV['CULT_IMMUTABLE'] == '1'
20
- end
21
-
22
- end
@@ -1,27 +0,0 @@
1
- require 'cult/driver'
2
- require 'cult/drivers/common'
3
-
4
- module Cult
5
- module Drivers
6
-
7
- class ScriptDriver < ::Cult::Driver
8
- include Common
9
-
10
- def initialize(api_key:)
11
- fail NotImplementedError
12
- end
13
-
14
-
15
- def provision!(name:, size:, zone:, image:, ssh_key_files:, extra: {})
16
- fail NotImplementedError
17
- end
18
-
19
-
20
- def self.setup!
21
- super
22
- fail NotImplementedError
23
- end
24
- end
25
-
26
- end
27
- end
data/skel/keys/.keep DELETED
File without changes