bard 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecbadd22fc4903fa9e779a515d0a7c9448392ac4fe2396ae2272bab7daeb4018
4
- data.tar.gz: '068143adee00988e0506bb8e834ad5a15ebf65caf9e824d7a7f8e3923b9dbf18'
3
+ metadata.gz: bf24b5fc8c53912b9568bbba566570d1883ab489e7d72dd01869dd1efcdcea8e
4
+ data.tar.gz: 2b069ea15ef1dbc21beccd0c909eedae482909c1a4a3a22fe7eb2e88d765118d
5
5
  SHA512:
6
- metadata.gz: b12423bf86e5978f48a4864c0572585aa583af33d1b1d6cdcdfb3e466b511d00e7e887908720346b6b13e7f09baa4948e511d717dbea34f72883a27385f58d6b
7
- data.tar.gz: 73451d824a62f1f8953f83d89055e87355018aebbf0b92d05741e17391db204be01d594afcedd113bbb347f065a3e42ed3dffc387ebcb94118670e9ce08f0316
6
+ metadata.gz: 3ff5b076f3ef83cd1d1fbf9eec8a510b4b1c6fcde36b0a9f823e48b694d29d0804869c0520dcd04095ff9ec974463c214f11f9e342eef478c30adc5827b0a21a
7
+ data.tar.gz: 64477c11e3e15b746c892329c67fbcb7c33872e2cc58c13aa8aee1ce88ee09976a539704e7f2e7260936b7d38956731542fac34c8684ebdb55943dafa2a3764b
@@ -0,0 +1,16 @@
1
+ # apt sanity
2
+
3
+ class Bard::Provision::Apt < Bard::Provision
4
+ def call
5
+ print "Apt:"
6
+ provision_server.run! [
7
+ %(echo "\\$nrconf{restart} = \\"a\\";" | sudo tee /etc/needrestart/conf.d/90-autorestart.conf),
8
+ "sudo apt-get update -y",
9
+ "sudo apt-get upgrade -y",
10
+ "sudo apt-get install -y curl",
11
+ ].join("; "), home: true
12
+
13
+ puts " ✓"
14
+ end
15
+ end
16
+
@@ -4,25 +4,11 @@ class Bard::Provision::HTTP < Bard::Provision
4
4
  def call
5
5
  print "HTTP:"
6
6
  target_host = URI.parse(server.ping.first).host
7
- if system "curl -s --resolve #{target_host}:80:#{provision_server.ssh_uri.host} http://#{target_host} -I | grep -i \"x-powered-by: phusion passenger\""
7
+ if system "curl -s --resolve #{target_host}:80:#{provision_server.ssh_uri.host} http://#{target_host} -I | grep -i \"x-powered-by: phusion passenger\" >/dev/null 2>&1"
8
8
  puts " ✓"
9
9
  else
10
10
  puts " !!! not serving a rails app from #{provision_server.ssh_uri.host}"
11
11
  end
12
12
  end
13
-
14
- private
15
-
16
- def ssh_available? ssh_uri, port: ssh_uri.port
17
- system "nc -zv #{ssh_uri.host} #{port} 2>/dev/null"
18
- end
19
-
20
- def ssh_known_host? ssh_uri
21
- system "grep -q \"$(ssh-keyscan -t ed25519 -p#{ssh_uri.port || 22} #{ssh_uri.host} 2>/dev/null | cut -d ' ' -f 2-3)\" ~/.ssh/known_hosts"
22
- end
23
-
24
- def add_ssh_known_host! ssh_uri
25
- system "ssh-keyscan -p#{ssh_uri.port || 22} -H #{ssh_uri.host} >> ~/.ssh/known_hosts"
26
- end
27
13
  end
28
14
 
@@ -19,5 +19,3 @@ class Bard::Provision::MySQL < Bard::Provision
19
19
  end
20
20
  end
21
21
 
22
-
23
-
@@ -6,16 +6,14 @@ class Bard::Provision::Passenger < Bard::Provision
6
6
  if !http_responding?
7
7
  print " Installing nginx & Passenger,"
