open-dock 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -10
- data/lib/open-dock/chef.rb +8 -0
- data/lib/open-dock/commands/configure_host.rb +27 -0
- data/lib/open-dock/commands/ship_host.rb +4 -5
- data/lib/open-dock/docker.rb +1 -0
- data/lib/open-dock/ops.rb +1 -0
- data/lib/open-dock/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f1505c1a79c47a3eaf3547ba9cb41d0b2a5947b
|
4
|
+
data.tar.gz: ab491f5bf6610a624e9f8473806cbfb1b0fc0fe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e3b55323382232ac6f29a1c20bb3d2725ab7dce58f39958c7a37c3718a7993ca5612b16b1dbca04e7b3d4cf5bb5c91818e7fd1f517ff337a149ea5ef489837
|
7
|
+
data.tar.gz: c74ede46fee31e533eb8d55da0cc472420d7e12bcd9a14bbfb0d23cd04ac8f7e9d2ec01111025ddf107604e7a7a9dc1bc6620a3ba62e67d1446a2cdcf1235500
|
data/README.md
CHANGED
@@ -43,9 +43,9 @@ containers
|
|
43
43
|
|
44
44
|
## Configure PROVIDER
|
45
45
|
|
46
|
-
`ops list` command will list all providers
|
46
|
+
`ops list` command will list all providers supported by this gem.
|
47
47
|
|
48
|
-
TODO: Create more providers (aws, linode, gcloud, ...)
|
48
|
+
TODO: Create more providers (vagrant, aws, linode, gcloud, ...)
|
49
49
|
|
50
50
|
### Digital Ocean
|
51
51
|
|
@@ -152,18 +152,29 @@ www:
|
|
152
152
|
|
153
153
|
### Shipping your local Docker
|
154
154
|
|
155
|
-
You can create a file `containers/localhost.yml` where you can define containers. And launch them on your workstation:
|
155
|
+
You can create a file `containers/localhost.example.com.yml` where you can define containers. And launch them on your workstation:
|
156
156
|
|
157
157
|
```
|
158
|
-
ops ship localhost
|
158
|
+
ops ship localhost.example.com
|
159
159
|
```
|
160
160
|
|
161
|
-
|
161
|
+
By convention:
|
162
|
+
|
163
|
+
* If [host_name] include "localhost" string, it is assumed that containers are shipped on local workstation
|
164
|
+
|
165
|
+
## Configure Containers (are nodes for Chef)
|
162
166
|
|
163
167
|
Configuration with chef commands
|
164
168
|
|
165
|
-
* `ops configure
|
166
|
-
* knife solo cook
|
169
|
+
* `ops configure HOST_NAME`: configure with chef all containers in host. Here you need to install knife-solo gem.
|
170
|
+
* Equivalent to: knife solo cook root@[HOST_NAME] -p [each container_ssh_port]
|
171
|
+
* `--container CONTAINER_NAME` to configure one container (default: '--container all')
|
172
|
+
|
173
|
+
By convention:
|
174
|
+
|
175
|
+
* "root" is the user in all containers
|
176
|
+
* Each container configuration is defined in a Chef node: `nodes/[container_name].[host_name].json`
|
177
|
+
* Then you have to create all container name records in your DNS provider: `[container_name].[host_name] CNAME [host_name].`
|
167
178
|
|
168
179
|
## Commands
|
169
180
|
|
@@ -177,7 +188,7 @@ Create/delete domain names, create/delete hosts and ship/unship hosts:
|
|
177
188
|
* `ops ship HOST_NAME` run the containers in the host.
|
178
189
|
* `ops unship HOST_NAME`
|
179
190
|
* TODO: `ops reship HOST_NAME` unship/ship all containers from host.
|
180
|
-
*
|
191
|
+
* `ops configure HOST_NAME` configure all containers with chef.
|
181
192
|
|
182
193
|
## Create your infrastructure project (/ops)
|
183
194
|
|
@@ -198,7 +209,7 @@ source 'https://rubygems.org'
|
|
198
209
|
|
199
210
|
gem 'open-dock'
|
200
211
|
|
201
|
-
# OPTIONAL: Add next gems if you want to integrate with Chef as Configuration management
|
212
|
+
# OPTIONAL: Add next gems if you want to integrate with Chef as Configuration management technology
|
202
213
|
gem 'knife-solo'
|
203
214
|
gem 'librarian-chef'
|
204
215
|
gem 'foodcritic'
|
@@ -242,4 +253,13 @@ Or integrate it within your Chef infrastructure project. Just add the gem to you
|
|
242
253
|
|
243
254
|
### v0.1.0
|
244
255
|
|
245
|
-
* Launch local containers with `containers/localhost.yml` and `ops ship localhost`
|
256
|
+
* Launch local containers with `containers/localhost.yml` and `ops ship localhost`
|
257
|
+
|
258
|
+
### v0.1.1
|
259
|
+
|
260
|
+
Create command `ops configure [host_name]` this will cook all containers. By convention:
|
261
|
+
|
262
|
+
* "root" is the user in all containers
|
263
|
+
* Each container configuration is defined in a Chef node: `nodes/[container_name].[host_name].json`
|
264
|
+
* Then you have to create all container name records in your DNS provider: `[container_name].[host_name] CNAME [host_name].`
|
265
|
+
* If [host_name] include "localhost" string, it is assumed that containers are shipped on local workstation
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Chef
|
2
|
+
def self.cook(user, container_name, host, ssh_port)
|
3
|
+
say "Container '#{container_name}' configuring on #{host}, please wait ....\n"
|
4
|
+
command = "knife solo cook #{user}@#{container_name}.#{host} -p #{ssh_port}"
|
5
|
+
say "Chef CMD: #{command}\n"
|
6
|
+
system command
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
command :configure do |c|
|
2
|
+
c.summary = 'Configure all Docker containers in a host using knife solo'
|
3
|
+
c.syntax = 'ops configure [host_name]'
|
4
|
+
c.description = "Configure all docker containers described in #{Ops::CONTAINERS_DIR}/[host_name].yml"
|
5
|
+
c.option '--container CONTAINER_NAME', String, 'Only configure this container'
|
6
|
+
c.example "Create a container called 'www' in the host example.com. This is described in '#{Ops::CONTAINERS_DIR}/example.com.yml' like:\n # www:\n # detach: true\n # image: jlebrijo/prun\n # ports:\n # - '2222:22'\n # - '80:80'\n # db:\n # detach: true\n # image: jlebrijo/prun-db\n # ports:\n # - '2223:22'\n # - '5432'\n # Equivalent to run:\n # knife solo cook root@www.example.com -p 2222\n # knife solo cook root@db.example.com -p 2223'\n # So you will need to create chef node files as 'nodes/[container_name].[host_name].json':\n # nodes/www.example.com.json\n # nodes/db.example.com.json", 'ops configure example.com'
|
7
|
+
c.action do |args, options|
|
8
|
+
options.default container: 'all'
|
9
|
+
host = args[0]
|
10
|
+
user = Docker::DEFAULT_USER
|
11
|
+
containers = Docker::containers_for(host)
|
12
|
+
|
13
|
+
if options.container == "all"
|
14
|
+
containers.each do |container_name, config|
|
15
|
+
ssh_port = get_port config
|
16
|
+
Chef::cook(user,container_name, host, ssh_port)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
ssh_port = get_port containers[options.container]
|
20
|
+
Chef::cook(user, options.container, host, ssh_port)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_port(config)
|
25
|
+
config["ports"].select{|port| port.end_with? ":22"}[0].split(':')[0]
|
26
|
+
end
|
27
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
command :ship do |c|
|
2
2
|
c.summary = 'Create Docker containers defined in ops/containers/[host_name].yml'
|
3
|
-
c.syntax = 'ops ship
|
3
|
+
c.syntax = 'ops ship [host_name]'
|
4
4
|
c.description = "Create all docker containers described in #{Ops::CONTAINERS_DIR}/[host_name].yml"
|
5
5
|
c.example "Create a container called 'www' in the host example.com. This is described in '#{Ops::CONTAINERS_DIR}/example.com.yml' like:\n # www:\n # detach: true\n # image: jlebrijo/prun\n # ports:\n # - '2222:22'\n # - '80:80'", 'ops ship example.com'
|
6
6
|
c.action do |args, options|
|
7
7
|
host = args[0]
|
8
|
-
user = Ops::get_user_for(host) unless host
|
8
|
+
user = Ops::get_user_for(host) unless host.include? "localhost"
|
9
9
|
|
10
10
|
Docker::containers_for(host).each do |container_name, config|
|
11
11
|
ports = config["ports"].map{|port| "-p #{port}"}.join(" ")
|
@@ -15,12 +15,11 @@ command :ship do |c|
|
|
15
15
|
end
|
16
16
|
say "Container '#{container_name}' loading on #{host}, please wait ....\n"
|
17
17
|
command = "docker run #{options.join(" ")} --name #{container_name} #{ports} #{config["image"]} #{config["command"]}"
|
18
|
-
|
18
|
+
say "Docker CMD: #{command}\n"
|
19
|
+
if host.include? "localhost"
|
19
20
|
system command
|
20
21
|
else
|
21
22
|
Net::SSH.start(host, user) do |ssh|
|
22
|
-
|
23
|
-
say "Docker CMD: #{command}\n"
|
24
23
|
ssh.exec command
|
25
24
|
end
|
26
25
|
end
|
data/lib/open-dock/docker.rb
CHANGED
data/lib/open-dock/ops.rb
CHANGED
data/lib/open-dock/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: open-dock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Lebrijo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -113,6 +113,8 @@ files:
|
|
113
113
|
- bin/ops
|
114
114
|
- lib/open-dock.rb
|
115
115
|
- lib/open-dock/base.rb
|
116
|
+
- lib/open-dock/chef.rb
|
117
|
+
- lib/open-dock/commands/configure_host.rb
|
116
118
|
- lib/open-dock/commands/create_host.rb
|
117
119
|
- lib/open-dock/commands/delete_host.rb
|
118
120
|
- lib/open-dock/commands/exec_host.rb
|