diff --git a/manifests/policyrcd.pp b/manifests/policyrcd.pp new file mode 100644 index 00000000..58329923 --- /dev/null +++ b/manifests/policyrcd.pp @@ -0,0 +1,43 @@ +# +# Copyright (C) 2016 Matthew J. Black +# +# Author: Matthew J. Black +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# == Class: openstacklib::policyrcd +# +# [*services*] +# (required) The services that should be in the policy-rc.d shell script +# that should not autostart on install. +# +class openstacklib::policyrcd( + $services +) { + + validate_array($services) + + if $::osfamily == 'Debian' { + # We put this out there so openstack services wont auto start + # when installed. + file { '/usr/sbin/policy-rc.d': + ensure => present, + content => template('openstacklib/policy-rc.d.erb'), + mode => '0755', + owner => root, + group => root, + } + + File['/usr/sbin/policy-rc.d'] -> Package<| tag == 'openstack' |> + } +} diff --git a/releasenotes/notes/manage_policy_rc_d_file-747510db06792d52.yaml b/releasenotes/notes/manage_policy_rc_d_file-747510db06792d52.yaml new file mode 100644 index 00000000..9db31c71 --- /dev/null +++ b/releasenotes/notes/manage_policy_rc_d_file-747510db06792d52.yaml @@ -0,0 +1,11 @@ +--- +features: + - Add a class that takes an array of services that can be + configured to not autostart on package install. The most + notable example is keystone. The policy-rc.d file is + generated to return the correct exit code to prevent the + services from autostarting on package install. This change + is only meant for debian based systems. +issues: + - ubuntu cloud archive keystone package is auto-starting the + eventlet process on package install. diff --git a/spec/classes/openstacklib_policyrcd_spec.rb b/spec/classes/openstacklib_policyrcd_spec.rb new file mode 100644 index 00000000..88b4baf1 --- /dev/null +++ b/spec/classes/openstacklib_policyrcd_spec.rb @@ -0,0 +1,49 @@ +# +# Copyright (C) 2016 Matthew J. Black +# +# Author: Matthew J. Black +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Unit tests for openstacklib::policyrcd +# +require 'spec_helper' + +describe 'openstacklib::policyrcd' do + + let :params do + { :services => ['keystone'] + } + end + + context 'on Debian platform' do + + let :facts do + { :osfamily => 'Debian' } + end + + describe "with default value" do + + it 'creates policy-rc.d file' do + verify_contents(catalogue, '/usr/sbin/policy-rc.d', [ + '#!/bin/bash', + '', + 'if [ "$1" == "keystone" ]', + 'then', + ' exit 101', + 'fi' + ]) + end + end + end +end diff --git a/templates/policy-rc.d.erb b/templates/policy-rc.d.erb new file mode 100644 index 00000000..ca420a09 --- /dev/null +++ b/templates/policy-rc.d.erb @@ -0,0 +1,8 @@ +#!/bin/bash +<% @services.each do |service| %> +if [ "$1" == "<%= service %>" ] +then + exit 101 +fi +<% end %> +