8
8
  provision_server.run! [
9
- %(echo "\\$nrconf{restart} = \\"a\\";" | sudo tee /etc/needrestart/conf.d/90-autorestart.conf),
10
9
  %(grep -qxF "RAILS_ENV=production" /etc/environment || echo "RAILS_ENV=production" | sudo tee -a /etc/environment),
11
10
  %(grep -qxF "EDITOR=vim" /etc/environment || echo "EDITOR=vim" | sudo tee -a /etc/environment),
12
- "sudo apt-get update -y",
13
- "sudo apt-get upgrade -y",
14
- "sudo apt-get install -y vim dirmngr gnupg apt-transport-https ca-certificates curl",
11
+ "sudo apt-get install -y vim dirmngr gnupg apt-transport-https ca-certificates",
15
12
  "curl https://oss-binaries.phusionpassenger.com/auto-software-signing-gpg-key.txt | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/phusion.gpg >/dev/null",
16
13
  %(echo "deb https://oss-binaries.phusionpassenger.com/apt/passenger jammy main" | sudo tee /etc/apt/sources.list.d/passenger.list),
17
14
  "sudo apt-get update -y",
18
15
  "sudo apt-get install -y nginx libnginx-mod-http-passenger",
16
+ "sudo rm /etc/nginx/sites-enabled/default",
19
17
  ].join("; "), home: true
20
18
  end
21
19
 
@@ -37,9 +37,9 @@ class Bard::Provision::Repo < Bard::Provision
37
37
  github_url = "git@github.com:botandrosedesign/#{project_name}"
38
38
  provision_server.run [
39
39
  "needle=$(ssh-keyscan -t ed25519 github.com 2>/dev/null | cut -d \" \" -f 2-3)",
40
- "grep -q \"$needle\" ~/.ssh/known_hosts || ssh-keyscan -H github.com >> ~/.ssh/known_hosts",
40
+ "grep -q \"$needle\" ~/.ssh/known_hosts || ssh-keyscan -H github.com >> ~/.ssh/known_hosts 2>/dev/null",
41
41
  "git ls-remote #{github_url}",
42
- ].join("; "), home: true
42
+ ].join("; "), home: true, quiet: true
43
43
  end
44
44
 
45
45
  def project_name
@@ -10,8 +10,9 @@ class Bard::Provision::RVM < Bard::Provision
10
10
  "gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB",
11
11
  "curl -sSL https://get.rvm.io | bash -s stable",
12
12
  ].join("; ")
13
- print " Installing Ruby #{File.read(".ruby-version")},"
14
- provision_server.run! "rvm install ."
13
+ version = File.read(".ruby-version").chomp
14
+ print " Installing Ruby #{version},"
15
+ provision_server.run! "rvm install #{version}"
15
16
  end
16
17
 
17
18
  puts " ✓"
@@ -5,16 +5,16 @@ class Bard::Provision::SSH < Bard::Provision
5
5
  def call
6
6
  print "SSH:"
7
7
 
8
- if !ssh_available?(provision_server.ssh_uri, port: server.ssh_uri.port)
8
+ if !ssh_available?(provision_server.ssh_uri, port: target_port)
9
9
  if !ssh_available?(provision_server.ssh_uri)
10
- raise "can't find SSH on port #{server.ssh_uri.port} or #{provision_server.ssh_uri.port}"
10
+ raise "can't find SSH on port #{target_port} or #{provision_server.ssh_uri.port || 22}"
11
11
  end
12
12
  if !ssh_known_host?(provision_server.ssh_uri)
13
13
  print " Adding known host,"
14
14
  add_ssh_known_host!(provision_server.ssh_uri)
15
15
  end
