toquen 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -0
- data/lib/toquen/capistrano.rb +24 -0
- data/lib/toquen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e8eed0f302dd92f603bd71621d6849f55c9ba9a
|
4
|
+
data.tar.gz: c3ef1e77013f5791903d47ed37c7c4e9969151bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61b28d8039fc62c554118dc1efc72fbca653728f4dafdef33769f2b88913c5bcf5cb8caebfcdadd07fda304397b8550e50540d855157bae1218c460bd86a96d6
|
7
|
+
data.tar.gz: 93fa073b84943afd345d1671a6da4550969d7be32abbafd6f79123e2b4b0ad209f950b20c29c9f96acc708e14c1de913dceffa4423cafe4c6115447b6dab3ba9
|
data/README.md
CHANGED
@@ -156,6 +156,20 @@ cap databases open_ssh cook close_ssh
|
|
156
156
|
|
157
157
|
**Note**: You can also use the task *open_port[22]* and *close_port[22]* to open and close SSH (or any other port).
|
158
158
|
|
159
|
+
## Application Configuration
|
160
|
+
Toquen can also drop off a config file meant for use by applications on your system. Here's how that works:
|
161
|
+
|
162
|
+
1. Toquen creates a hash that contains a list of all of your servers and all of their details (based on your servers data_bag)
|
163
|
+
1. Toquen looks for a file named "apps.json" in your config folder, and if it's found, Toquen pulls out all of the keys that correspond with the server's roles and merges them together with the hash it's building (if this file contains secrets, consider *not* including in revision control)
|
164
|
+
1. The resulting hash is dropped off in your user's home directory (this can be overridden with the apps_config_path config variable) with the filename "apps.json".
|
165
|
+
|
166
|
+
This happens on every cook, and can be run separately as:
|
167
|
+
|
168
|
+
```shell
|
169
|
+
cap <role name> update_appconfig
|
170
|
+
```
|
171
|
+
|
172
|
+
|
159
173
|
## Additional Cap Tasks
|
160
174
|
There are a few other helper cap tasks as well - to see them, run:
|
161
175
|
|
data/lib/toquen/capistrano.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'capistrano/setup'
|
2
2
|
require 'capistrano/console'
|
3
3
|
require 'set'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
set :chef_upload_location, -> { "/home/#{fetch(:ssh_options)[:user]}" }
|
6
7
|
|
@@ -25,6 +26,28 @@ task :update_roles do
|
|
25
26
|
Toquen::LocalWriter.superfluous_check!(servers, roles.keys)
|
26
27
|
end
|
27
28
|
|
29
|
+
desc "send up apps.json config file"
|
30
|
+
task :update_appconfig do
|
31
|
+
return unless File.exists?('config/apps.json')
|
32
|
+
apps = JSON.parse(File.read('config/apps.json'))
|
33
|
+
config = { "_description" => "Dropped off by Toquen/Chef.", "servers" => [] }.merge(apps['default'] || {})
|
34
|
+
Dir.glob("#{fetch(:chef_data_bags_path)}/servers/*.json") do |fname|
|
35
|
+
open(fname, 'r') { |f| config['servers'] << JSON.parse(f.read) }
|
36
|
+
end
|
37
|
+
dest = File.join fetch(:apps_config_path, "/home/#{fetch(:ssh_options)[:user]}"), "apps.json"
|
38
|
+
|
39
|
+
on roles(:all), in: :parallel do |host|
|
40
|
+
appconfig = Marshal.load(Marshal.dump(config))
|
41
|
+
host.properties.roles.each do |role|
|
42
|
+
appconfig.merge!(apps[role.to_s] || {})
|
43
|
+
end
|
44
|
+
debug "Uploading app config file to #{dest}"
|
45
|
+
upload! StringIO.new(JSON.pretty_generate(appconfig)), "/tmp/apps.json"
|
46
|
+
sudo "mv /tmp/apps.json #{dest}"
|
47
|
+
sudo "chmod 755 #{dest}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
28
51
|
desc "bootstrap a server so that it can run chef"
|
29
52
|
task :bootstrap do
|
30
53
|
on roles(:all), in: :parallel do |host|
|
@@ -85,6 +108,7 @@ task :cook do
|
|
85
108
|
end
|
86
109
|
end
|
87
110
|
before :cook, :update_kitchen
|
111
|
+
after :cook, :update_appconfig
|
88
112
|
|
89
113
|
desc "Add given role to machines"
|
90
114
|
task :add_role, :role do |t, args|
|
data/lib/toquen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toquen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Muller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|