gearship 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3893ba4345cc9005374a5568012a3ec5ccb5b07c
4
- data.tar.gz: d725cd188273a288e3f406ce9ea335d11717cc6a
3
+ metadata.gz: 86d96d296139d8b354fe5a40c6f624d118de218f
4
+ data.tar.gz: 909431af40628e676297513b34dbe52edd7fc76c
5
5
  SHA512:
6
- metadata.gz: fd11e99fe1e66d4753ab4a1fe5615800375f563e73d082d60bd618c6d8a3f682c9042828e2483e964ad4ff59357d64dbb5a4eba1ea789325bbfd6d0d26be69ae
7
- data.tar.gz: b2f73a0b0a336514bcb9f121b4cb3e48fb20f8a5ac668ceb326e57cd9ecd032a08572640b14e44a95f490de4c3c432d065090be93279c7508c2eaa8b74f5133b
6
+ metadata.gz: f89420895ffaf548b45c05e94a84ac462a77066bc81550811700f4e4c0ede9976ad67b3ca143fef9e308d44526513c431772c1e90b1f31319a799558e07a6109
7
+ data.tar.gz: 58581cc785ab37a3e2b579559e52d2cc9112c11fdfa2da7c4c4b295244a23de1c79d6aea21baf0a5435f5bc9b0a80e5abc155911c7d0ef32f088a4427217af4f
data/gearship.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'gearship'
5
- spec.version = '0.2.3'
5
+ spec.version = '0.2.4'
6
6
  spec.authors = ['Leonas']
7
7
  spec.email = ['leonas@leonas.io']
8
8
  spec.homepage = 'http://github.com/leonas/gearship'
data/lib/gearship/cli.rb CHANGED
@@ -7,14 +7,20 @@ module Gearship
7
7
  include Thor::Actions
8
8
 
9
9
  desc 'init', 'Initialize gearship project'
10
- def init(project = 'gearship')
11
- init!(project)
10
+ def init
11
+ init!('gearship')
12
12
  end
13
13
 
14
14
  desc 'go [mission] [--sudo]', 'Send gearship on a mission with ssh.'
15
15
  method_options :sudo => false
16
- def go(target, *args)
17
- go!(target, *args)
16
+ def go(mission, *args)
17
+ go!(mission, *args)
18
+ end
19
+
20
+ desc 'local [mission] [--sudo]', 'Send gearship on a local mission.'
21
+ method_options :sudo => false
22
+ def local(mission, *args)
23
+ local!(mission, *args)
18
24
  end
19
25
 
20
26
  desc 'compile', 'Compile gearship project for debugging'
@@ -30,23 +36,24 @@ module Gearship
30
36
  end
31
37
 
32
38
  def init!(project)
33
- copy_file 'templates/.dockerignore', ".dockerignore"
34
- copy_file 'templates/.gitignore', "#{project}/.gitignore"
35
- copy_file 'templates/gearship.yml', "#{project}/gearship.yml"
36
- copy_file 'templates/gearship.sh', "#{project}/gearship.sh"
39
+ copy_file 'templates/.dockerignore', ".dockerignore"
40
+ copy_file 'templates/.gitignore', "gearship/.gitignore"
41
+ copy_file 'templates/gearship.yml', "gearship/gearship.yml"
42
+ copy_file 'templates/gearship.sh', "gearship/gearship.sh"
37
43
 
38
- copy_file 'templates/actions/configure_firewall.sh', "#{project}/actions/configure_firewall.sh"
39
- copy_file 'templates/actions/install_basics.sh', "#{project}/actions/install_basics.sh"
40
- copy_file 'templates/actions/install_docker.sh', "#{project}/actions/install_docker.sh"
41
- copy_file 'templates/actions/pull_latest_image.sh', "#{project}/actions/pull_latest_image.sh"
42
- copy_file 'templates/actions/remove_container.sh', "#{project}/actions/remove_container.sh"
43
- copy_file 'templates/actions/start_container.sh', "#{project}/actions/start_container.sh"
44
+ copy_file 'templates/actions/configure_firewall.sh', "gearship/actions/configure_firewall.sh"
45
+ copy_file 'templates/actions/install_basics.sh', "gearship/actions/install_basics.sh"
46
+ copy_file 'templates/actions/install_docker.sh', "gearship/actions/install_docker.sh"
47
+ copy_file 'templates/actions/login_docker.sh', "gearship/actions/login_docker.sh"
48
+ copy_file 'templates/actions/pull_image.sh', "gearship/actions/pull_image.sh"
49
+ copy_file 'templates/actions/remove_container.sh', "gearship/actions/remove_container.sh"
50
+ copy_file 'templates/actions/start_container.sh', "gearship/actions/start_container.sh"
44
51
 
45
- copy_file 'templates/missions/install_container.sh', "#{project}/missions/install_container.sh"
46
- copy_file 'templates/missions/setup_host.sh', "#{project}/missions/setup_host.sh"
47
- copy_file 'templates/missions/update_container.sh', "#{project}/missions/update_container.sh"
52
+ copy_file 'templates/missions/install_container.sh', "gearship/missions/install_container.sh"
53
+ copy_file 'templates/missions/setup_host.sh', "gearship/missions/setup_host.sh"
54
+ copy_file 'templates/missions/update_container.sh', "gearship/missions/update_container.sh"
48
55
 
