Added policy-rc.d class.
On debian os family systems the methodology is to start services when installed. This causes a problem with keystone sometimes at random in CI jobs. Change-Id: Id0b38743a9bf536f69d155e1d6e664a5585e5e1d
This commit is contained in:
43
manifests/policyrcd.pp
Normal file
43
manifests/policyrcd.pp
Normal file
@@ -0,0 +1,43 @@
|
||||
#
|
||||
# Copyright (C) 2016 Matthew J. Black
|
||||
#
|
||||
# Author: Matthew J. Black <mjblack@gmail.com>
|
||||
#
|
||||
# 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' |>
|
||||
}
|
||||
}
|
@@ -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.
|
57
spec/classes/openstacklib_policyrcd_spec.rb
Normal file
57
spec/classes/openstacklib_policyrcd_spec.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Copyright (C) 2016 Matthew J. Black
|
||||
#
|
||||
# Author: Matthew J. Black <mjblack@gmail.com>
|
||||
#
|
||||
# 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
|
||||
|
||||
let :test_facts do
|
||||
{ :operatingsystem => 'default',
|
||||
:operatingsystemrelease => 'default'
|
||||
}
|
||||
end
|
||||
|
||||
context 'on Debian platform' do
|
||||
|
||||
let :facts do
|
||||
@default_facts.merge(test_facts.merge(
|
||||
{ :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
|
8
templates/policy-rc.d.erb
Normal file
8
templates/policy-rc.d.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
<% @services.each do |service| %>
|
||||
if [ "$1" == "<%= service %>" ]
|
||||
then
|
||||
exit 101
|
||||
fi
|
||||
<% end %>
|
||||
|
Reference in New Issue
Block a user