Make ironic::drivers::ansible actually install required packages

It is assumed that ansible is installed, but realistically it does
not have to. This change install ansible and systemd-python (the latter
required for correct logging in the driver).

Change-Id: I50d15bdd210fa444a0354e3b38acf21ec9d0ac30
This commit is contained in:
Dmitry Tantsur 2017-12-07 15:32:26 +01:00
parent e4fcf84bdf
commit 2dae296b45
4 changed files with 51 additions and 0 deletions

View File

@ -14,6 +14,10 @@
#
# === Parameters
#
# [*package_ensure*]
# (optional) The state of the required packages
# Defaults to 'present'
#
# [*ansible_extra_args*]
# (optional) Extra arguments to pass on every invocation of ansible.
# Defaults to $::os_service_default
@ -33,6 +37,7 @@
#
class ironic::drivers::ansible (
$package_ensure = 'present',
$ansible_extra_args = $::os_service_default,
$playbooks_path = $::os_service_default,
$config_file_path = $::os_service_default,
@ -40,6 +45,7 @@ class ironic::drivers::ansible (
) {
include ::ironic::deps
include ::ironic::params
# Configure ironic.conf
ironic_config {
@ -49,4 +55,19 @@ class ironic::drivers::ansible (
'ansible/image_store_insecure': value => $image_store_insecure;
}
ensure_packages('ansible',
{
ensure => $package_ensure,
tag => ['openstack', 'ironic-package'],
}
)
ensure_packages('systemd-python',
{
ensure => $package_ensure,
name => $::ironic::params::systemd_python_package,
tag => ['openstack', 'ironic-package'],
}
)
}

View File

@ -41,6 +41,7 @@ class ironic::params {
$inspector_service = 'openstack-ironic-inspector'
$inspector_dnsmasq_service = 'openstack-ironic-inspector-dnsmasq'
$staging_drivers_package = 'openstack-ironic-staging-drivers'
$systemd_python_package = 'systemd-python'
$ipxe_rom_dir = '/usr/share/ipxe'
$ironic_wsgi_script_path = '/var/www/cgi-bin/ironic'
$ironic_wsgi_script_source = '/usr/lib/python2.7/site-packages/ironic/api/app.wsgi'
@ -64,6 +65,7 @@ class ironic::params {
$inspector_dnsmasq_service = 'ironic-inspector-dnsmasq'
# guessing the name, ironic-staging-drivers is not packaged in debian yet
$staging_drivers_package = 'ironic-staging-drivers'
$systemd_python_package = 'python-systemd'
$ipxe_rom_dir = '/usr/lib/ipxe'
$ironic_wsgi_script_path = '/usr/lib/cgi-bin/ironic'
$ironic_wsgi_script_source = '/usr/lib/python2.7/dist-packages/ironic/api/app.wsgi'

View File

@ -0,0 +1,5 @@
---
fixes:
- |
The ``ironic::drivers::ansible`` manifest now installs dependencies of
the *ansible* deploy method - ``ansible`` and ``systemd-python`` packages.

View File

@ -33,6 +33,19 @@ describe 'ironic::drivers::ansible' do
is_expected.to contain_ironic_config('ansible/image_store_insecure').with_value('<SERVICE DEFAULT>')
end
it 'installs ansible package' do
is_expected.to contain_package('ansible').with(
:ensure => 'present',
:name => 'ansible',
:tag => ['openstack', 'ironic-package'],
)
is_expected.to contain_package('systemd-python').with(
:ensure => 'present',
:name => platform_params[:systemd_python_package],
:tag => ['openstack', 'ironic-package'],
)
end
context 'when overriding parameters' do
before do
params.merge!(:ansible_extra_args => '--foo',
@ -57,6 +70,16 @@ describe 'ironic::drivers::ansible' do
let (:facts) do
facts.merge(OSDefaults.get_facts())
end
let :platform_params do
case facts[:osfamily]
when 'Debian'
{ :systemd_python_package => 'python-systemd' }
when 'RedHat'
{ :systemd_python_package => 'systemd-python' }
end
end
it_behaves_like 'ironic ansible deploy interface'
end
end