Skip to content

Commit

Permalink
adding env_vars property and using in systemd
Browse files Browse the repository at this point in the history
Signed-off-by: Sean OMeara <[email protected]>
  • Loading branch information
skylerto authored and someara committed Aug 21, 2017
1 parent ffb6ecd commit 27fd84e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libraries/docker_service_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class DockerServiceBase < DockerBase
# register with the resource resolution system
provides :docker_service_manager

# Environment variables to docker service
property :env_vars, Hash

# daemon management
property :instance, String, name_property: true, required: true, desired_state: false
property :auto_restart, Boolean, default: false
Expand Down
3 changes: 2 additions & 1 deletion libraries/docker_service_manager_systemd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class DockerServiceManagerSystemd < DockerServiceBase
docker_socket: connect_socket,
docker_daemon_cmd: docker_daemon_cmd,
systemd_args: systemd_args,
docker_wait_ready: "#{libexec_dir}/#{docker_name}-wait-ready"
docker_wait_ready: "#{libexec_dir}/#{docker_name}-wait-ready",
env_vars: new_resource.env_vars
)
notifies :run, 'execute[systemctl daemon-reload]', :immediately
notifies :run, "execute[systemctl restart #{docker_name}]", :immediately
Expand Down
3 changes: 3 additions & 0 deletions templates/default/systemd/docker.service-override.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Environment="NO_PROXY=<%= @config.no_proxy %>"
<% if @config.tmpdir %>
Environment="TMPDIR=<%= @config.tmpdir %>"
<% end %>
<% @env_vars.each do |key, val| %>
Environment="<%= key %>=<%= val %>"
<% end unless @env_vars.nil? %>
<% if @config.ipv4_forward %>
ExecStartPre=/sbin/sysctl -w net.ipv4.ip_forward=1
<% end %>
Expand Down

0 comments on commit 27fd84e

Please sign in to comment.