Fix Ironic modules so services properly run in Juno

Initially, the module was not creating an ironic.conf file and now
it does.  The configurations that are being put into the ironic.conf
file come straight out of the documentation.

The package 'python-pbr' is required and was not being installed
elsewhere so it is installed by the init module.

The ironic-conductor service requires the execution of 'ironic-dbsync'
before it can be active.

In the params module, the 'RedHat' packages and services were named
incorrectly or were otherwise missing.

Change-Id: I73cecc590038fa7d9518453c448bfc243ddedff1
This commit is contained in:
Ryan Hallisey 2014-11-12 15:09:31 -05:00
parent a34629f956
commit a7ed4f4b4b
6 changed files with 77 additions and 33 deletions

View File

@ -31,7 +31,7 @@ $glance_api_servers = 'glance:9292'
$deploy_kernel = 'glance://deploy_kernel_uuid' $deploy_kernel = 'glance://deploy_kernel_uuid'
$deploy_ramdisk = 'glance://deploy_ramdisk_uuid' $deploy_ramdisk = 'glance://deploy_ramdisk_uuid'
node db { node 'db' {
class { 'mysql::server': class { 'mysql::server':
config_hash => { config_hash => {

View File

@ -68,9 +68,20 @@
# (optional) The name of the user to create in keystone for use by the ironic services # (optional) The name of the user to create in keystone for use by the ironic services
# Defaults to 'ironic' # Defaults to 'ironic'
# #
# [*neutron_url*]
# (optional) The Neutron URL to be used for requests from ironic
# Defaults to false
#
# [*admin_password*] # [*admin_password*]
# (required) The password to set for the ironic admin user in keystone # (required) The password to set for the ironic admin user in keystone
# #
# [*enabled_drivers*]
# The back-end drivers for Ironic
# Defaults to agent_ssh
#
# [*swift_temp_url_key*]
# (required) The temporaty url key for Ironic to access Swift
#
class ironic::api ( class ironic::api (
$package_ensure = 'present', $package_ensure = 'present',
@ -86,7 +97,10 @@ class ironic::api (
$auth_version = false, $auth_version = false,
$admin_tenant_name = 'services', $admin_tenant_name = 'services',
$admin_user = 'ironic', $admin_user = 'ironic',
$neutron_url = false,
$admin_password, $admin_password,
$swift_temp_url_key,
$enabled_drivers = 'agent_ssh',
) { ) {
include ironic::params include ironic::params
@ -97,9 +111,11 @@ class ironic::api (
# Configure ironic.conf # Configure ironic.conf
ironic_config { ironic_config {
'api/host_ip': value => $host_ip; 'api/host_ip': value => $host_ip;
'api/port': value => $port; 'api/port': value => $port;
'api/max_limit': value => $max_limit; 'api/max_limit': value => $max_limit;
'DEFAULT/enabled_drivers': value => $enabled_drivers;
'glance/swift_temp_url_key': value => $swift_temp_url_key, secret => true;
} }
# Install package # Install package
@ -127,6 +143,12 @@ class ironic::api (
hasstatus => true, hasstatus => true,
} }
if $neutron_url {
ironic_config { 'neutron/url': value => $neutron_url; }
} else {
ironic_config { 'neutron/url': value => "${auth_protocol}://${auth_host}:9696/"; }
}
if $auth_uri { if $auth_uri {
ironic_config { 'keystone_authtoken/auth_uri': value => $auth_uri; } ironic_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
} else { } else {
@ -159,5 +181,4 @@ class ironic::api (
} }
} }
} }

View File

@ -156,25 +156,32 @@ class ironic (
include ironic::params include ironic::params
Package['ironic'] -> Ironic_config<||> Package['ironic-common'] -> Ironic_config<||>
File { file { '/etc/ironic':
require => Package['ironic'], ensure => directory,
require => Package['ironic-common'],
owner => 'root',
group => 'ironic',
mode => '0750',
}
file { '/etc/ironic/ironic.conf':
require => Package['ironic-common'],
owner => 'root', owner => 'root',
group => 'ironic', group => 'ironic',
mode => '0640', mode => '0640',
} }
file { '/etc/ironic': package { 'python-pbr':
ensure => directory, ensure => $package_ensure,
mode => '0750', name => $::ironic::params::pbr_package,
} }
file { '/etc/ironic/ironic.conf': } package { 'ironic-common':
ensure => $package_ensure,
package { 'ironic': name => $::ironic::params::common_package_name,
ensure => $package_ensure, require => Package['python-pbr'],
name => $::ironic::params::package_name,
} }
validate_re($database_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?') validate_re($database_connection, '(sqlite|mysql|postgresql):\/\/(\S+:\S+@\S+\/\S+)?')
@ -182,7 +189,6 @@ class ironic (
case $database_connection { case $database_connection {
/mysql:\/\/\S+:\S+@\S+\/\S+/: { /mysql:\/\/\S+:\S+@\S+\/\S+/: {
$database_backend_package = false $database_backend_package = false
require 'mysql::python'
} }
/postgresql:\/\/\S+:\S+@\S+\/\S+/: { /postgresql:\/\/\S+:\S+@\S+\/\S+/: {
$database_backend_package = 'python-psycopg2' $database_backend_package = 'python-psycopg2'
@ -226,6 +232,16 @@ class ironic (
'glance/glance_api_insecure': value => $glance_api_insecure; 'glance/glance_api_insecure': value => $glance_api_insecure;
} }
Ironic_config['database/connection'] ~> Exec['ironic-dbsync']
exec { 'ironic-dbsync':
command => $::ironic::params::dbsync_command,
path => '/usr/bin',
user => 'ironic',
refreshonly => true,
logoutput => on_failure,
}
if $rpc_backend == 'ironic.openstack.common.rpc.impl_kombu' { if $rpc_backend == 'ironic.openstack.common.rpc.impl_kombu' {
if ! $rabbit_password { if ! $rabbit_password {
fail('When rpc_backend is rabbitmq, you must set rabbit password') fail('When rpc_backend is rabbitmq, you must set rabbit password')

View File

@ -20,22 +20,27 @@
class ironic::params { class ironic::params {
$dbsync_command =
'ironic-dbsync --config-file /etc/ironic/ironic.conf'
case $::osfamily { case $::osfamily {
'RedHat': { 'RedHat': {
$package_name = 'openstack-ironic' $common_package_name = 'openstack-ironic-common'
$api_package = false $api_package = 'openstack-ironic-api'
$conductor_package = false $api_service = 'openstack-ironic-api'
$api_service = 'ironic-api' $conductor_package = 'openstack-ironic-conductor'
$conductor_service = 'ironic-conductor' $conductor_service = 'openstack-ironic-conductor'
$client_package = 'python-ironicclient' $client_package = 'python-ironicclient'
$pbr_package = 'python-pbr'
} }
'Debian': { 'Debian': {
$package_name = 'ironic-common' $common_package_name = 'ironic-common'
$api_service = 'ironic-api' $api_service = 'ironic-api'
$conductor_service = 'ironic-conductor' $api_package = 'ironic-api'
$api_package = 'ironic-api' $conductor_service = 'ironic-conductor'
$conductor_package = 'ironic-conductor' $conductor_package = 'ironic-conductor'
$client_package = 'python-ironicclient' $client_package = 'python-ironicclient'
$pbr_package = 'python-pbr'
} }
default: { default: {
fail("Unsupported osfamily ${::osfamily}") fail("Unsupported osfamily ${::osfamily}")

View File

@ -66,6 +66,7 @@ describe 'ironic::api' do
should contain_ironic_config('keystone_authtoken/admin_password').with_value(p[:admin_password]) should contain_ironic_config('keystone_authtoken/admin_password').with_value(p[:admin_password])
should contain_ironic_config('keystone_authtoken/admin_user').with_value(p[:admin_user]) should contain_ironic_config('keystone_authtoken/admin_user').with_value(p[:admin_user])
should contain_ironic_config('keystone_authtoken/auth_uri').with_value('http://127.0.0.1:5000/') should contain_ironic_config('keystone_authtoken/auth_uri').with_value('http://127.0.0.1:5000/')
should contain_ironic_config('neutron/url').with_value('http://127.0.0.1:9696/')
end end
context 'when overriding parameters' do context 'when overriding parameters' do

View File

@ -102,7 +102,8 @@ describe 'ironic' do
:owner => 'root', :owner => 'root',
:group => 'ironic', :group => 'ironic',
:mode => '0750', :mode => '0750',
:require => 'Package[ironic]' :require => 'Package[python-pbr]',
:require => 'Package[ironic-common]'
) )
end end
@ -111,12 +112,12 @@ describe 'ironic' do
:owner => 'root', :owner => 'root',
:group => 'ironic', :group => 'ironic',
:mode => '0640', :mode => '0640',
:require => 'Package[ironic]' :require => 'Package[ironic-common]'
) )
end end
it 'installs ironic package' do it 'installs ironic package' do
should contain_package('ironic').with( should contain_package('ironic-common').with(
:ensure => 'present', :ensure => 'present',
:name => platform_params[:common_package_name] :name => platform_params[:common_package_name]
) )
@ -233,7 +234,7 @@ describe 'ironic' do
end end
let :platform_params do let :platform_params do
{ :common_package_name => 'openstack-ironic' } { :common_package_name => 'openstack-ironic-common' }
end end
it_configures 'ironic' it_configures 'ironic'