Yolanda Robla Mota 70f4c4f19e Start parameterizing the network config in bifrost
This doesn't have to be hardcoded in the module, but
parameterized, and ideally shall be configured using
hiera. As an initial step, add the parameters with
default values, to pass tests until the corresponding
change for system-config lands.

Change-Id: Ic1f0368a1cb6c94405a4cb52dec1b83131164035
2016-09-16 16:07:22 +02:00

117 lines
3.7 KiB
Puppet

# Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# 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 infracloud::bifrost (
$gateway_ip,
$ipmi_passwords,
$ironic_db_password,
$ironic_inventory,
$mysql_password,
$ssh_private_key,
$ssh_public_key,
$vlan,
$default_network_interface = 'eth2',
$dhcp_pool_start = '10.10.16.144',
$dhcp_pool_end = '10.10.16.190',
$network_interface = 'eth2',
$ipv4_gateway = '15.184.64.1',
$ipv4_nameserver = '8.8.8.8',
$ipv4_subnet_mask = '255.255.224.0',
) {
include ::infracloud::params
# The configdrive bifrost task defaults to copying the user's local public
# ssh key. Let's make sure it's there so that bifrost doesn't error and so we
# can log in to nodes from the baremetal host.
file { '/root/.ssh/id_rsa':
ensure => present,
mode => '0600',
content => $ssh_private_key,
before => Exec['install bifrost'],
}
file { '/root/.ssh/id_rsa.pub':
ensure => present,
mode => '0644',
content => $ssh_public_key,
before => Exec['install bifrost'],
}
ensure_packages($::infracloud::params::bifrost_req_packages)
class { '::ansible':
ansible_version => '2.1.1.0',
require => Package[$::infracloud::params::bifrost_req_packages],
}
class { '::mysql::server':
root_password => $mysql_password,
}
vcsrepo { '/opt/stack/bifrost':
ensure => 'latest',
provider => 'git',
revision => 'master',
source => 'https://git.openstack.org/openstack/bifrost',
}
file { '/etc/bifrost':
ensure => directory,
}
file { '/etc/bifrost/bifrost_global_vars':
ensure => present,
content => template('infracloud/bifrost/bifrost_global_vars.erb'),
}
file { '/opt/stack/baremetal.json':
ensure => file,
content => template('infracloud/bifrost/inventory.json.erb'),
require => Vcsrepo['/opt/stack/bifrost'],
}
exec { 'install bifrost dependencies':
command => 'pip install -U -r /opt/stack/bifrost/requirements.txt',
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin',
refreshonly => true,
subscribe => Vcsrepo['/opt/stack/bifrost'],
}
file { '/opt/stack/elements':
ensure => directory,
recurse => true,
source => 'puppet:///modules/infracloud/elements',
require => Vcsrepo['/opt/stack/bifrost'],
before => Exec['install bifrost'],
}
exec { 'install bifrost':
environment => ['BIFROST_INVENTORY_SOURCE=/opt/stack/baremetal.json', 'HOME=/root'],
command => "ansible-playbook -e @/etc/bifrost/bifrost_global_vars -vvvv \
-i /opt/stack/bifrost/playbooks/inventory/bifrost_inventory.py \
/opt/stack/bifrost/playbooks/install.yaml \
&& touch /var/run/bifrost_install_succeeded",
path => '/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin',
creates => '/var/run/bifrost_install_succeeded',
timeout => 1500,
require => [
Exec['install bifrost dependencies'],
File['/etc/bifrost/bifrost_global_vars'],
Vcsrepo['/opt/stack/bifrost'],
Package[$::infracloud::params::bifrost_req_packages],
Class['::mysql::server'],
],
}
}