diff --git a/plans/uninstall.pp b/plans/uninstall.pp new file mode 100644 index 00000000..5d1f2e5d --- /dev/null +++ b/plans/uninstall.pp @@ -0,0 +1,13 @@ +# @summary Single-entry-point plan for uninstalling Puppet Enterprise + +plan peadm::uninstall ( + Peadm::SingleTargetSpec $primary_host, +) { + peadm::assert_supported_bolt_version() + + $primary_target = peadm::get_targets($primary_host, 1) + $uninstall_result = run_task('peadm::pe_uninstall', $primary_target) + + return([$uninstall_result]) +} + diff --git a/spec/plans/uninstall_spec.rb b/spec/plans/uninstall_spec.rb new file mode 100644 index 00000000..60c333cb --- /dev/null +++ b/spec/plans/uninstall_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'peadm::uninstall' do + include BoltSpec::Plans + + describe 'basic functionality' do + it 'runs peadm::uninstall successfully with only primary_host as parameter' do + expect_task('peadm::pe_uninstall') + expect(run_plan('peadm::uninstall', 'primary_host' => 'primary')).to be_ok + end + end +end diff --git a/tasks/pe_uninstall.json b/tasks/pe_uninstall.json new file mode 100644 index 00000000..14179361 --- /dev/null +++ b/tasks/pe_uninstall.json @@ -0,0 +1,9 @@ +{ + "description": "Uninstall Puppet Enterprise", + "parameters": { + }, + "input_method": "environment", + "implementations": [ + {"name": "pe_uninstall.sh"} + ] +} diff --git a/tasks/pe_uninstall.sh b/tasks/pe_uninstall.sh new file mode 100755 index 00000000..881bd71c --- /dev/null +++ b/tasks/pe_uninstall.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Uninstalling PE with the following flags +# For more information about the uninstaller +# and the command-line flags, visit: +# https://puppet.com/docs/pe/2019.8/uninstalling.html + +if [ -x "$(command -v /opt/puppetlabs/bin/puppet-enterprise-uninstaller)" ]; then + /opt/puppetlabs/bin/puppet-enterprise-uninstaller -d -p -y +else + echo 'Error: puppet-enterprise-uninstaller is not available on this target.' + exit 1 +fi