https://bugzilla.redhat.com/show_bug.cgi?id=731863
When the -s option is used, the cleanup process will not remove any data --- bin/aeolus-cleanup | 10 ++++++++-- recipes/aeolus/manifests/conductor.pp | 6 +++++- recipes/aeolus/manifests/image-factory.pp | 4 +++- recipes/aeolus/manifests/init.pp | 1 - recipes/aeolus/manifests/iwhd.pp | 17 ++++++++++------- 5 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/bin/aeolus-cleanup b/bin/aeolus-cleanup index 230b9a9..ef7427c 100644 --- a/bin/aeolus-cleanup +++ b/bin/aeolus-cleanup @@ -19,28 +19,32 @@ usage() cat << EOF
USAGE: -aeolus-cleanup [-d|--debug] [-h|--help] [-v|--verbose] +aeolus-cleanup [-d|--debug] [-h|--help] [-v|--verbose] [-s|--savedata]
OPTIONS: -h | --help Show this message. -d | --debug Debug logging mode. -v | --verbose Verbose logging mode. + -s | --savedata Do not delete existing data. EOF }
-args=`getopt -o :hdv --long help,debug,verbose -- "$@"` +args=`getopt -o :hdvs --long help,debug,verbose,savedata -- "$@"` if test $? != 0 then usage exit 1 fi
+SAVE_DATA=false + eval set -- $args while true ; do case "$1" in -h|--help) usage ; exit 1 ; shift ;; -d|--debug) LOGLEVEL="--debug" ; shift ;; -v|--verbose) LOGLEVEL="--verbose" ; shift ;; + -s|--savedata) SAVE_DATA=true ; shift ;; --) shift ; break ;; *) usage ; exit 1 ;; esac @@ -50,6 +54,8 @@ PUPPET_NODE='cleanup'
export FACTER_AEOLUS_ENABLE_HTTPS=true export FACTER_AEOLUS_ENABLE_SECURITY=false +export FACTER_AEOLUS_SAVE_DATA=$SAVE_DATA + puppet /usr/share/aeolus-configure/modules/aeolus/aeolus.pp \ --modulepath=/usr/share/aeolus-configure/modules/ \ --external_nodes "/bin/sh /usr/share/aeolus-configure/modules/aeolus/aeolus-node $PUPPET_NODE" --node_terminus exec \ diff --git a/recipes/aeolus/manifests/conductor.pp b/recipes/aeolus/manifests/conductor.pp index 11acb0d..531ebb7 100644 --- a/recipes/aeolus/manifests/conductor.pp +++ b/recipes/aeolus/manifests/conductor.pp @@ -136,10 +136,12 @@ class aeolus::conductor inherits aeolus { }
class aeolus::conductor::disabled { + if $aeolus_save_data == "false" { file {"/var/lib/aeolus-conductor": ensure => absent, force => true } + }
file {"/etc/rsyslog.d/aeolus.conf": ensure => absent, @@ -158,7 +160,8 @@ class aeolus::conductor::disabled { enable => false, hasstatus => true }
- ### Destroy the aeolus database + if $aeolus_save_data == "false" { + ### Destroy the aeolus database rails::drop::db{"drop_aeolus_database": cwd => "/usr/share/aeolus-conductor", rails_env => "production", @@ -167,6 +170,7 @@ class aeolus::conductor::disabled { postgres::user{"aeolus": ensure => 'dropped', require => Rails::Drop::Db["drop_aeolus_database"]} + } }
# Create a new site admin conductor web user diff --git a/recipes/aeolus/manifests/image-factory.pp b/recipes/aeolus/manifests/image-factory.pp index d6e37ec..0a5af28 100644 --- a/recipes/aeolus/manifests/image-factory.pp +++ b/recipes/aeolus/manifests/image-factory.pp @@ -94,8 +94,10 @@ class aeolus::image-factory::disabled { hasstatus => true, enable => false}
- ### Destroy and cleanup aeolus artifacts + if $aeolus_save_data == "false" { + ### Destroy and cleanup aeolus artifacts exec{"remove_aeolus_templates": command => "/bin/rm -rf /templates"} + } }
define aeolus::image($template, $provider='', $target='', $hwp=''){ diff --git a/recipes/aeolus/manifests/init.pp b/recipes/aeolus/manifests/init.pp index 97228ef..9551cc8 100644 --- a/recipes/aeolus/manifests/init.pp +++ b/recipes/aeolus/manifests/init.pp @@ -42,7 +42,6 @@ if $aeolus_enable_security == "true" or $aeolus_enable_security == "1" { $enable_security = false }
- # Base aeolus class class aeolus { package{'curl': diff --git a/recipes/aeolus/manifests/iwhd.pp b/recipes/aeolus/manifests/iwhd.pp index 61579e8..43b219b 100644 --- a/recipes/aeolus/manifests/iwhd.pp +++ b/recipes/aeolus/manifests/iwhd.pp @@ -63,11 +63,13 @@ class aeolus::iwhd inherits aeolus { }
class aeolus::iwhd::disabled { - exec { 'clean_iwhd': - command => '/usr/bin/ruby /usr/share/aeolus-configure/modules/aeolus/clean-iwhd.rb http://localhost:9090', - before => Service[iwhd], - onlyif => '/usr/bin/curl http://localhost:9090', - logoutput => true, + if $aeolus_save_data == "false" { + exec { 'clean_iwhd': + command => '/usr/bin/ruby /usr/share/aeolus-configure/modules/aeolus/clean-iwhd.rb http://localhost:9090', + before => Service[iwhd], + onlyif => '/usr/bin/curl http://localhost:9090', + logoutput => true, + } }
### Stop the aeolus services @@ -81,12 +83,13 @@ class aeolus::iwhd::disabled { enable => false, hasstatus => true}
- file { "/var/lib/iwhd": + if $aeolus_save_data == "false" { + file { "/var/lib/iwhd": ensure => 'absent', backup => 'false', force => true, require => Service['iwhd']} - + } }
# Create a named bucket in iwhd