16
- print " Reconfiguring port to #{server.ssh_uri.port},"
17
- provision.server.run! %(echo "Port #{server.ssh_uri.port}" | sudo tee /etc/ssh/sshd_config.d/port_22022.conf; sudo service ssh restart), home: true
16
+ print " Reconfiguring port to #{target_port},"
17
+ provision_server.run! %(echo "Port #{target_port}" | sudo tee /etc/ssh/sshd_config.d/port_#{target_port}.conf; sudo service ssh restart), home: true
18
18
  end
19
19
 
20
20
  if !ssh_known_host?(provision_server.ssh_uri)
@@ -22,23 +22,30 @@ class Bard::Provision::SSH < Bard::Provision
22
22
  add_ssh_known_host!(provision_server.ssh_uri)
23
23
  end
24
24
 
25
- # provision with new port from now on
25
+ # provision with new target port from now on
26
26
  ssh_url.gsub!(/:\d+$/, "")
27
- ssh_url << ":#{server.ssh_uri.port}"
27
+ ssh_url << ":#{target_port}"
28
28
  puts " ✓"
29
29
  end
30
30
 
31
31
  private
32
32
 
33
- def ssh_available? ssh_uri, port: ssh_uri.port
33
+ def target_port
34
+ server.ssh_uri.port || 22
35
+ end
36
+
37
+ def ssh_available? ssh_uri, port: nil
38
+ port ||= ssh_uri.port || 22
34
39
  system "nc -zv #{ssh_uri.host} #{port} 2>/dev/null"
35
40
  end
36
41
 
37
42
  def ssh_known_host? ssh_uri
38
- system "grep -q \"$(ssh-keyscan -t ed25519 -p#{ssh_uri.port || 22} #{ssh_uri.host} 2>/dev/null | cut -d ' ' -f 2-3)\" ~/.ssh/known_hosts"
43
+ port ||= ssh_uri.port || 22
44
+ system "grep -q \"$(ssh-keyscan -t ed25519 -p#{port} #{ssh_uri.host} 2>/dev/null | cut -d ' ' -f 2-3)\" ~/.ssh/known_hosts"
39
45
  end
40
46
 
41
47
  def add_ssh_known_host! ssh_uri
42
- system "ssh-keyscan -p#{ssh_uri.port || 22} -H #{ssh_uri.host} >> ~/.ssh/known_hosts"
48
+ port ||= ssh_uri.port || 22
49
+ system "ssh-keyscan -p#{port} -H #{ssh_uri.host} >> ~/.ssh/known_hosts 2>/dev/null"
43
50
  end
44
51
  end
@@ -16,6 +16,7 @@ class Bard::Provision::User < Bard::Provision
16
16
  "sudo mkdir -p ~#{new_user}/.ssh",
17
17
  "sudo cp ~/.ssh/authorized_keys ~#{new_user}/.ssh/authorized_keys",
18
18
  "sudo chown -R #{new_user}:#{new_user} ~#{new_user}/.ssh",
19
+ "sudo chmod +rx ~#{new_user}", # so nginx and passenger can read it
19
20
  ].join("; "), home: true
20
21
  end
21
22
 
@@ -5,6 +5,7 @@ module Bard
5
5
  def call
6
6
  SSH.call(*values)
7
7
  User.call(*values)
8
+ Apt.call(*values)
8
9
  MySQL.call(*values)
9
10
  Repo.call(*values)
10
11
  MasterKey.call(*values)
@@ -29,12 +30,13 @@ end
29
30
 
30
31
  require "bard/provision/ssh"
31
32
  require "bard/provision/user"
33
+ require "bard/provision/apt"
32
34
  require "bard/provision/mysql"
33
- require "bard/provision/passenger"
34
35
  require "bard/provision/repo"
35
36
  require "bard/provision/master_key"
36
37
  require "bard/provision/rvm"
37
38
  require "bard/provision/app"
39
+ require "bard/provision/passenger"
38
40
  require "bard/provision/data"
39
41
  require "bard/provision/http"
40
42
 
data/lib/bard/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bard
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
@@ -146,6 +146,7 @@ files:
146
146
  - lib/bard/ping.rb
147
147
  - lib/bard/provision.rb
148
148
  - lib/bard/provision/app.rb
149
+ - lib/bard/provision/apt.rb
149
150
  - lib/bard/provision/data.rb
150
151
  - lib/bard/provision/http.rb
151
152
  - lib/bard/provision/master_key.rb