diff --git a/deployment/puppet/galera/manifests/init.pp b/deployment/puppet/galera/manifests/init.pp index 736bed53c1..5da0a3a275 100644 --- a/deployment/puppet/galera/manifests/init.pp +++ b/deployment/puppet/galera/manifests/init.pp @@ -118,14 +118,6 @@ class galera ( } if ($use_percona and $::operatingsystem == 'Ubuntu') { - # Disable service autostart - file { '/usr/sbin/policy-rc.d': - ensure => present, - content => inline_template("#!/bin/sh\nexit 101\n"), - mode => '0755', - before => Package['MySQL-server'] - } - #FIXME: #Remove this after https://bugs.launchpad.net/bugs/1461304 will be fixed file {'/etc/apt/apt.conf.d/99tmp': @@ -305,14 +297,9 @@ class galera ( if ($use_percona and $::operatingsystem == 'Ubuntu') { #Clean tmp files: - exec { 'rm-policy-rc.d': - command => '/bin/rm /usr/sbin/policy-rc.d', - } exec {'rm-99tmp': command => '/bin/rm /etc/apt/apt.conf.d/99tmp', } - Exec['wait-for-synced-state'] -> - Exec['rm-policy-rc.d'] Exec['wait-for-synced-state'] -> Exec['rm-99tmp'] } @@ -321,7 +308,7 @@ class galera ( Service['mysql'] -> Exec['wait-initial-sync'] -> Exec['wait-for-synced-state'] -> - Exec ['rm-init-file'] + Exec['rm-init-file'] Package['MySQL-server'] ~> Exec['wait-initial-sync'] anchor {'database-cluster-done': } diff --git a/deployment/puppet/galera/spec/shared-examples.rb b/deployment/puppet/galera/spec/shared-examples.rb index c4cfc1f5a8..9af998e358 100644 --- a/deployment/puppet/galera/spec/shared-examples.rb +++ b/deployment/puppet/galera/spec/shared-examples.rb @@ -41,7 +41,6 @@ shared_examples 'test-files' do |params| should contain_file('/etc/mysql/conf.d/wsrep.cnf') should contain_file('/tmp/wsrep-init-file') if params[:use_percona_packages] and facts[:operatingsystem] == 'Ubuntu' - should contain_file('/usr/sbin/policy-rc.d') should contain_file('/etc/apt/apt.conf.d/99tmp') end } diff --git a/deployment/puppet/galera/spec/unit/classes/init_spec.rb b/deployment/puppet/galera/spec/unit/classes/init_spec.rb index 255df2d6f4..f7dc454bfb 100644 --- a/deployment/puppet/galera/spec/unit/classes/init_spec.rb +++ b/deployment/puppet/galera/spec/unit/classes/init_spec.rb @@ -34,7 +34,6 @@ describe 'galera', :type => :class do # the package installation on Ubuntu let(:params) { p } it { - should contain_exec('rm-policy-rc.d') should contain_exec('rm-99tmp') } end @@ -59,7 +58,6 @@ describe 'galera', :type => :class do # the package installation on Ubuntu let(:params) { p } it { - should contain_exec('rm-policy-rc.d') should contain_exec('rm-99tmp') } end diff --git a/deployment/puppet/tweaks/.fixtures.yml b/deployment/puppet/tweaks/.fixtures.yml index 0bca348d61..0119c57693 100644 --- a/deployment/puppet/tweaks/.fixtures.yml +++ b/deployment/puppet/tweaks/.fixtures.yml @@ -1,3 +1,5 @@ fixtures: + forge_modules: + stdlib: "puppetlabs/stdlib" symlinks: - 'tweaks': "#{source_dir}" + tweaks: "#{source_dir}" diff --git a/deployment/puppet/tweaks/manifests/ubuntu_service_override.pp b/deployment/puppet/tweaks/manifests/ubuntu_service_override.pp index f51c1e9391..4764bee359 100644 --- a/deployment/puppet/tweaks/manifests/ubuntu_service_override.pp +++ b/deployment/puppet/tweaks/manifests/ubuntu_service_override.pp @@ -1,32 +1,57 @@ +# == Type: tweaks::ubuntu_service_override +# +# Disable services from starting when the package is installed on Ubuntu OS +# +# == Parameters +# +# [*service_name*] +# The name of the service that is associated with the package being installed. +# Defaults to $name +# +# [*package_name*] +# The name of the package that is being installed that has a service to be +# prevented from being started as part of the installation process. +# Defaults to $name +# define tweaks::ubuntu_service_override ( $service_name = $name, $package_name = $name, ) { if $::operatingsystem == 'Ubuntu' { - $override_file = "/etc/init/${service_name}.override" - $file_name = "create_${service_name}_override" - $exec_name = "remove_${service_name}_override" - if ! is_pkg_installed($package_name) { - file { $file_name : + # https://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt + # use policy-rc.d to really ensure services don't get started on + # installation as service override files are only used if a job + # configuration file exists (see man 5 init) + $policyrc_file = '/usr/sbin/policy-rc.d' + + # use ensure resource as we only want a single instance of the + # policy-rc.d file in the catalog + ensure_resource('file', 'create-policy-rc.d', { ensure => present, - path => $override_file, - content => 'manual', - mode => '0644', + path => $policyrc_file, + content => "#!/bin/bash\nexit 101", + mode => '0755', owner => 'root', - group => 'root', - } - - exec { $exec_name : + group => 'root' + }) + # use ensure resource as we only want a single remove exec in the catalog + ensure_resource('exec', 'remove-policy-rc.d', { path => [ '/sbin', '/bin', '/usr/bin', '/usr/sbin' ], - command => "rm -f ${override_file}", - onlyif => "test -f ${override_file}", - } + command => "rm -f ${policyrc_file}", + onlyif => "test -f ${policyrc_file}", + }) - File[$file_name] -> Package <| name == $package_name |> -> Exec[$exec_name] - File[$file_name] -> Package <| title == $package_name |> -> Exec[$exec_name] - Exec[$exec_name] -> Service <| name == $service_name |> - Exec[$exec_name] -> Service <| title == $service_name |> + File['create-policy-rc.d'] -> + Package <| name == $package_name |> -> + Exec['remove-policy-rc.d'] + File['create-policy-rc.d'] -> + Package <| title == $package_name |> -> + Exec['remove-policy-rc.d'] + Exec['remove-policy-rc.d'] -> + Service <| name == $service_name |> + Exec['remove-policy-rc.d'] -> + Service <| title == $service_name |> } } } diff --git a/deployment/puppet/tweaks/spec/defines/tweaks_ubuntu_service_override_spec.rb b/deployment/puppet/tweaks/spec/defines/tweaks_ubuntu_service_override_spec.rb index f41995eff5..f58cf407c9 100644 --- a/deployment/puppet/tweaks/spec/defines/tweaks_ubuntu_service_override_spec.rb +++ b/deployment/puppet/tweaks/spec/defines/tweaks_ubuntu_service_override_spec.rb @@ -22,13 +22,19 @@ describe 'tweaks::ubuntu_service_override' do it 'configures with the default params' do should contain_tweaks__ubuntu_service_override(title) if facts[:operatingsystem] == 'Ubuntu' - should contain_file("create_#{params[:service_name]}_override").with( - :path => "/etc/init/#{title}.override") - should contain_exec("remove_#{params[:service_name]}_override") + should contain_file('create-policy-rc.d').with( + :ensure => 'present', + :path => '/usr/sbin/policy-rc.d', + :content => "#!/bin/bash\nexit 101", + :mode => '0755', + :owner => 'root', + :group => 'root') + should contain_exec('remove-policy-rc.d').with( + :command => 'rm -f /usr/sbin/policy-rc.d', + :onlyif => 'test -f /usr/sbin/policy-rc.d') else - should_not contain_file("create_#{params[:service_name]}_override").with( - :path => "/etc/init.d/#{title}.override") - should_not contain_exec("remove_#{params[:service_name]}_override") + should_not contain_file('create-policy-rc.d') + should_not contain_exec('remove-policy-rc.d') end end end