diff --git a/.fixtures.yml b/.fixtures.yml index 9090d28b9..4014e8e32 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,10 +1,14 @@ fixtures: - forge_modules: - stdlib: 'puppetlabs-stdlib' - epel: 'stahnma-epel' +# forge_modules: +# - 'puppetlabs-stdlib' +# - 'stahnma-epel' repositories: apt: - repo: git://github.com/puppetlabs/puppetlabs-apt.git + repo: https://github.com/puppetlabs/puppetlabs-apt.git ref: 2.1.0 + puppetlabs-stdlib: + repo: https://github.com/puppetlabs/puppetlabs-stdlib + epel: + repo: https://github.com/stahnma/puppet-module-epel symlinks: docker: "#{source_dir}" diff --git a/lib/facter/dockerd_binary.rb b/lib/facter/dockerd_binary.rb new file mode 100644 index 000000000..806cfea8f --- /dev/null +++ b/lib/facter/dockerd_binary.rb @@ -0,0 +1,5 @@ +Facter.add(:dockerd_binary) do + setcode do + Facter::Core::Execution.which('dockerd') + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bf973048d..8fa3e8a0a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,9 @@ require 'puppetlabs_spec_helper/module_spec_helper' +RSpec.configure do |config| + config.mock_with :rspec +end + RSpec::Matchers.define :require_string_for do |property| match do |type_class| config = {:name => 'name'} diff --git a/spec/unit/dockerd_daemon_spec.rb b/spec/unit/dockerd_daemon_spec.rb new file mode 100644 index 000000000..1f647077f --- /dev/null +++ b/spec/unit/dockerd_daemon_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe 'dockerd_binary fact' do + + before :each do + Facter.clear + end + + context 'when the dockerd binary is NOT present' do + + before :each do + Facter.fact(:dockerd_binary).stubs(:value).returns(nil) + end + + it 'return nil' do + expect(Facter.fact(:dockerd_binary).value).to be_nil + end + end + + context 'when the dockerd binary is installed' do + + before :each do + Facter.fact(:dockerd_binary).stubs(:value).returns('/some/path/to/dockerd') + end + + it 'return the full path to the dockerd binary' do + expect(Facter.fact(:dockerd_binary).value).to eq('/some/path/to/dockerd') + end + end +end diff --git a/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb b/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb index e56dabd72..e79c8efab 100644 --- a/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb +++ b/templates/etc/systemd/system/docker.service.d/service-overrides-debian.conf.erb @@ -2,5 +2,9 @@ EnvironmentFile=-/etc/default/docker EnvironmentFile=-/etc/default/docker-storage ExecStart= +<% unless @dockerd_binary -%> ExecStart=/usr/bin/<%= @docker_command %> <%= @daemon_subcommand %> $OPTIONS \ $DOCKER_STORAGE_OPTIONS +<% end -%> +ExecStart=<%= @dockerd_binary %> $OPTIONS \ + $DOCKER_STORAGE_OPTIONS diff --git a/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb b/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb index 3d367e9cf..56956dbed 100644 --- a/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb +++ b/templates/etc/systemd/system/docker.service.d/service-overrides-rhel.conf.erb @@ -5,8 +5,15 @@ EnvironmentFile=-/etc/sysconfig/docker-network <% if @daemon_environment_files %><% @daemon_environment_files.each do |param| %>EnvironmentFile=-<%= param %> <% end %><% end -%> ExecStart= +<% unless @dockerd_binary -%> ExecStart=/usr/bin/<%= @docker_command %> <%= @daemon_subcommand %> $OPTIONS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ $BLOCK_REGISTRY \ $INSECURE_REGISTRY +<% end -%> +ExecStart=<%= @dockerd_binary %> $OPTIONS \ + $DOCKER_STORAGE_OPTIONS \ + $DOCKER_NETWORK_OPTIONS \ + $BLOCK_REGISTRY \ + $INSECURE_REGISTRY