Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added node['docker']['no_proxy'] to complement the existing http_proxy attribute. #221

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -151,6 +151,7 @@ ip | Default IP address to use when binding container ports | String | nil (impl
iptables | Enable Docker's addition of iptables rules | TrueClass, FalseClass | nil (implicitly true)
logfile | Set custom DOCKER_LOGFILE | String | nil
mtu | Set the containers network MTU | Fixnum | nil (implicitly default route MTU or 1500 if no default route is available)
no_proxy | NO_PROXY environment variable | String | nil
options | Additional options to pass to docker. These could be flags like "-api-enable-cors". | String | nil
pidfile | Path to use for daemon PID file | String | nil (implicitly /var/run/docker.pid)
ramdisk | Set DOCKER_RAMDISK when using RAM disk | TrueClass or FalseClass | false
Expand Down
1 change: 1 addition & 0 deletions attributes/default.rb
Expand Up @@ -146,6 +146,7 @@
default['docker']['ip'] = nil
default['docker']['iptables'] = nil
default['docker']['mtu'] = nil
default['docker']['no_proxy'] = nil
default['docker']['options'] = nil
default['docker']['pidfile'] = nil
default['docker']['ramdisk'] = false
Expand Down
13 changes: 13 additions & 0 deletions spec/runit_spec.rb
Expand Up @@ -103,6 +103,19 @@
# end
# end

# context 'when no_proxy is set' do
# let(:chef_run) do
# runner = ChefSpec::Runner.new
# runner.node.set['docker']['no_proxy'] = 'host1.example.com,111.111.111.0/24'
# runner.converge(described_recipe)
# end

# it 'sets NO_PROXY environment variable in docker service' do
# expect(chef_run).to render_file('/etc/sv/docker/run').with_content(
# /^export NO_PROXY=host1.example.com,111.111.111.0\/24$/)
# end
# end

# context 'when options is set' do
# let(:chef_run) do
# runner = ChefSpec::Runner.new
Expand Down
13 changes: 13 additions & 0 deletions spec/systemd_spec.rb
Expand Up @@ -243,6 +243,19 @@
end
end

context 'when no_proxy is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['no_proxy'] = 'host1.example.com,111.111.111.0/24'
runner.converge(described_recipe)
end

it 'sets NO_PROXY environment variable in docker service' do
expect(chef_run).to render_file('/usr/lib/systemd/system/docker.service').with_content(
/^Environment="NO_PROXY=host1.example.com,111.111.111.0\/24"/)
end
end

context 'when icc is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down
13 changes: 13 additions & 0 deletions spec/sysv_spec.rb
Expand Up @@ -254,6 +254,19 @@
end
end

context 'when no_proxy is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['no_proxy'] = 'host1.example.com,111.111.111.0/24'
runner.converge(described_recipe)
end

it 'sets NO_PROXY environment variable in docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
/^export NO_PROXY=host1.example.com,111.111.111.0\/24$/)
end
end

context 'when icc is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down
13 changes: 13 additions & 0 deletions spec/upstart_spec.rb
Expand Up @@ -255,6 +255,19 @@
end
end

context 'when no_proxy is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['no_proxy'] = 'host1.example.com,111.111.111.0/24'
runner.converge(described_recipe)
end

it 'sets NO_PROXY environment variable in docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
/^export NO_PROXY=host1.example.com,111.111.111.0\/24$/)
end
end

context 'when icc is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down
3 changes: 3 additions & 0 deletions templates/default/docker.service.erb
Expand Up @@ -11,6 +11,9 @@ Environment="DOCKER_RAMDISK=<%= node['docker']['ramdisk'] %>"
<% if node['docker']['http_proxy'] -%>
Environment="HTTP_PROXY=<%= node['docker']['http_proxy'] %>"
<% end -%>
<% if node['docker']['no_proxy'] -%>
Environment="NO_PROXY=<%= node['docker']['no_proxy'] %>"
<% end -%>
<% if node['docker']['tmpdir'] -%>
Environment="TMPDIR=<%= node['docker']['tmpdir'] %>"
<% end -%>
Expand Down
3 changes: 3 additions & 0 deletions templates/default/docker.sysconfig.erb
Expand Up @@ -22,6 +22,9 @@ DOCKER_RAMDISK=<%= node['docker']['ramdisk'] %>
<% if node['docker']['http_proxy'] -%>
export HTTP_PROXY=<%= node['docker']['http_proxy'] %>
<% end -%>
<% if node['docker']['no_proxy'] -%>
export NO_PROXY=<%= node['docker']['no_proxy'] %>
<% end -%>

# This is also a handy place to tweak where Docker's temporary files go.
<% if node['docker']['tmpdir'] -%>
Expand Down
3 changes: 3 additions & 0 deletions templates/default/sv-docker-run.erb
Expand Up @@ -6,6 +6,9 @@ export DOCKER_RAMDISK=<%= node['docker']['ramdisk'] %>
<% if node['docker']['http_proxy'] -%>
export HTTP_PROXY=<%= node['docker']['http_proxy'] %>
<% end -%>
<% if node['docker']['no_proxy'] -%>
export NO_PROXY=<%= node['docker']['no_proxy'] %>
<% end -%>
<% if node['docker']['tmpdir'] -%>
export TMPDIR=<%= node['docker']['tmpdir'] %>
<% end -%>
Expand Down