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 +4 -4
- data/lib/bard/provision/apt.rb +16 -0
- data/lib/bard/provision/http.rb +1 -15
- data/lib/bard/provision/mysql.rb +0 -2
- data/lib/bard/provision/passenger.rb +2 -4
- data/lib/bard/provision/repo.rb +2 -2
- data/lib/bard/provision/rvm.rb +3 -2
- data/lib/bard/provision/ssh.rb +16 -9
- data/lib/bard/provision/user.rb +1 -0
- data/lib/bard/provision.rb +3 -1
- data/lib/bard/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf24b5fc8c53912b9568bbba566570d1883ab489e7d72dd01869dd1efcdcea8e
|
4
|
+
data.tar.gz: 2b069ea15ef1dbc21beccd0c909eedae482909c1a4a3a22fe7eb2e88d765118d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
|
data/lib/bard/provision/http.rb
CHANGED
@@ -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
|
|
data/lib/bard/provision/mysql.rb
CHANGED
@@ -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
|
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
|
|
data/lib/bard/provision/repo.rb
CHANGED
@@ -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
|
data/lib/bard/provision/rvm.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
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 " ✓"
|
data/lib/bard/provision/ssh.rb
CHANGED
@@ -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:
|
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 #{
|
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 #{
|
17
|
-
|
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 << ":#{
|
27
|
+
ssh_url << ":#{target_port}"
|
28
28
|
puts " ✓"
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
-
def
|
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
|
-
|
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
|
-
|
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
|
data/lib/bard/provision/user.rb
CHANGED
@@ -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
|
|
data/lib/bard/provision.rb
CHANGED
@@ -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
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.
|
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
|