From 5baf8d135ccf858df8a918461c730272f1f609d9 Mon Sep 17 00:00:00 2001 From: Ricardo Carrillo Cruz Date: Fri, 21 Aug 2015 10:48:28 +0000 Subject: [PATCH] Put configuration files under configurable folder Instead of putting baremetal.json and groupvars/all on the git repo folder for Bifrost, just create a folder (which defaults to /etc/bifrost) and put those files in there. This will avoid having a dirty bifrost git repo and having issues whenever the Bifrost git repo is updated. Note, you will need to run 'ansible-playbook -e @/etc/bifrost/bifrost_global_vars ...' in order to load the configuration file variables at execution time. Check http://docs.ansible.com/ansible/playbooks_variables.html for more info. Change-Id: Id0f5711f6f4e18cf67586e2445d8bd09c5db7ca9 --- README.md | 8 ++++++ manifests/bifrost.pp | 26 ++++++++++++++----- spec/classes/ironic_bifrost_spec.rb | 19 +++++++++----- ...p_vars_all.erb => bifrost_global_vars.erb} | 0 4 files changed, 41 insertions(+), 12 deletions(-) rename templates/{group_vars_all.erb => bifrost_global_vars.erb} (100%) diff --git a/README.md b/README.md index 338a06bc..73b7e251 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,14 @@ class { '::ironic::api': } class { '::ironic::drivers::ipmi': } + +# alternatively, you can deploy Ironic with Bifrost. It's a collection of Ansible playbooks to configure +# and install Ironic in a stand-alone fashion (for more information visit http://git.openstack.org/openstack/bifrost) +class { 'ironic::bifrost': + ironic_db_password => 'a_big_secret', + mysql_password => 'yet_another_big_secret', + baremetal_json_hosts => hiera('your_hiera_var_containing_bm_json_hosts'), +} ``` Examples of usage also can be found in the *examples* directory. diff --git a/manifests/bifrost.pp b/manifests/bifrost.pp index 34dcd6b2..bda15ebe 100644 --- a/manifests/bifrost.pp +++ b/manifests/bifrost.pp @@ -55,6 +55,15 @@ # (optional) Folder to clone the Bifrost git repository # Defaults to '/opt/stack/bifrost' # +# [*bifrost_config_folder*] +# (optional) Folder to keep the configuration files, namely the global vars file +# and baremetal.json +# Defaults to '/etc/bifrost' +# Note that due to how Ansible handles the directory layout of playbooks and roles, +# you will need to pass '-e "@/etc/bifrost/bifrost_global_vars' switch to 'ansible-playbook' +# to load the variables at execution time. +# For more information, check http://docs.ansible.com/ansible/playbooks_variables.html +# # [*ironic_url*] # (optional) The URL of the Ironic server # Defaults to '"http://localhost:6385"' @@ -155,6 +164,7 @@ class ironic::bifrost ( $ensure = present, $revision = 'master', $git_dest_repo_folder = '/opt/stack/bifrost', + $bifrost_config_folder = '/etc/bifrost', $ironic_url = '"http://localhost:6385/"', $network_interface = '"virbr0"', $testing = false, @@ -187,16 +197,20 @@ class ironic::bifrost ( source => $git_source_repo, } - file { "${git_dest_repo_folder}/playbooks/inventory/group_vars/all": - ensure => present, - content => template('ironic/group_vars_all.erb'), - require => Vcsrepo[$git_dest_repo_folder], + file { $bifrost_config_folder: + ensure => directory } - file { "${git_dest_repo_folder}/baremetal.json": + file { "${bifrost_config_folder}/bifrost_global_vars": + ensure => present, + content => template('ironic/bifrost_global_vars.erb'), + require => File[$bifrost_config_folder], + } + + file { "${bifrost_config_folder}/baremetal.json": ensure => present, content => template('ironic/baremetal.json.erb'), - require => Vcsrepo[$git_dest_repo_folder], + require => File[$bifrost_config_folder], } } diff --git a/spec/classes/ironic_bifrost_spec.rb b/spec/classes/ironic_bifrost_spec.rb index 6a1f2535..3355cb35 100644 --- a/spec/classes/ironic_bifrost_spec.rb +++ b/spec/classes/ironic_bifrost_spec.rb @@ -23,6 +23,7 @@ describe 'ironic::bifrost' do { :git_source_repo => 'https://git.openstack.org/openstack/bifrost', :revision => master, :git_dest_repo_folder => '/opt/stack/bifrost', + :bifrost_config_folder => '/etc/bifrost', :ironic_url => '"http://localhost:6385/"', :network_interface => '"virbr0"', :testing => false, @@ -65,18 +66,24 @@ describe 'ironic::bifrost' do ) end - it 'should contain file group_vars/all' do - should contain_file('/opt/stack/bifrost/playbooks/inventory/group_vars/all').with( + it 'should contain folder /etc/bifrost' do + should contain_file('/etc/bifrost').with( + 'ensure' => 'directory', + ) + end + + it 'should contain file /etc/bifrost/bifrost_global_vars' do + should contain_file('/etc/bifrost/bifrost_global_vars').with( 'ensure' => 'present', - 'require' => 'Vcsrepo[/opt/stack/bifrost]', + 'require' => 'File[/etc/bifrost]', 'content' => /ironic_url/, ) end - it 'should contain file baremetal.json' do - should contain_file('/opt/stack/bifrost/baremetal.json').with( + it 'should contain file /etc/bifrost/baremetal.json' do + should contain_file('/etc/bifrost/baremetal.json').with( 'ensure' => 'present', - 'require' => 'Vcsrepo[/opt/stack/bifrost]', + 'require' => 'File[/etc/bifrost]', 'content' => /test/, ) end diff --git a/templates/group_vars_all.erb b/templates/bifrost_global_vars.erb similarity index 100% rename from templates/group_vars_all.erb rename to templates/bifrost_global_vars.erb