User and password as argument to wapt-get

Share your tips or issues concerning the WAPT Console or WAPT Agent here
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
User avatar
lduriez
Messages: 17
Registration: Sep 2, 2015 - 09:16
Location: Roubaix
Contact :

October 12, 2015 - 10:53

Good morning,

I am looking to automate, to a greater or lesser extent, the addition of host packages to my WAPT server.

I would like to know if it is possible to directly pass the username and password as arguments with the "wapt-get build-upload" command.<chemin_paquet_host> "? Or at least not have to manually enter the username and password.

If that's not possible, does anyone have any ideas on how to do it?

Personally, I tried something like this:

Code: Select all

wapt-get build-upload [chemin_paquet_host] < saisie.txt 
The following data is contained in the saisie.txt file:

Code: Select all

admin
pswd
admin being the WAPT Server user and pswd the WAPT Server password (NB -> This password is an example).

Unfortunately, it only works halfway because the user is correctly registered automatically (without me needing to enter it manually), however, the password is not registered, I am forced to enter it manually.

Thank you in advance for your answers, ideas, etc.
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

October 12, 2015 - 3:03 PM

We can patch wapt-get.py to allow this information to be passed via the command line...
Add 2 options to the parser.

Code: Select all

    parser.add_option("--wapt-server-user", dest="wapt_server_user", default=None, help="User to upload packages to waptserver. (default: %default)")
    parser.add_option("--wapt-server-passwd", dest="wapt_server_passwd", default=None, help="Password to upload packages to waptserver. (default: %default)")
    

Add the values ​​to the call to build_upload:

Code: Select all

   res = mywapt.upload_package(cmd_dict,wapt_server_user = options.wapt_server_user,wapt_server_passwd=options.wapt_server_passwd)
                             print('Status : %s, %s' % (

Code: Select all

@@ -134,6 +134,8 @@ parser.add_option("-U","--user", dest="user", default=None, help="Interactive us
 parser.add_option("-g","--usergroups", dest="usergroups", default='[]', help="Groups of the final user as a JSon array for checking install permission (default: %default)")
 parser.add_option("-t","--maxttl", type='int',  dest="max_ttl", default=60, help="Max run time in minutes of wapt-get process before being killed by subsequent wapt-get (default: %default minutes)")
 parser.add_option("-L","--language",    dest="language",    default=setuphelpers.get_language(), help="Override language for install (example : fr) (default: %default)")
+parser.add_option("--wapt-server-user", dest="wapt_server_user", default=None, help="User to upload packages to waptserver. (default: %default)")
+parser.add_option("--wapt-server-passwd", dest="wapt_server_passwd", default=None, help="Password to upload packages to waptserver. (default: %default)")
 
 (options,args) = parser.parse_args()
 
@@ -742,7 +744,7 @@ def main():
                                 'waptfile': files_list,
                                 'waptdir':package_group[0],
                             }
-                            res = mywapt.upload_package(cmd_dict)
+                            res = mywapt.upload_package(cmd_dict,wapt_server_user = options.wapt_server_user,wapt_server_passwd=options.wapt_server_passwd)
                             print('Status : %s, %s' % (
                                 res['status'], res['message']))
                                 
Tranquil IT
User avatar
lduriez
Messages: 17
Registration: Sep 2, 2015 - 09:16
Location: Roubaix
Contact :

October 12, 2015 - 3:36 PM

Thank you very much for your reply.

I'll look into it, but I think it will help me a lot.
User avatar
lduriez
Messages: 17
Registration: Sep 2, 2015 - 09:16
Location: Roubaix
Contact :

October 14, 2015 - 2:12 PM

Hello,

just to let you know that I made the change to wapt-get.py and it works perfectly.

Thanks anyway, and I hope this can help someone else.

PS: I think you should include this in future versions of WAPT as it could be useful for some people.
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

October 14, 2015 - 2:14 PM

Tranquil IT
Locked