Re: [Fab-user] Log integratiing extra commands
Hi Nicolas, On Wed, Feb 10, 2010 at 11:32 AM, Nicolas Steinmetz nsteinm...@gmail.com wrote: For complex deployment, i may need to run extra commandes like run some scripts on one or serveral frontal servers or on a given db. I would like to avoid providing a new fabfile and was looking for taking into account some extra commands which would not be used for simple deployment. Any clue ? Could you provide an example here? I'm afraid I don't quite follow what you're asking :) My other concern is that I would like that all actions are written to a log file so that I can audit if a deployment went well or not. Your assumption that output currently only goes to stdout/stderr, is correct -- however, there are plans to change this. See http://code.fabfile.org/issues/show/57 :) There's also nothing preventing you from logging your own messages using the Python logging module, but that obviously doesn't cover the actual stdout/stderr. However, all calls to run() and sudo() return strings containing stdout, and those strings also have a '.stderr' attribute containing stderr -- so you could still rig something up to log both types of output to a file. Again, however, we have plans to make that a lot easier or automatic, in the future. Best, Jeff -- Jeff Forcier Unix sysadmin; Python/Ruby developer http://bitprophet.org ___ Fab-user mailing list Fab-user@nongnu.org http://lists.nongnu.org/mailman/listinfo/fab-user
Re: [Fab-user] Log integratiing extra commands
Hi, 2010/2/10 Jeff Forcier j...@bitprophet.org Hi Nicolas, On Wed, Feb 10, 2010 at 11:32 AM, Nicolas Steinmetz nsteinm...@gmail.com wrote: For complex deployment, i may need to run extra commandes like run some scripts on one or serveral frontal servers or on a given db. I would like to avoid providing a new fabfile and was looking for taking into account some extra commands which would not be used for simple deployment. Any clue ? Could you provide an example here? I'm afraid I don't quite follow what you're asking :) Yep, of course :-) For now, I have a commands.upd file which can contains commands to execute against some servers : Ex : remote front cd /var/www/myapp php path/to/script.php -s arg : will execute the given command on all frontals remote once front cd /var/www/myapp php /path/to/script2.php -s arg -u arg : will execute the command on the first frontal only remote db mysql -uusser -ppass -e SQL Query : will execute the query on all db servers So my perl script actually : * first push files on given servers (db or frontal according to a tree structure of the package) * execute content from the commands.upd file Most of the time, I do always the same thing in my commands.upd file : clear cache and update version in DB. But sometimes, I can have extra commands to pass (for ex, when I deploy a new town in my app, I have some jobs to run for initialising the meteo block or stations list or ... This scripts are part of my app but I need to call them. So I used to have so far most of the time the same commands.upd file that I extend for a given release with some required commands. I would like to do the same without modifying the fabfile.py (to avoid that at next release there are some old scripts that would be run because they were forgotten). Is it clear enough ? My other concern is that I would like that all actions are written to a log file so that I can audit if a deployment went well or not. Your assumption that output currently only goes to stdout/stderr, is correct -- however, there are plans to change this. See http://code.fabfile.org/issues/show/57 :) There's also nothing preventing you from logging your own messages using the Python logging module, but that obviously doesn't cover the actual stdout/stderr. However, all calls to run() and sudo() return strings containing stdout, and those strings also have a '.stderr' attribute containing stderr -- so you could still rig something up to log both types of output to a file. Again, however, we have plans to make that a lot easier or automatic, in the future. Ok, thanks for the information - Will try to see what can I do with the current .stderr, before 1.0 lands. Nicolas -- Nicolas Steinmetz http://www.steinmetz.fr - http://nicolas.steinmetz.fr/ ___ Fab-user mailing list Fab-user@nongnu.org http://lists.nongnu.org/mailman/listinfo/fab-user
Re: [Fab-user] Log integratiing extra commands
On Wed, Feb 10, 2010 at 11:54 PM, Nicolas Steinmetz nsteinm...@gmail.com wrote: Hi, 2010/2/10 Jeff Forcier j...@bitprophet.org Could you provide an example here? I'm afraid I don't quite follow what you're asking :) Yep, of course :-) For now, I have a commands.upd file which can contains commands to execute against some servers : Ex : remote front cd /var/www/myapp php path/to/script.php -s arg : will execute the given command on all frontals remote once front cd /var/www/myapp php /path/to/script2.php -s arg -u arg : will execute the command on the first frontal only remote db mysql -uusser -ppass -e SQL Query : will execute the query on all db servers So my perl script actually : * first push files on given servers (db or frontal according to a tree structure of the package) * execute content from the commands.upd file Most of the time, I do always the same thing in my commands.upd file : clear cache and update version in DB. But sometimes, I can have extra commands to pass (for ex, when I deploy a new town in my app, I have some jobs to run for initialising the meteo block or stations list or ... This scripts are part of my app but I need to call them. So I used to have so far most of the time the same commands.upd file that I extend for a given release with some required commands. I would like to do the same without modifying the fabfile.py (to avoid that at next release there are some old scripts that would be run because they were forgotten). Is it clear enough ? Something like that (different commands may execute on different servers with few fab commands), i'm make. For example. Input data: users, groups from several servers (20-30 or more). Some users can be on one or few servers. Need: after inspecting users, i have list (exported to file of course :)) with hosts, users and needed actions (for users for example: block, disable password, change password (password length can be different), create sudo %rule for some group (or for group of some user), add user(s) to group, etc). After that, when i'm execute fab with special command(s), this file loaded, parsed and use env.roledefs, and other combination inspect module, globals() and other, run specified actions (with needed parameters) only on needed hosts. In other varian, i'm make fabfile for deploying oracle ias applications. Several applications on production and testing servers with one fabfile and few commands. But all settings (paths, servers, applications names) for this applications (testing and production) change not very often, and so all this settings i'm write in few python dictionaries. and after run (for example) fab beta deploy, i'm пуt deployed application on testing environment beta (but fabfile, and other included modules, don't contain function beta in this case :)). and if i need new testing environment (gamma), i'm just add new parameters to dictionary, and i can run deploy command fab gamma deploy. in internals, on loading fabfile, i'm analysing fab command line parameters (and change it), based on this command-line parameters and parameters for environments, i'm generating need small functions (that contains atomic functions with passed parameters), and export generated functions to global. and fab can run this on-fly generated functions. Again, however, we have plans to make that a lot easier or automatic, in the future. Ok, thanks for the information - Will try to see what can I do with the current .stderr, before 1.0 lands. Nicolas i'm also try solve this problem with logging. for now, i'm sometimes use decorated fabric functions (run, sudo, and so on). decorator just turn off all function output and redirect stdout with stderr to logging module. and this decorated functions use in fabfile. -- WBW, Unatine mailto:unat...@gmail.com xmpp:unat...@unatine.ru ___ Fab-user mailing list Fab-user@nongnu.org http://lists.nongnu.org/mailman/listinfo/fab-user