Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature set dest war file name #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions files/scripts/get_file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ showhelp () {
echo "-s <source_file> - The URL of the file to get"
echo "-t <file_type> - The type of file that is retrieved: list|tarball|maven-metadata|dir"
echo "-d <local_dir> - An alternative destination directory (default is automatically chosen)"
echo "-f <local_file> - An alternative destination file name (default is automatically chosen)"
echo "-a <yes|no> - If 'no' return a special error code (99) if the download checksum is the same of the one previously downloaded"
echo "-u <http_user> - in case of type http, specify a http_user for curl"
echo "-p <http_password> - in case of type http, specifiy http_user for curl"
Expand Down Expand Up @@ -77,6 +78,9 @@ while [ $# -gt 0 ]; do
# Enforces and overrides and alternative downloaddir
downloaddir=$2
shift 2 ;;
-f)
destfilename=$2
shift 2 ;;
-a)
alwaysdeploy=$2
shift 2 ;;
Expand Down Expand Up @@ -115,11 +119,19 @@ case $type in
save_runtime_config "downloadedfile=$downloaddir/$downloadfilename"
;;
http|https)
if [ -z "$http_password" ] ; then
curl $ssl_arg -s -f -L "$url" -O
if [ ! -z "$destfilename" ] ; then
destfilename_arg="-o $destfilename"
else
curl $ssl_arg -s -f -L --anyauth --user $http_user:$http_password "$url" -O
fi
destfilename_arg="-O"
fi

if [ ! -z "$http_password" ] ; then
httpauth_arg="--anyauth --user $http_user:$http_password"
else
httpauth_arg=""
fi

curl $ssl_arg -s -f -L $httpauth_arg "$url" $destfilename_arg
check_retcode
save_runtime_config "downloadedfile=$downloaddir/$downloadfilename"
;;
Expand Down
31 changes: 19 additions & 12 deletions manifests/project/war.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
# [*deploy_root*]
# The destination directory where the retrieved file(s) are deployed.
#
# [*war_file*]
# (Optional) - The destination war file name where the retrieved file
# is deployed. In the case of a single war file that already has a version
# specifies the name and needs to be renamed.
#
# [*init_source*]
# (Optional) - The full URL to be used to retrieve, for the first time,
# the project files. They are copied directly to the $deploy_root
Expand Down Expand Up @@ -117,6 +122,7 @@
define puppi::project::war (
$source,
$deploy_root,
$war_file = undef,
$init_source = '',
$user = 'root',
$predeploy_customcommand = '',
Expand Down Expand Up @@ -173,8 +179,9 @@
$bool_check_deploy = any2bool($check_deploy)
$bool_auto_deploy = any2bool($auto_deploy)

$war_file = url_parse($source,'filename')

if ($war_file == undef) {
$war_file = url_parse($source,'filename')
}

### CREATE PROJECT
puppi::project { $name:
Expand All @@ -187,7 +194,7 @@
puppi::initialize { "${name}-Deploy_Files":
priority => '40' ,
command => 'get_file.sh' ,
arguments => "-s ${init_source} -d ${deploy_root}" ,
arguments => "-s '${init_source}' -d '${deploy_root}'" ,
user => $user ,
project => $name ,
enable => $enable ,
Expand All @@ -211,7 +218,7 @@
puppi::deploy { "${name}-Retrieve_WAR":
priority => '20' ,
command => 'get_file.sh' ,
arguments => "-s ${source} -a ${real_always_deploy}" ,
arguments => "-s '${source}' -a '${real_always_deploy}' -f '${war_file}'" ,
user => 'root' ,
project => $name ,
enable => $enable ,
Expand All @@ -232,7 +239,7 @@
puppi::deploy { "${name}-Backup_existing_WAR":
priority => '30' ,
command => 'archive.sh' ,
arguments => "-b ${deploy_root} -t war -s move -m diff -o '${backup_rsync_options}' -n ${backup_retention}" ,
arguments => "-b '${deploy_root}' -t war -s copy -m diff -o '${backup_rsync_options}' -n '${backup_retention}'" ,
user => 'root' ,
project => $name ,
enable => $enable ,
Expand All @@ -243,7 +250,7 @@
puppi::deploy { "${name}-Check_undeploy":
priority => '32' ,
command => 'checkwardir.sh' ,
arguments => "-a ${deploy_root}/${war_file}" ,
arguments => "-a '${deploy_root}/${war_file}'" ,
user => $user ,
project => $name ,
enable => $enable ,
Expand Down Expand Up @@ -287,7 +294,7 @@
puppi::deploy { "${name}-Deploy_WAR":
priority => '40' ,
command => 'deploy_files.sh' ,
arguments => "-d ${deploy_root} -c ${bool_clean_deploy}",
arguments => "-d '${deploy_root}' -c '${bool_clean_deploy}'",
user => $user ,
project => $name ,
enable => $enable ,
Expand Down Expand Up @@ -330,7 +337,7 @@
puppi::deploy { "${name}-Check_deploy":
priority => '45' ,
command => 'checkwardir.sh' ,
arguments => "-p ${deploy_root}/${war_file}" ,
arguments => "-p '${deploy_root}/${war_file}'" ,
user => $user ,
project => $name ,
enable => $enable ,
Expand Down Expand Up @@ -378,7 +385,7 @@
puppi::rollback { "${name}-Remove_existing_WAR":
priority => '30' ,
command => 'delete.sh' ,
arguments => "${deploy_root}/${war_file}" ,
arguments => "'${deploy_root}/${war_file}'" ,
user => 'root' ,
project => $name ,
enable => $enable ,
Expand All @@ -388,7 +395,7 @@
puppi::rollback { "${name}-Check_undeploy":
priority => '36' ,
command => 'checkwardir.sh' ,
arguments => "-a ${deploy_root}/${war_file}" ,
arguments => "-a '${deploy_root}/${war_file}'" ,
user => $user ,
project => $name ,
enable => $enable ,
Expand Down Expand Up @@ -431,7 +438,7 @@
puppi::rollback { "${name}-Recover_Files_To_Deploy":
priority => '40' ,
command => 'archive.sh' ,
arguments => "-r ${deploy_root} -t war -o '${backup_rsync_options}'" ,
arguments => "-r '${deploy_root}' -t war -o '${backup_rsync_options}'" ,
user => $user ,
project => $name ,
enable => $enable ,
Expand Down Expand Up @@ -474,7 +481,7 @@
puppi::rollback { "${name}-Check_deploy":
priority => '45' ,
command => 'checkwardir.sh' ,
arguments => "-p ${deploy_root}/${war_file}" ,
arguments => "-p '${deploy_root}/${war_file}'" ,
user => $user ,
project => $name ,
enable => $enable ,
Expand Down