open-dock 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -5
- data/lib/open-dock/commands/ship_host.rb +6 -4
- data/lib/open-dock/commands/unship_host.rb +1 -1
- data/lib/open-dock/docker.rb +24 -0
- data/lib/open-dock/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f95a46172f0a2194702ba0a6219e3b5c7a2102a
|
4
|
+
data.tar.gz: 129b68d7a9c44cf0d89ce8718f0bd46196247c7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3f5e9f131355747abb2abb46661fe5b5d381b8fdad3374b911f4e3e09bedf133b31806e5decd3048023d1b989c45772ed1b7f0c4c7fe0391a7687607aa165a5
|
7
|
+
data.tar.gz: e1f4836d8cdc76ac7e456b75886f931fcf36c073d95560de9415ed7fb41eae243891f3fc3947cd4aa946a1ad619c97d183d9534b0ad889ea1c2e11a234532922
|
data/README.md
CHANGED
@@ -138,9 +138,9 @@ www:
|
|
138
138
|
# cpuset: 0-7
|
139
139
|
|
140
140
|
# POST-CONDITIONS: execute after build the container:
|
141
|
-
post-conditions:
|
142
|
-
- sshpass -p 'J3mw?$_6' ssh-copy-id -o 'StrictHostKeyChecking no' -i ~/.ssh/id_rsa.pub root@lebrijo.com -p 2222
|
143
|
-
- ssh root@lebrijo.com -p 2222 "echo 'root:Kxxxxx1' | chpasswd"
|
141
|
+
# post-conditions:
|
142
|
+
# - sshpass -p 'J3mw?$_6' ssh-copy-id -o 'StrictHostKeyChecking no' -i ~/.ssh/id_rsa.pub root@lebrijo.com -p 2222
|
143
|
+
# - ssh root@lebrijo.com -p 2222 "echo 'root:Kxxxxx1' | chpasswd"
|
144
144
|
|
145
145
|
# here you can create other containers
|
146
146
|
# db:
|
@@ -150,6 +150,8 @@ www:
|
|
150
150
|
|
151
151
|
`ops ship example.com` will create all containers configured on 'containers/example.com.yml' file
|
152
152
|
|
153
|
+
Note: host SSH credentials (id_rsa.pub and authorized_keys) are copied by default to container, in order to have the same access to conainer.
|
154
|
+
|
153
155
|
### Shipping your local Docker
|
154
156
|
|
155
157
|
You can create a file `containers/localhost.example.com.yml` where you can define containers. And launch them on your workstation:
|
@@ -160,7 +162,7 @@ ops ship localhost.example.com
|
|
160
162
|
|
161
163
|
By convention:
|
162
164
|
|
163
|
-
* If [host_name]
|
165
|
+
* If [host_name] includes "localhost" string, it is assumed that containers are shipped as docker containers in local workstation
|
164
166
|
|
165
167
|
## Configure Containers (are nodes for Chef)
|
166
168
|
|
@@ -189,6 +191,7 @@ Create/delete domain names, create/delete hosts and ship/unship hosts:
|
|
189
191
|
* `ops unship HOST_NAME`
|
190
192
|
* TODO: `ops reship HOST_NAME` unship/ship all containers from host.
|
191
193
|
* `ops configure HOST_NAME` configure all containers with chef.
|
194
|
+
* TODO: `ops ssh [CONTAINER_NAME] HOST_NAME` ssh connection to host or container
|
192
195
|
|
193
196
|
## Create your infrastructure project (/ops)
|
194
197
|
|
@@ -262,4 +265,8 @@ Create command `ops configure [host_name]` this will cook all containers. By con
|
|
262
265
|
* "root" is the user in all containers
|
263
266
|
* Each container configuration is defined in a Chef node: `nodes/[container_name].[host_name].json`
|
264
267
|
* 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
|
268
|
+
* If [host_name] include "localhost" string, it is assumed that containers are shipped on local workstation
|
269
|
+
|
270
|
+
### v0.1.2
|
271
|
+
|
272
|
+
* Delete post-conditions from containers files. By default host credentials are passed to conainers.
|
@@ -17,14 +17,16 @@ command :ship do |c|
|
|
17
17
|
command = "docker run #{options.join(" ")} --name #{container_name} #{ports} #{config["image"]} #{config["command"]}"
|
18
18
|
say "Docker CMD: #{command}\n"
|
19
19
|
if host.include? "localhost"
|
20
|
-
system command
|
20
|
+
system "#{command} ; #{Docker::copy_ssh_credentials_command(container_name)}"
|
21
21
|
else
|
22
22
|
Net::SSH.start(host, user) do |ssh|
|
23
|
-
ssh.exec command
|
23
|
+
ssh.exec "#{command} ; #{Docker::copy_ssh_credentials_command(container_name)}"
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
|
26
|
+
if config["post-conditions"]
|
27
|
+
sleep 5
|
28
|
+
config["post-conditions"].each { |c| system c }
|
29
|
+
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
data/lib/open-dock/docker.rb
CHANGED
@@ -14,4 +14,28 @@ module Docker
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.copy_ssh_credentials_command(container_name)
|
18
|
+
<<-EOH
|
19
|
+
# Container folder
|
20
|
+
if sudo test -d "/var/lib/docker/aufs"; then
|
21
|
+
CONTAINERS_DIR=/var/lib/docker/aufs/mnt
|
22
|
+
elif sudo test -d "/var/lib/docker/aufs"; then
|
23
|
+
CONTAINERS_DIR=/var/lib/docker/btrfs/subvolumes
|
24
|
+
fi
|
25
|
+
|
26
|
+
ID=$(docker inspect -f '{{.Id}}' #{container_name})
|
27
|
+
SSH_DIR=$CONTAINERS_DIR/$ID/root/.ssh
|
28
|
+
echo SSH container folder is $SSH_DIR
|
29
|
+
if sudo test ! -d "$SSH_DIR" ; then
|
30
|
+
sudo mkdir $SSH_DIR
|
31
|
+
fi
|
32
|
+
|
33
|
+
echo Copying authorized_keys and id_rsa.pub files
|
34
|
+
sudo touch $SSH_DIR/authorized_keys
|
35
|
+
sudo cat ~/.ssh/authorized_keys | sudo tee -a $SSH_DIR/authorized_keys
|
36
|
+
sudo cat ~/.ssh/id_rsa.pub | sudo tee -a $SSH_DIR/authorized_keys
|
37
|
+
sudo chmod 600 $SSH_DIR/authorized_keys
|
38
|
+
EOH
|
39
|
+
end
|
40
|
+
|
17
41
|
end
|
data/lib/open-dock/version.rb
CHANGED