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

svn deploy in interactive mode #42

Open
amateo opened this issue Dec 27, 2012 · 3 comments
Open

svn deploy in interactive mode #42

amateo opened this issue Dec 27, 2012 · 3 comments

Comments

@amateo
Copy link
Contributor

amateo commented Dec 27, 2012

With the svn define and script included in puppi, svn command is always run in non-interactive mode. This way, you have to include svn username and password in your puppet files, which is not always a good idea.

I have patched these files to include a "interactive" option to the puppet define (which default to false) and svn script, so when it is true, svn command is run in interactive mode.

If you think it could be interesting, this is the patch:

Index: modules/puppi/files/scripts/svn.sh
===================================================================
--- modules/puppi/files/scripts/svn.sh  (revisión: 10271)
+++ modules/puppi/files/scripts/svn.sh  (copia de trabajo)
@@ -24,12 +24,14 @@
     echo "-c <commit> (Optional) Commit to deploy"
     echo "-v <true|false> (Optional) If verbose"
     echo "-k <true|false> (Optional) If .svn dir is kept on deploy_root"
+    echo "-i (Optional) Interactive. Execute svn command in interactive mode"
     echo 
     echo "Examples:"
     echo "svn.sh -a deploy -s $source -d $deploy_root -u $user -gs $svn_subdir -t $tag -b $branch -c $commit -v $bool_verbose -k $bool_keep_svndata"
 }

 verbose="true"
+interactive=false

 # Check Arguments
 while [ $# -gt 0 ]; do
@@ -121,6 +123,14 @@
         keep_svndata=$2
       fi
       shift 2 ;;
+    -i)
+      if [ $interactive ] ; then
+        interactive=$interactive
+      else
+        interactive=$2
+      fi
+      shift 2
+      ;;
     *)
       showhelp
       exit ;;
@@ -133,6 +143,12 @@
   verbosity="--quiet"
 fi

+if [ "$interactive" == "true" ] ; then
+  interactive_arg="--non-interactive"
+else
+  interactive_arg=""
+fi
+
 cd /

 if [ "x$branch" == "xundefined" ] ; then
@@ -172,9 +188,9 @@
 do_install () {
   if [ -d $svndir/.svn ] ; then
     cd $svndir
-    svn up $verbosity $svn_auth --non-interactive
+    svn up $verbosity $svn_auth $interactive_arg
   else
-    svn co $verbosity $real_source $svndir $svn_auth --non-interactive
+    svn co $verbosity $real_source $svndir $svn_auth $interactive_arg
     cd $svndir
   fi

Index: modules/puppi/manifests/project/svn.pp
===================================================================
--- modules/puppi/manifests/project/svn.pp  (revisión: 10271)
+++ modules/puppi/manifests/project/svn.pp  (copia de trabajo)
@@ -131,6 +131,10 @@
 #   (Optional) - If you want to automatically run this puppi deploy when
 #   Puppet runs. Default: 'false'
 #
+# [*interactive*]
+#   (Optional) - If you want to run svn in interactive mode
+#   Default: 'false'
+#
 define puppi::project::svn (
   $source,
   $deploy_root,
@@ -159,6 +163,7 @@
   $backup_retention         = '5',
   $run_checks               = true,
   $auto_deploy              = false,
+  $interactive              = false,
   $enable                   = true ) {

   require puppi
@@ -180,6 +185,7 @@
   $bool_verbose = any2bool($verbose)
   $bool_run_checks = any2bool($run_checks)
   $bool_auto_deploy = any2bool($auto_deploy)
+  $bool_interactive = any2bool($interactive)

 ### INSTALL GIT
   if ($bool_install_svn == true) {
@@ -191,7 +197,6 @@
       enable => $enable ,
     }

-
 ### DEPLOY SEQUENCE
   if ($bool_run_checks == true) {
     puppi::deploy { "${name}-Run_PRE-Checks":
@@ -252,7 +257,7 @@
     puppi::deploy { "${name}-Deploy_Files":
       priority  => '40' ,
       command   => 'svn.sh' ,
-      arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${svn_subdir} -su ${svn_user} -sp ${svn_password} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata}" ,
+      arguments => "-a deploy -s ${source} -d ${deploy_root} -u ${user} -gs ${svn_subdir} -su ${svn_user} -sp ${svn_password} -t ${tag} -b ${branch} -c ${commit} -v ${bool_verbose} -k ${bool_keep_svndata} -i ${bool_interactive}" ,
       user      => 'root' ,
       project   => $name ,
       enable    => $enable ,
@alvagante
Copy link
Member

Have you tested this on a real puppi deploy? My concern is that puppi shows the output of a command AFTER it has executed it (showing its return code and OK/WARNNG/ERROR), so during deploy you might not see the username/password prompt....

@amateo
Copy link
Contributor Author

amateo commented Dec 27, 2012

Yes,

I have tried. It asks for the password of the user:

Deleted old /var/lib/puppi/archive/infoapp/20121227-125024

pitufo11 Deploy: 40-infoapp-Deploy_FilesClave de «amateo»: 

It is not the best way, because it asks for the password before needing it and if you put a wrong password, then it asks for username without prompting anything, but it works.

@alvagante
Copy link
Member

Ok, thank you, Would you please submit the patch as a git pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants