sistero 0.7.1 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/bin/sistero +7 -4
- data/lib/sistero.rb +47 -20
- data/lib/sistero/config.rb +1 -1
- data/lib/sistero/version.rb +1 -1
- data/readme.md +70 -13
- data/sistero.gemspec +1 -1
- metadata +8 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f235e9d54734e98384ab4f4cc22e09c6b90db8b9cd788da9a240448245c5fc98
|
4
|
+
data.tar.gz: a435ca3f77f729d317e44e029d6f2c7df0857b5374b38ee948410a7a939229e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a7e25013fac34584e0bfabd3f0ffd3e24e11f26d61744b7ef3c30f3971f3b8a799a99a8cf4f727a03867e3e13045465e893386ddfb5013d3eff57c9ab379d1
|
7
|
+
data.tar.gz: c37a09b748bc6b9c38e78e817b60e8f5bc0e2ca87d9fcaa1af51c82c398e12c69200167b5d63a59f1fb6b294e7e46be8f49be6bc25eebe20993e4b18eac4cd7a
|
data/bin/sistero
CHANGED
@@ -24,10 +24,12 @@ module Sistero::Command
|
|
24
24
|
op.on '-c', '--config file', 'override path to config file', 'cfg_file_path'
|
25
25
|
op.on '-d', '--directory dir', 'set working dir', 'directory'
|
26
26
|
|
27
|
-
op.subcommand 'ssh [vm]', 'ssh to vm' do |subop|
|
27
|
+
op.subcommand 'ssh [vm] [*run]', 'ssh to vm' do |subop|
|
28
28
|
subop.on '-o val', 'add ssh options', 'ssh_options'
|
29
29
|
end
|
30
30
|
|
31
|
+
op.subcommand 'rsync vm *cmd', 'rsync files to/from vm'
|
32
|
+
|
31
33
|
op.subcommand 'create [*vms]', 'create vm'
|
32
34
|
op.subcommand 'create-all', 'create all vms in config'
|
33
35
|
op.subcommand 'destroy [*vms]', 'destroy vm'
|
@@ -56,12 +58,13 @@ module Sistero::Command
|
|
56
58
|
|
57
59
|
case command
|
58
60
|
when 'ssh'
|
59
|
-
|
60
|
-
|
61
|
+
sistero.ssh_to_vm(command_cfg.vm, ssh_options: command_cfg.ssh_options, run: command_cfg.run)
|
62
|
+
when 'rsync'
|
63
|
+
sistero.rsync(command_cfg.vm, cmd: command_cfg.cmd)
|
61
64
|
when 'create'
|
62
65
|
vms = command_cfg.vms
|
63
66
|
vms.push nil if vms.empty?
|
64
|
-
vms.each &sistero.method(:
|
67
|
+
vms.each &sistero.method(:create_droplet_from_vm)
|
65
68
|
when 'create-all'
|
66
69
|
sistero.create_all()
|
67
70
|
when 'destroy'
|
data/lib/sistero.rb
CHANGED
@@ -10,12 +10,12 @@ module Sistero
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def find_droplet(name)
|
13
|
-
@client.droplets.all.find { |
|
13
|
+
@client.droplets.all.find { |droplet| droplet.name == name }
|
14
14
|
end
|
15
15
|
|
16
16
|
def list_vms()
|
17
|
-
@client.droplets.all.each do |
|
18
|
-
puts "#{
|
17
|
+
@client.droplets.all.each do |droplet|
|
18
|
+
puts "#{droplet.name} - #{get_public_ip droplet}"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -65,33 +65,33 @@ module Sistero
|
|
65
65
|
return false
|
66
66
|
end
|
67
67
|
|
68
|
-
def ssh_to_vm(name, ssh_options: nil)
|
68
|
+
def ssh_to_vm(name, ssh_options: nil, run: nil)
|
69
69
|
vm, name = get_vm name
|
70
70
|
ssh_options ||= vm.ssh_options
|
71
71
|
|
72
72
|
droplet = find_droplet(name) || create_droplet_from_vm(name)
|
73
|
-
|
74
|
-
|
75
|
-
puts "no public interfaces, trying again in a second"
|
76
|
-
sleep 1
|
77
|
-
droplet = find_droplet(name)
|
78
|
-
public_network = droplet.networks.v4.find { |network| network.type == 'public' }
|
79
|
-
end
|
80
|
-
ip = public_network.ip_address
|
73
|
+
public_ip = get_public_ip droplet
|
74
|
+
wait_for_ssh_port public_ip
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
until is_port_open? ip, 22 do
|
86
|
-
sleep 1
|
87
|
-
end
|
76
|
+
cmd = "ssh -o 'StrictHostKeyChecking no' #{ssh_options} #{vm.ssh_user || 'root'}@#{public_ip}"
|
77
|
+
unless run.empty?
|
78
|
+
cmd += ' ' + run.join(' ')
|
88
79
|
end
|
89
80
|
|
90
|
-
|
91
|
-
puts cmd
|
81
|
+
# puts cmd
|
92
82
|
exec cmd
|
93
83
|
end
|
94
84
|
|
85
|
+
def rsync(name, cmd: nil)
|
86
|
+
vm, name = get_vm name
|
87
|
+
droplet = find_droplet(name) || create_droplet_from_vm(name)
|
88
|
+
public_ip = get_public_ip droplet
|
89
|
+
wait_for_ssh_port public_ip
|
90
|
+
|
91
|
+
cmd_str = 'rsync ' + cmd.join(' ').gsub('vm:', "#{vm.ssh_user || 'root'}@#{public_ip}:")
|
92
|
+
exec cmd_str
|
93
|
+
end
|
94
|
+
|
95
95
|
def destroy_vm(name)
|
96
96
|
vm, name = get_vm name
|
97
97
|
|
@@ -143,5 +143,32 @@ module Sistero
|
|
143
143
|
puts " regions #{image.regions.join ', '}"
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
private
|
148
|
+
def find_public_network droplet
|
149
|
+
droplet&.networks.v4.find { |network| network.type == 'public' }
|
150
|
+
end
|
151
|
+
|
152
|
+
private
|
153
|
+
def get_public_ip droplet
|
154
|
+
public_network = find_public_network droplet
|
155
|
+
until public_network
|
156
|
+
puts "no public interfaces, trying again in a second"
|
157
|
+
sleep 1
|
158
|
+
droplet = find_droplet(droplet.name)
|
159
|
+
public_network = find_public_network droplet
|
160
|
+
end
|
161
|
+
public_network.ip_address
|
162
|
+
end
|
163
|
+
|
164
|
+
def wait_for_ssh_port public_ip
|
165
|
+
unless is_port_open? public_ip, 22
|
166
|
+
puts "waiting for ssh port to open"
|
167
|
+
sleep 1
|
168
|
+
until is_port_open? public_ip, 22 do
|
169
|
+
sleep 1
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
146
173
|
end
|
147
174
|
end
|
data/lib/sistero/config.rb
CHANGED
data/lib/sistero/version.rb
CHANGED
data/readme.md
CHANGED
@@ -8,33 +8,35 @@ sistero is a profile based tool to manage a digital ocean cluster.
|
|
8
8
|
|
9
9
|
## Configuration
|
10
10
|
|
11
|
-
|
11
|
+
First sistero looks for a file called `sistero.yaml` in the current directory or a parent of the current directory. If it is not found the default configuration is loaded from `.config/sistero`. Here is an example:
|
12
12
|
|
13
13
|
```
|
14
14
|
defaults:
|
15
|
-
|
15
|
+
name: default-vm
|
16
16
|
ssh_keys:
|
17
17
|
- 1234567
|
18
18
|
ssh_options: -D1080 -A
|
19
19
|
access_token: f788fffffffffffff8ffffffffffffffffffffff8fffffffffffffffffffffff
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
size: 512mb
|
21
|
+
region: nyc3
|
22
|
+
image: ubuntu-14-04-x64
|
23
|
+
vms:
|
24
24
|
-
|
25
|
-
|
26
|
-
vm_region: lon1
|
25
|
+
name: default-vm
|
27
26
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
name: london-vm
|
28
|
+
region: lon1
|
29
|
+
-
|
30
|
+
name: london-bigger-vm
|
31
|
+
region: lon1
|
32
|
+
size: 1gb
|
31
33
|
```
|
32
34
|
|
33
|
-
Any values not specified in a profile are taken from `defaults`. If the `defaults` entry specifies a `
|
35
|
+
Any values not specified in a profile are taken from `defaults`. If the `defaults` entry specifies a `name` then it becomes the default VM for the `create`, `ssh` and `destroy` commands but is not inherited by vm configuration items.
|
34
36
|
|
35
37
|
The `ssh_keys` is a list of ID numbers (rather than names) of ssh keys, these can be found by running `sistero ssh-keys`.
|
36
38
|
|
37
|
-
The valid options for `region`, `
|
39
|
+
The valid options for `region`, `size` and `image` can be found by running `sistero regions`, `sistero sizes` and `sistero images` respectively.
|
38
40
|
|
39
41
|
## Running
|
40
42
|
|
@@ -47,3 +49,58 @@ Or to create a VM called `london-vm` in london:
|
|
47
49
|
```
|
48
50
|
sistero create london-vm
|
49
51
|
```
|
52
|
+
|
53
|
+
The command `sistero create-all` can be used to create all VMs listed in the configuration file.
|
54
|
+
|
55
|
+
## More advanced configurations
|
56
|
+
|
57
|
+
This config that shows how to create a CoreOS cluster:
|
58
|
+
|
59
|
+
```
|
60
|
+
defaults:
|
61
|
+
ssh_user: core
|
62
|
+
ssh_keys:
|
63
|
+
- 1234567
|
64
|
+
- 1234568
|
65
|
+
ssh_options: -D1080 -A
|
66
|
+
access_token:
|
67
|
+
file: ./secrets/digital-ocean.access-token
|
68
|
+
region: lon1
|
69
|
+
image: coreos-stable
|
70
|
+
name: vm1
|
71
|
+
private_networking: true
|
72
|
+
user_data: |
|
73
|
+
#cloud-config
|
74
|
+
coreos:
|
75
|
+
etcd2:
|
76
|
+
# y$@" :r !curl -s -w "\n" "https://discovery.etcd.io/new?size=2"
|
77
|
+
discovery: https://discovery.etcd.io/af66d811fc9b5b9b0989009f849cc37a
|
78
|
+
# use $public_ipv4 for multi-cloud/region:
|
79
|
+
advertise-client-urls: http://$private_ipv4:2379
|
80
|
+
initial-advertise-peer-urls: http://$private_ipv4:2380
|
81
|
+
listen-client-urls: http://0.0.0.0:2379
|
82
|
+
listen-peer-urls: http://$private_ipv4:2380
|
83
|
+
fleet:
|
84
|
+
public-ip: $private_ipv4 # used for fleetctl ssh command
|
85
|
+
metadata: "size=#{size},name=#{name}"
|
86
|
+
units:
|
87
|
+
- name: etcd2.service
|
88
|
+
command: start
|
89
|
+
- name: fleet.service
|
90
|
+
command: start
|
91
|
+
vms:
|
92
|
+
-
|
93
|
+
name: vm1
|
94
|
+
size: 1gb
|
95
|
+
-
|
96
|
+
name: vm2
|
97
|
+
size: 512mb
|
98
|
+
-
|
99
|
+
name: vm3
|
100
|
+
size: 512mb
|
101
|
+
```
|
102
|
+
|
103
|
+
This demonstrates a few more things:
|
104
|
+
|
105
|
+
1. The config can be split over multiple files using `file:`, in this config file the digital ocean access token is specified in a different file.
|
106
|
+
2. In `user_data` vm configuration variables can be substituted, see `#{size}` and `#{name}` in the metadata.
|
data/sistero.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.name
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_development_dependency "bundler", "~>
|
29
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
30
30
|
spec.add_development_dependency "rake", "~> 10.0"
|
31
31
|
spec.add_development_dependency "rspec"
|
32
32
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sistero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Pike
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
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: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,7 +105,7 @@ homepage: http://github.com/ohjames/sistero
|
|
105
105
|
licenses: []
|
106
106
|
metadata:
|
107
107
|
allowed_push_host: https://rubygems.org
|
108
|
-
post_install_message:
|
108
|
+
post_install_message:
|
109
109
|
rdoc_options: []
|
110
110
|
require_paths:
|
111
111
|
- lib
|
@@ -120,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
|
124
|
-
|
125
|
-
signing_key:
|
123
|
+
rubygems_version: 3.1.4
|
124
|
+
signing_key:
|
126
125
|
specification_version: 4
|
127
126
|
summary: Profile based digital ocean cluster management command line tool.
|
128
127
|
test_files: []
|