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 ip forwarding flag #115

Merged
merged 4 commits into from Apr 12, 2014
Merged
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 @@ -98,6 +98,7 @@ image_cmd_timeout | image LWRP default cmd_timeout seconds | Fixnum | 300
init_type | Init type for docker ("runit", "systemd", "sysv", or "upstart") | String | auto-detected (see attributes/default.rb)
install_dir | Installation directory for docker binary | String | auto-detected (see attributes/default.rb)
install_type | Installation type for docker ("binary", "package" or "source") | String | "package"
ipv4_forward | Sysctl set net.ipv4.ip_forward to 1 | Boolean | true
logfile | Set custom DOCKER_LOGFILE | String | nil
options | Additional options to pass to docker. These could be flags like "-api-enable-cors". | String | nil
pidfile | Set custom DOCKER_PIDFILE | String | nil
Expand Down
3 changes: 3 additions & 0 deletions attributes/default.rb
Expand Up @@ -73,6 +73,9 @@

default['docker']['version'] = nil

# IP forwarding
default['docker']['ipv4_forward'] = true

# Binary attributes
default['docker']['binary']['version'] = node['docker']['version'] || 'latest'
default['docker']['binary']['url'] = "http://get.docker.io/builds/#{node['kernel']['name']}/#{node['docker']['arch']}/docker-#{node['docker']['binary']['version']}"
Expand Down
2 changes: 1 addition & 1 deletion recipes/default.rb
Expand Up @@ -5,7 +5,7 @@
package 'bsdtar'
sysctl_param 'net.ipv4.ip_forward' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we should also allow IPv6 control as well here. Something like:

if node['platform'] == 'debian'
  sysctl_param 'net.ipv4.ip_forward' do
    value 1
    only_if { node['docker']['ipv4_forward'] }
  end
  sysctl_param 'net.ipv6.conf.all.forwarding' do
    value 1
    only_if { node['docker']['ipv6_forward'] }
  end
end

value 1
only_if { node['platform'] == 'debian' }
only_if { node['platform'] == 'debian' && node['docker']['ipv4_forward'] }
end
end

Expand Down
4 changes: 4 additions & 0 deletions templates/default/docker.service.erb
Expand Up @@ -14,7 +14,11 @@ Environment="HTTP_PROXY=<%= node['docker']['http_proxy'] %>"
<% if node['docker']['tmpdir'] -%>
Environment="TMPDIR=<%= node['docker']['tmpdir'] %>"
<% end -%>
<% if node['docker']['ipv4_forward'] -%>
ExecStartPre=/usr/sbin/sysctl -w net.ipv4.ip_forward=1 net.ipv6.conf.all.forwarding=1
<% else -%>
ExecStartPre=/usr/sbin/sysctl -w net.ipv6.conf.all.forwarding=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you create a second attribute for IPv6? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation detail: IPv4 would be inside its own if/end block while IPv6 would be inside its own if/end block.

<% end -%>
ExecStart=<%= node['docker']['install_dir'] %>/docker -d<%= node['docker']['bind_socket'] ? " -H #{node['docker']['bind_socket']}" : '' %><%= node['docker']['bind_uri'] ? " -H #{node['docker']['bind_uri']}" : '' %><%= node['docker']['container_init_type'] ? ' -r=false' : '' %><%= node['docker']['options'] ? " #{node['docker']['options']}" : '' %><%= node['docker']['storage_driver'] ? " -s #{node['docker']['storage_driver']}" : '' %><%= node['docker']['exec_driver'] ? " -e #{node['docker']['exec_driver']}" : '' %><%= node['docker']['group'] ? " -G #{node['docker']['group']}" : '' %>
Restart=on-failure

Expand Down
2 changes: 2 additions & 0 deletions templates/default/docker.sysv.erb
Expand Up @@ -39,7 +39,9 @@ prestart() {

preexec="/sbin/sysctl"
[ -x $preexec ] || exit 6
<% if node['docker']['ipv4_forward'] -%>
$preexec -w net.ipv4.ip_forward=1 > /dev/null 2>&1
<% end -%>
$preexec -w net.ipv6.conf.all.forwarding=1 > /dev/null 2>&1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use new IPv6 forward attribute to also wrap this in if/end? Thanks!


}
Expand Down