vagrant-scriptrock 0.0.3 → 0.0.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 +4 -4
- data/lib/vagrant-scriptrock/provisioner.rb +10 -2
- data/lib/vagrant-scriptrock/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: 3882e4771b3636fdab43dc218cc39d194d67c374
|
4
|
+
data.tar.gz: 64e808df145fff2ab3c9a43a271a598f92aeee7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8ffa61cf30d1a2a6ba15d2c78fa2887385bd1221e48ee099d440cfec197587675c5960b7effa335eb8bd7f577e639901172413c9c317d8af1ae7b21b2a8cba6
|
7
|
+
data.tar.gz: 687aa62182cc0bd49f222ae42120e42be29605682ab62825517dd29dcce28004ff7a6ca9a37605556d9287918cdd58d615189305211af30236b3b9d0735ff469
|
@@ -4,6 +4,10 @@ require 'httparty'
|
|
4
4
|
module VagrantPlugins
|
5
5
|
module ScriptRock
|
6
6
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
7
|
+
|
8
|
+
class GuardrailPrivateKeyInstallError < Vagrant::Errors::VagrantError
|
9
|
+
end
|
10
|
+
|
7
11
|
def initialize(machine, config)
|
8
12
|
@debug = false
|
9
13
|
@machine = machine
|
@@ -107,9 +111,13 @@ module VagrantPlugins
|
|
107
111
|
puts "provision provision" if @debug
|
108
112
|
|
109
113
|
# insert the guardrail public key onto the target node if it is not already present
|
114
|
+
puts "Checking for and possibly installing Guardrail public key in ~/.ssh/authorized_keys..."
|
115
|
+
pk = @root_config.scriptrock.ssh_pubkey
|
116
|
+
key_install_script = "mkdir -p ~/.ssh && " +
|
117
|
+
"(grep -q -s '#{pk}' ~/.ssh/authorized_keys || echo '#{pk}' >> ~/.ssh/authorized_keys) && "+
|
118
|
+
"grep -q -s '#{pk}' ~/.ssh/authorized_keys"
|
110
119
|
@machine.communicate.tap do |comm|
|
111
|
-
|
112
|
-
comm.execute("mkdir -p ~/.ssh && grep -q -s '#{pk}' ~/.ssh/authorized_keys || echo '#{pk}' >> ~/.ssh/authorized_keys")
|
120
|
+
comm.execute(key_install_script, error_class: GuardrailPrivateKeyInstallError)
|
113
121
|
end
|
114
122
|
|
115
123
|
# add this node to guardrail if not already present, then update to use the current credentials + forwarded port
|