49
- copy_file 'templates/cargo/sample.conf', "#{project}/cargo/sample.conf"
56
+ copy_file 'templates/cargo/sample.conf', "gearship/cargo/sample.conf"
50
57
  end
51
58
 
52
59
  def go!(*args)
@@ -56,10 +63,10 @@ module Gearship
56
63
 
57
64
  if mission.include? 'local'
58
65
  local_commands = <<-EOS
59
- bash compiled/gearship.sh
66
+ cd compiled
67
+ #{sudo}bash gearship.sh
60
68
  EOS
61
69
  else
62
-
63
70
  user, host, port = parse_target(@config['attributes']['ssh_target'])
64
71
  endpoint = "#{user}@#{host}"
65
72
 
@@ -82,6 +89,23 @@ module Gearship
82
89
  EOS
83
90
  end
84
91
 
92
+ execute(local_commands)
93
+ end
94
+
95
+ def local!(*args)
96
+ mission = args[0]
97
+ compile!(mission)
98
+ sudo = 'sudo ' if options.sudo?
99
+
100
+ local_commands = <<-EOS
101
+ cd compiled
102
+ #{sudo}bash gearship.sh
103
+ EOS
104
+
105
+ execute(local_commands)
106
+ end
107
+
108
+ def execute(local_commands)
85
109
  Open3.popen3(local_commands) do |stdin, stdout, stderr|
86
110
  stdin.close
87
111
  t = Thread.new do
@@ -95,7 +119,6 @@ module Gearship
95
119
  t.join
96
120
  end
97
121
  end
98
-
99
122
 
100
123
  def compile!(mission)
101
124
  abort_with 'You must be in the gearship folder' unless File.exists?('gearship.yml')
@@ -1,12 +1,14 @@
1
1
  if gearship.install "docker-ce"; then
2
- sudo apt-get install -y linux-image-extra-$(uname -r) linux-image-extra-virtual
3
-
4
- sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
5
-
6
2
  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
7
-
8
3
  sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
9
-
10
4
  sudo apt-get update
11
- sudo apt-get install -y docker-ce
5
+
6
+ sudo apt-get install -y linux-image-extra-$(uname -r) \
7
+ linux-image-extra-virtual \
8
+ apt-transport-https \
9
+ ca-certificates \
10
+ software-properties-common \
11
+ docker-ce
12
+
13
+
12
14
  fi
@@ -1,2 +1 @@
1
1
  docker login -u="<%= @attributes.docker_username %>" -p="<%= @attributes.docker_password %>"
2
- docker pull <%= @attributes.container_repo %>
@@ -0,0 +1 @@
1
+ docker pull <%= @attributes.container_repo %>
@@ -1,5 +1,4 @@
1
1
  docker run --name <%= @attributes.container_name %> \
2
2
  --publish <%= @attributes.container_port_map %> \
3
3
  --restart always \
4
- --detach \
5
4
  <%= @attributes.container_repo %>
@@ -38,15 +38,4 @@ echo "
38
38
  | (_ |/ -_)/ _\` || '_|(_-<| ' \ | || '_ \\
39
39
  \___|\___|\__,_||_| /__/|_||_||_|| .__/
40
40
  |_|
41
-
42
- ___ _ _ __ _
43
- / _ \| ' \ / _\` |
44
- \___/|_||_| \__,_|
45
-
46
- _ _ _
47
- _ __ (_) ___ ___(_) ___ _ _ | |
48
- | ' \ | |(_-<(_-<| |/ _ \| ' \ |_|
49
- |_|_|_||_|/__//__/|_|\___/|_||_|(_)
50
-
51
-
52
41
  "
@@ -5,7 +5,7 @@ attributes:
5
5
  docker_password: docker_password
6
6
  container_name: container_name
7
7
  container_repo: username/repository
8
- container_port_map: "80:4000"
8
+ container_port_map: 80:4000
9
9
 
10
10
  # Remote actions here will be downloaded to compiled/actions.
11
11
  actions:
@@ -1,2 +1,3 @@
1
- source actions/pull_latest_image.sh
1
+ source actions/login_docker.sh
2
+ source actions/pull_image.sh
2
3
  source actions/start_container.sh
@@ -0,0 +1,2 @@
1
+ source actions/pull_image.sh
2
+ source actions/start_container.sh
@@ -1,3 +1,4 @@
1
1
  source actions/remove_container.sh
2
- source actions/pull_latest_image.sh
2
+ source actions/login_docker.sh
3
+ source actions/pull_image.sh
3
4
  source actions/start_container.sh
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gearship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-13 00:00:00.000000000 Z
11
+ date: 2017-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -77,13 +77,15 @@ files:
77
77
  - lib/templates/actions/configure_firewall.sh
78
78
  - lib/templates/actions/install_basics.sh
79
79
  - lib/templates/actions/install_docker.sh
80
- - lib/templates/actions/pull_latest_image.sh
80
+ - lib/templates/actions/login_docker.sh
81
+ - lib/templates/actions/pull_image.sh
81
82
  - lib/templates/actions/remove_container.sh
82
83
  - lib/templates/actions/start_container.sh
83
84
  - lib/templates/cargo/sample.conf
84
85
  - lib/templates/gearship.sh
85
86
  - lib/templates/gearship.yml
86
87
  - lib/templates/missions/install_container.sh
88
+ - lib/templates/missions/install_locally.sh
87
89
  - lib/templates/missions/setup_host.sh
88
90
  - lib/templates/missions/update_container.sh
89
91
  homepage: http://github.com/leonas/gearship