vagrant-proxyconf 2.0.4 → 2.0.10
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/.travis.yml +12 -7
- data/CHANGELOG.md +155 -0
- data/Gemfile +1 -18
- data/Jenkinsfile +60 -0
- data/Makefile +33 -0
- data/README.md +22 -0
- data/deps/patches/lib/vagrant/bundler.rb.patch +14 -0
- data/jenkins/helper_functions +206 -0
- data/lib/vagrant-proxyconf/action/base.rb +20 -9
- data/lib/vagrant-proxyconf/action/configure_docker_proxy.rb +21 -23
- data/lib/vagrant-proxyconf/config/apt_proxy.rb +21 -2
- data/lib/vagrant-proxyconf/version.rb +1 -1
- data/spec/unit/support/shared/apt_proxy_config.rb +12 -0
- data/spec/unit/vagrant-proxyconf/action/configure_docker_proxy_spec.rb +44 -37
- data/spec/unit/vagrant-proxyconf/action/configure_svn_proxy_spec.rb +1 -0
- data/test/issues/172/README.md +2 -2
- data/test/issues/172/spec/docker_host/redhat_spec.rb +2 -2
- data/test/issues/180/spec/docker_host/redhat_spec.rb +2 -2
- data/test/issues/192/.rspec +2 -0
- data/test/issues/192/Dockerfile +47 -0
- data/test/issues/192/Dockerfile.bionic +40 -0
- data/test/issues/192/README.md +29 -0
- data/test/issues/192/Rakefile +27 -0
- data/test/issues/192/Vagrantfile +64 -0
- data/test/issues/192/entrypoint.sh +50 -0
- data/test/issues/192/spec/default/redhat_spec.rb +15 -0
- data/test/issues/192/spec/docker_host/ubuntu_spec.rb +3 -0
- data/test/issues/192/spec/spec_helper.rb +52 -0
- data/test/issues/192/tinyproxy.conf +333 -0
- data/test/issues/199/.rspec +2 -0
- data/test/issues/199/Dockerfile +47 -0
- data/test/issues/199/README.md +31 -0
- data/test/issues/199/Rakefile +27 -0
- data/test/issues/199/Vagrantfile +74 -0
- data/test/issues/199/entrypoint.sh +50 -0
- data/test/issues/199/spec/apt_host/ubuntu_spec.rb +135 -0
- data/test/issues/199/spec/default/redhat_spec.rb +15 -0
- data/test/issues/199/spec/spec_helper.rb +52 -0
- data/test/issues/199/tinyproxy.conf +333 -0
- data/test/issues/218/.rspec +2 -0
- data/test/issues/218/Dockerfile +47 -0
- data/test/issues/218/README.md +35 -0
- data/test/issues/218/Rakefile +27 -0
- data/test/issues/218/Vagrantfile +62 -0
- data/test/issues/218/entrypoint.sh +50 -0
- data/test/issues/218/force-all-outbound-traffic-through-proxy.iptables +18 -0
- data/test/issues/218/spec/default/redhat_spec.rb +16 -0
- data/test/issues/218/spec/docker_host/redhat_spec.rb +171 -0
- data/test/issues/218/spec/spec_helper.rb +43 -0
- data/test/issues/218/tinyproxy.conf +333 -0
- metadata +71 -4
@@ -0,0 +1,47 @@
|
|
1
|
+
FROM centos:7
|
2
|
+
|
3
|
+
ENV CI_USERNAME vagrant
|
4
|
+
ENV CI_PASSWORD vagrant
|
5
|
+
ENV CI_HOMEDIR /home/vagrant
|
6
|
+
ENV CI_SHELL /bin/bash
|
7
|
+
|
8
|
+
EXPOSE 8888
|
9
|
+
|
10
|
+
RUN yum clean all && \
|
11
|
+
yum makecache fast && \
|
12
|
+
yum -y install epel-release && \
|
13
|
+
yum clean expire-cache && \
|
14
|
+
yum -y install \
|
15
|
+
curl \
|
16
|
+
initscripts \
|
17
|
+
openssh-clients \
|
18
|
+
openssh-server \
|
19
|
+
sudo \
|
20
|
+
tinyproxy
|
21
|
+
|
22
|
+
RUN /usr/sbin/sshd-keygen && \
|
23
|
+
mkdir -p /var/run/sshd && \
|
24
|
+
rm -f /usr/lib/tmpfiles.d/systemd-nologin.conf
|
25
|
+
|
26
|
+
RUN if ! getent passwd $CI_USERNAME; then \
|
27
|
+
useradd -m -d ${CI_HOMEDIR} -s ${CI_SHELL} $CI_USERNAME; \
|
28
|
+
fi && \
|
29
|
+
echo "${CI_USERNAME}:${CI_PASSWORD}" | chpasswd && \
|
30
|
+
echo "${CI_USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && \
|
31
|
+
mkdir -p /etc/sudoers.d && \
|
32
|
+
echo "${CI_USERNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/${CI_USERNAME} && \
|
33
|
+
chmod 0440 /etc/sudoers.d/${CI_USERNAME} && \
|
34
|
+
mkdir -p ${CI_HOMEDIR}/.ssh && \
|
35
|
+
chown -R ${CI_USERNAME}:${CI_USERNAME} ${CI_HOMEDIR}/.ssh && \
|
36
|
+
chmod 0700 ${CI_HOMEDIR}/.ssh && \
|
37
|
+
curl -L https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub > ${CI_HOMEDIR}/.ssh/vagrant.pub && \
|
38
|
+
touch ${CI_HOMEDIR}/.ssh/authorized_keys && \
|
39
|
+
grep -q "$(cat ${CI_HOMEDIR}/.ssh/vagrant.pub | awk '{print $2}')" ${CI_HOMEDIR}/.ssh/authorized_keys || cat ${CI_HOMEDIR}/.ssh/vagrant.pub >> ${CI_HOMEDIR}/.ssh/authorized_keys && \
|
40
|
+
chown ${CI_USERNAME}:${CI_USERNAME} ${CI_HOMEDIR}/.ssh/authorized_keys && \
|
41
|
+
chmod 0600 ${CI_HOMEDIR}/.ssh/authorized_keys
|
42
|
+
|
43
|
+
COPY tinyproxy.conf /etc/tinyproxy/tinyproxy.conf
|
44
|
+
COPY entrypoint.sh /entrypoint.sh
|
45
|
+
|
46
|
+
ENTRYPOINT ["/entrypoint.sh"]
|
47
|
+
CMD [ "start" ]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Tests
|
2
|
+
-----
|
3
|
+
|
4
|
+
|
5
|
+
Lined to github issue [#218](https://github.com/tmatilai/vagrant-proxyconf/issues/218)
|
6
|
+
|
7
|
+
|
8
|
+
If you are testing the current release of this plugin via bundler
|
9
|
+
|
10
|
+
```
|
11
|
+
bundle exec vagrant up default
|
12
|
+
```
|
13
|
+
|
14
|
+
## Expect
|
15
|
+
|
16
|
+
|
17
|
+
### Box `default``
|
18
|
+
|
19
|
+
- The box `default` is a docker container that will be a reverse
|
20
|
+
proxy. It should provision itself and work without errors.
|
21
|
+
|
22
|
+
- You can check that the proxy is working by
|
23
|
+
`tail -f /var/log/tinyproxy/tinyproxy.log` inside the container
|
24
|
+
|
25
|
+
- **NOTE**: You'll need to use `docker exec <hash> -it bash` to get into the container
|
26
|
+
|
27
|
+
|
28
|
+
### Box `docker-host`
|
29
|
+
|
30
|
+
- Vagrant should automatically instally docker-ce.
|
31
|
+
- The box should come up and provision itself with the proxy settings
|
32
|
+
configured in your Vagrantfile.
|
33
|
+
|
34
|
+
|
35
|
+
- **NOTE**: You can use `ssh` to connect to this container.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
task :spec => 'spec:all'
|
5
|
+
task :default => :spec
|
6
|
+
|
7
|
+
namespace :spec do
|
8
|
+
targets = []
|
9
|
+
Dir.glob('./spec/*').each do |dir|
|
10
|
+
next unless File.directory?(dir)
|
11
|
+
target = File.basename(dir)
|
12
|
+
target = "_#{target}" if target == "default"
|
13
|
+
targets << target
|
14
|
+
end
|
15
|
+
|
16
|
+
task :all => targets
|
17
|
+
task :default => :all
|
18
|
+
|
19
|
+
targets.each do |target|
|
20
|
+
original_target = target == "_default" ? target[1..-1] : target
|
21
|
+
desc "Run serverspec tests to #{original_target}"
|
22
|
+
RSpec::Core::RakeTask.new(target.to_sym) do |t|
|
23
|
+
ENV['TARGET_HOST'] = original_target
|
24
|
+
t.pattern = "spec/#{original_target}/*_spec.rb"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# this should be the IP address of the :default box
|
2
|
+
$PROXY_HOST ="10.0.2.2"
|
3
|
+
$PROXY_PORT="8888"
|
4
|
+
$PROXY_NO_PROXY=[
|
5
|
+
'localhost',
|
6
|
+
]
|
7
|
+
|
8
|
+
ENV['HTTP_PROXY'] = ENV.fetch('HTTP_PROXY', "http://#{$PROXY_HOST}:#{$PROXY_PORT}")
|
9
|
+
ENV['HTTPS_PROXY'] = ENV.fetch('HTTPS_PROXY', "http://#{$PROXY_HOST}:#{$PROXY_PORT}")
|
10
|
+
ENV['NO_PROXY'] = ENV.fetch('NO_PROXY', $PROXY_NO_PROXY.join(","))
|
11
|
+
|
12
|
+
puts "HTTP_PROXY = '#{ENV["HTTP_PROXY"]}'"
|
13
|
+
puts "HTTPS_PROXY = '#{ENV["HTTPS_PROXY"]}'"
|
14
|
+
puts "NO_PROXY = '#{ENV["NO_PROXY"]}'"
|
15
|
+
|
16
|
+
puts "is vagrant-proxyconf installed? #{Vagrant.has_plugin?('vagrant-proxyconf')}"
|
17
|
+
|
18
|
+
Vagrant.configure("2") do |config|
|
19
|
+
|
20
|
+
config.vm.define 'default' do |c|
|
21
|
+
c.vm.box = nil
|
22
|
+
|
23
|
+
if Vagrant.has_plugin?('vagrant-proxyconf')
|
24
|
+
c.proxy.enabled = false
|
25
|
+
end
|
26
|
+
|
27
|
+
c.vm.provider "docker" do |d|
|
28
|
+
d.build_dir = "."
|
29
|
+
d.expose = ['8888']
|
30
|
+
d.has_ssh = true
|
31
|
+
d.ports = ['8888:8888']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
config.vm.define 'docker_host' do |c|
|
36
|
+
c.vm.box = "centos/7"
|
37
|
+
c.vm.box_check_update = false
|
38
|
+
|
39
|
+
if Vagrant.has_plugin?('vagrant-proxyconf')
|
40
|
+
c.proxy.http = ENV['HTTP_PROXY']
|
41
|
+
c.proxy.https = ENV['HTTPS_PROXY']
|
42
|
+
c.proxy.no_proxy = ENV['NO_PROXY']
|
43
|
+
end
|
44
|
+
|
45
|
+
c.vm.provision "shell", path: "force-all-outbound-traffic-through-proxy.iptables"
|
46
|
+
|
47
|
+
if Vagrant.has_plugin?('vagrant-vbguest')
|
48
|
+
c.vbguest.auto_update = false
|
49
|
+
c.vbguest.auto_reboot = true
|
50
|
+
end
|
51
|
+
|
52
|
+
c.vm.provision "docker"
|
53
|
+
|
54
|
+
c.vm.synced_folder ".", "/vagrant",
|
55
|
+
disabled: false,
|
56
|
+
type: "sshfs",
|
57
|
+
ssh_opts_append: "-o Compression=yes -o ControlPersist=60s -o ControlMaster=auto",
|
58
|
+
sshfs_opts_append: "-o cache=no -o nonempty"
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -ex
|
3
|
+
|
4
|
+
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
5
|
+
|
6
|
+
start() {
|
7
|
+
# start ssh if sshd is installed
|
8
|
+
if [ -f /usr/sbin/sshd ]; then
|
9
|
+
|
10
|
+
/usr/sbin/sshd-keygen
|
11
|
+
/usr/sbin/sshd -t
|
12
|
+
/usr/sbin/sshd
|
13
|
+
|
14
|
+
else
|
15
|
+
|
16
|
+
true
|
17
|
+
|
18
|
+
fi
|
19
|
+
|
20
|
+
# start tinyproxy
|
21
|
+
/usr/sbin/tinyproxy \
|
22
|
+
-d \
|
23
|
+
-c "/etc/tinyproxy/tinyproxy.conf"
|
24
|
+
}
|
25
|
+
|
26
|
+
stop() {
|
27
|
+
|
28
|
+
pgrep -f 'sshd' | while read _pid
|
29
|
+
do
|
30
|
+
kill -9 $_pid
|
31
|
+
done
|
32
|
+
|
33
|
+
pgrep -f 'tinyproxy' | while read _pid
|
34
|
+
do
|
35
|
+
kill -9 $_pid
|
36
|
+
done
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
case "${1}" in
|
41
|
+
|
42
|
+
start)
|
43
|
+
start
|
44
|
+
;;
|
45
|
+
|
46
|
+
stop)
|
47
|
+
stop
|
48
|
+
;;
|
49
|
+
|
50
|
+
esac
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -ex
|
3
|
+
|
4
|
+
# OUTPUT:IN= OUT=eth0 SRC=10.0.2.15 DST=10.0.2.2 LEN=40 TOS=0x00 PREC=0x00 TTL=64 ID=61920 DF PROTO=TCP SPT=59780 DPT=8888 WINDOW=65535 RES=0x00 ACK URGP=0
|
5
|
+
# OUTPUT:IN= OUT=eth0 SRC=10.0.2.15 DST=10.0.2.2 LEN=84 TOS=0x10 PREC=0x00 TTL=64 ID=22073 DF PROTO=TCP SPT=22 DPT=55694 WINDOW=47600 RES=0x00 ACK PSH URGP=0
|
6
|
+
# OUTPUT:IN= OUT=eth0 SRC=10.0.2.15 DST=10.0.2.3 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=30731 PROTO=UDP SPT=45910 DPT=53 LEN=40
|
7
|
+
|
8
|
+
iptables -F OUTPUT
|
9
|
+
iptables -Z OUTPUT
|
10
|
+
|
11
|
+
iptables -A OUTPUT -d 10.0.2.2 -p tcp -m tcp --dport 8888 -j ACCEPT
|
12
|
+
iptables -A OUTPUT -p tcp -m tcp --sport 22 -j ACCEPT
|
13
|
+
iptables -A OUTPUT -p udp -m udp --dport 53 -j ACCEPT
|
14
|
+
iptables -A OUTPUT -p udp -m udp --dport 123 -j ACCEPT
|
15
|
+
|
16
|
+
iptables -A OUTPUT -j LOG --log-prefix 'OUTPUT:DROPPED '
|
17
|
+
|
18
|
+
iptables -P OUTPUT DROP
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe package('tinyproxy') do
|
4
|
+
it { should be_installed }
|
5
|
+
end
|
6
|
+
|
7
|
+
describe service('tinyproxy') do
|
8
|
+
it { should be_enabled }
|
9
|
+
it { should be_running }
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
describe port(8888) do
|
14
|
+
it { should be_listening }
|
15
|
+
it { should be_listening.on('0.0.0.0').with('tcp') }
|
16
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
PROXY_HOST = "10.0.2.2"
|
4
|
+
|
5
|
+
describe service('docker') do
|
6
|
+
it { should be_running }
|
7
|
+
it { should be_enabled }
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
describe file('/etc/docker/config.json') do
|
12
|
+
it { should_not be_file }
|
13
|
+
it { should_not exist }
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
describe file('/home/vagrant/.docker/config.json') do
|
18
|
+
it { should be_file }
|
19
|
+
it { should exist }
|
20
|
+
it { should be_mode 644 }
|
21
|
+
it { should be_owned_by "vagrant" }
|
22
|
+
it { should be_grouped_into "docker" }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when proxy is enabled' do
|
26
|
+
before(:context) do
|
27
|
+
ENV['HTTP_PROXY'] = "http://#{PROXY_HOST}:8888"
|
28
|
+
ENV['HTTPS_PROXY'] = "http://#{PROXY_HOST}:8888"
|
29
|
+
ENV['NO_PROXY'] = "*.example.com"
|
30
|
+
|
31
|
+
`vagrant provision #{ENV['TARGET_HOST']}`
|
32
|
+
`sleep 3`
|
33
|
+
end
|
34
|
+
|
35
|
+
describe file('/home/vagrant/.docker/config.json') do
|
36
|
+
let(:expected_content) do
|
37
|
+
{
|
38
|
+
"proxies" => {
|
39
|
+
"default" => {
|
40
|
+
"httpProxy" => "http://10.0.2.2:8888",
|
41
|
+
"httpsProxy" => "http://10.0.2.2:8888",
|
42
|
+
"noProxy" => "*.example.com",
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
its(:content_as_json) do
|
49
|
+
should include(expected_content)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when HTTP_PROXY=""' do
|
56
|
+
|
57
|
+
before(:context) do
|
58
|
+
ENV['HTTP_PROXY'] = ""
|
59
|
+
ENV['HTTPS_PROXY'] = "https://#{PROXY_HOST}:8888"
|
60
|
+
ENV['NO_PROXY'] = "*.example.com"
|
61
|
+
|
62
|
+
`vagrant provision #{ENV['TARGET_HOST']}`
|
63
|
+
`sleep 3`
|
64
|
+
end
|
65
|
+
|
66
|
+
describe file('/home/vagrant/.docker/config.json') do
|
67
|
+
let(:expected_content) do
|
68
|
+
{
|
69
|
+
"proxies" => {
|
70
|
+
"default" => {
|
71
|
+
"httpsProxy" => "https://#{PROXY_HOST}:8888",
|
72
|
+
"noProxy" => "*.example.com",
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
its(:content_as_json) do
|
79
|
+
should include(expected_content)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when HTTPS_PROXY=""' do
|
86
|
+
|
87
|
+
before(:context) do
|
88
|
+
ENV['HTTP_PROXY'] = "http://#{PROXY_HOST}:8888"
|
89
|
+
ENV['HTTPS_PROXY'] = ""
|
90
|
+
ENV['NO_PROXY'] = "*.example.com"
|
91
|
+
|
92
|
+
`vagrant provision #{ENV['TARGET_HOST']}`
|
93
|
+
end
|
94
|
+
|
95
|
+
describe file('/home/vagrant/.docker/config.json') do
|
96
|
+
let(:expected_content) do
|
97
|
+
{
|
98
|
+
"proxies" => {
|
99
|
+
"default" => {
|
100
|
+
"httpProxy" => "http://#{PROXY_HOST}:8888",
|
101
|
+
"noProxy" => "*.example.com",
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
its(:content_as_json) do
|
108
|
+
should include(expected_content)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when HTTPS_PROXY="" and HTTP_PROXY=""' do
|
115
|
+
|
116
|
+
before(:context) do
|
117
|
+
ENV['HTTP_PROXY'] = ""
|
118
|
+
ENV['HTTPS_PROXY'] = ""
|
119
|
+
ENV['NO_PROXY'] = "*.example.com"
|
120
|
+
|
121
|
+
`vagrant provision #{ENV['TARGET_HOST']}`
|
122
|
+
`sleep 3`
|
123
|
+
end
|
124
|
+
|
125
|
+
describe file('/home/vagrant/.docker/config.json') do
|
126
|
+
let(:expected_content) do
|
127
|
+
{
|
128
|
+
"proxies" => {
|
129
|
+
"default" => {
|
130
|
+
"noProxy" => "*.example.com",
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
end
|
135
|
+
|
136
|
+
its(:content_as_json) do
|
137
|
+
should include(expected_content)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'when NO_PROXY=""' do
|
144
|
+
|
145
|
+
before(:context) do
|
146
|
+
ENV['HTTP_PROXY'] = "http://#{PROXY_HOST}:8888"
|
147
|
+
ENV['HTTPS_PROXY'] = "https://#{PROXY_HOST}:8888"
|
148
|
+
ENV['NO_PROXY'] = ""
|
149
|
+
|
150
|
+
`vagrant provision #{ENV['TARGET_HOST']}`
|
151
|
+
`sleep 3`
|
152
|
+
end
|
153
|
+
|
154
|
+
describe file('/home/vagrant/.docker/config.json') do
|
155
|
+
let(:expected_content) do
|
156
|
+
{
|
157
|
+
"proxies" => {
|
158
|
+
"default" => {
|
159
|
+
"httpProxy" => "http://#{PROXY_HOST}:8888",
|
160
|
+
"httpsProxy" => "https://#{PROXY_HOST}:8888",
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
end
|
165
|
+
|
166
|
+
its(:content_as_json) do
|
167
|
+
should include(expected_content)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'serverspec'
|
2
|
+
require 'net/ssh'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
set :backend, :ssh
|
6
|
+
|
7
|
+
if ENV['ASK_SUDO_PASSWORD']
|
8
|
+
begin
|
9
|
+
require 'highline/import'
|
10
|
+
rescue LoadError
|
11
|
+
fail "highline is not available. Try installing it."
|
12
|
+
end
|
13
|
+
set :sudo_password, ask("Enter sudo password: ") { |q| q.echo = false }
|
14
|
+
else
|
15
|
+
set :sudo_password, ENV['SUDO_PASSWORD'] || "vagrant"
|
16
|
+
end
|
17
|
+
|
18
|
+
host = ENV['TARGET_HOST']
|
19
|
+
|
20
|
+
`vagrant up #{host}`
|
21
|
+
|
22
|
+
config = Tempfile.new('', Dir.tmpdir)
|
23
|
+
config.write(`vagrant ssh-config #{host}`)
|
24
|
+
config.close
|
25
|
+
|
26
|
+
options = Net::SSH::Config.for(host, [config.path])
|
27
|
+
|
28
|
+
options[:user] ||= Etc.getlogin
|
29
|
+
|
30
|
+
set :host, options[:host_name] || host
|
31
|
+
set :ssh_options, options
|
32
|
+
|
33
|
+
# Disable sudo
|
34
|
+
# set :disable_sudo, true
|
35
|
+
|
36
|
+
|
37
|
+
# Set environment variables
|
38
|
+
set :env,
|
39
|
+
:LANG => 'C',
|
40
|
+
:LC_MESSAGES => 'C'
|
41
|
+
|
42
|
+
# Set PATH
|
43
|
+
# set :path, '/sbin:/usr/local/sbin:$PATH'
|