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

All solutions of samuka smk #78

Open
wants to merge 3 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
39 changes: 27 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 All @@ -24,6 +29,12 @@
# [*user*]
# (Optional) - The user to be used for deploy operations.
#
# [*http_user*]
# (Optional) - The user to be used for download the war file(s).
#
# [*http_pass*]
# (Optional) - The password to be used for download the war file(s).
#
# [*predeploy_customcommand*]
# (Optional) - Full path with arguments of an eventual custom command to
# execute before the deploy. The command is executed as $predeploy_user.
Expand Down Expand Up @@ -117,8 +128,11 @@
define puppi::project::war (
$source,
$deploy_root,
$war_file = undef,
$init_source = '',
$user = 'root',
$http_user = undef,
$http_pass = undef,
$predeploy_customcommand = '',
$predeploy_user = '',
$predeploy_priority = '39',
Expand Down Expand Up @@ -173,8 +187,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 +202,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 +226,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}' -u '${http_user}' -p '${http_pass}'" ,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here when http_user and http_user and http_pass are left blank?
Probably an error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, have you tried to pass username and password directyl in the url?
IE: http://user:mypw@host:/path/file.war
That should work, without the need of setting extra params.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hy Guys,

This is an optional solution, use any way they wish. My intention to insert
these new options was formally declare in the manifest as a way to explain
how to pass the unsuspecting user and password of http, since we have no
explanatory documentation on http authentication, (I even hit head until I
remember that gave to pass the username and password via http url)

Thanks,
Samuka~Smk

2013/6/24 Alessandro Franceschi [email protected]

In manifests/project/war.pp:

@@ -211,7 +226,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}' -u '${http_user}' -p '${http_pass}'" ,
    

BTW, have you tried to pass username and password directyl in the url?
IE: http://user:mypw@host:/path/file.war
That should work, without the need to setting extra params.


Reply to this email directly or view it on GitHubhttps://github.com//pull/78/files#r4843197
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the approach of passing username and password directly in the url works, I would stick to it and eventually explain it better in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!,

The way you guys found better, If you want to close the pull request # 76
(Feature passing parameters in http aauth puppi project in war),
provided that improved documentation and is clear for new users, feel free.

Thanks,
SamukaSMk

2013/6/24 Alessandro Franceschi [email protected]

In manifests/project/war.pp:

@@ -211,7 +226,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}' -u '${http_user}' -p '${http_pass}'" ,
    

If the approach of passing username and password directly in the url
works, I would stick to it and eventually explain it better in the docs.


Reply to this email directly or view it on GitHubhttps://github.com//pull/78/files#r4843641
.

user => 'root' ,
project => $name ,
enable => $enable ,
Expand All @@ -232,7 +247,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 +258,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 +302,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 +345,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 +393,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 +403,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 +446,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 +489,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