Comments (17)
Hi Vlad!
Thanks a lot, that's wonderful news. You actually found the best solution I think, as I would like to keep cuisine a simple, flat, 1-file module. In the same line of thinking, we could:
- Rename existing package_* functions to apt_* functions
- Add your yum functions as yum_* functions
- Add a package_mode_apt and package_mode_yum functions that set a variable (preferrably in Fabric's env) to indicate the package engine
- Rewrite the package_* so that they dispatch to the proper apt_* or yum_* function according to the mode
Thet new package_* functions could be like:
def package_ensure(*args,**kwargs): return (eval(env.package_mode + "_ensure"))(*args,**kwargs)
or we could even create a decorator to do that automatically. If that sounds too much work, then I could maybe just clone your branch and do the manual integration.
from cuisine.
This would be great for me as well. We have a mixed Centos/Ubuntu environment. Great to see we aren't the only ones!
from cuisine.
I just added the @dispatch decorator (see package_* functions). It is documented in the README, so it is now easy for you guys to contribute specific backends.
from cuisine.
Sorry for a bit late reply, I was tied in with something else. My modifications are currently working fine, but need a bit more testing before I submit a pull request. I think the best approach so far is a simple if-else branch, or a map of methods. For example: packagers["rhel"]["install"] = yum_install. It might also be possible (but is it wise?) to do autodetect of distribution based on existence of individual package managers. I'll try a method map and see how that pans out for various conditions. Also note it is not just package management. For example adding user with password currently only CRYPT-s it, while on CentOS default is sha512. Also I've removed all sudo() calls and replaced with run() so that they all use the global config MODE* to deremine whether to fab.api.run() or fab.api.sudo()
Edit: I can't get stupid GFM not to parse underscores.... meh.
from cuisine.
Hi Vlad,
I think your thoughts around if-else, map of methods, parsing underscores have been resolved already by Sebastien's dispatch approach.
Regarding removal of sudo, ... please also check my issue #40.
Regards,
Juergen
from cuisine.
@VladK78 I think you should use the new "dispatch" decorator, as it provides a mechanism to implement specific backends -- I realize it would have been better if I had worked on it before, as it means a little bit of extra work for you. If you think it's too much, I can try to manually integrate your branch myself.
In general, whenever you have a platform-specific option, you should use @dispatch. To detect the Linux distro, you can read /etc/lsb-release (and we could provide a wrapper for that in cuisine).
@schacki will read issue #40, thanks!
from cuisine.
Yes, of course, I'll try reuse the dispatch decorator. Also, will read issue #40.
from cuisine.
Any news on this request ?
I also did a modification for yum and will try to do more changes if needed in the coming month... Let me know if I can test any of your modifications.
Great job sebastien !
from cuisine.
As I don't use RHEL, all I can do is merge contributions -- feel free to send me what you have!
from cuisine.
For the moment I just added the yum options to the package_update part.
I also added a package_clean command to APT so the function exist for every variation :
def package_clean_apt(package=None):
pass
-----------------------------------------------------------------------------
YUM PACKAGE (RedHat, CentOS)
-----------------------------------------------------------------------------
def repository_ensure_yum(repository):
pass
def package_upgrade_yum():
sudo("yum --assumeyes update")
def package_update_yum(package=None):
if package == None:
sudo("yum --assumeyes update")
else:
if type(package) in (list, tuple):
package = " ".join(package)
sudo("yum --assumeyes upgrade " + package)
def package_upgrade_yum(package=None):
sudo("yum --assumeyes upgrade")
def package_install_yum(package, update=False):
if update:
sudo("yum --assumeyes update")
if type(package) in (list, tuple):
package = " ".join(package)
sudo("yum --assumeyes install %s" % (package))
def package_ensure_yum(package, update=False):
status = run("yum list installed %s " % package)
if status.find("No matching Packages") != -1 or status.find(package) == -1:
package_install(package)
return False
else:
if update: package_update(package)
return True
def package_clean_yum(package=None):
sudo("yum --assumeyes clean all")
from cuisine.
Thanks! Could you send a pull request or a gist? The indent got mangled.
from cuisine.
I had to checkout the new changes before submitting a pull... :)
Again, this is bare modification for yum and I'm not a yum expert. What I've tested is working on Cent OS 6 (should work on any RHEL compliant OS).
from cuisine.
I don't see the pull request. Did you submit it?
from cuisine.
done just now. This is my first pull request. Is everything ok ?
from cuisine.
Yes, thanks a lot!
from cuisine.
Can you release this to pypi? I think this is good to go.
I'd like to add this updated version to our pip requirements file.
from cuisine.
It's done! 0.2.6
from cuisine.
Related Issues (20)
- group_user_ensure fails in suse 11 sp3 HOT 5
- `user_create` function appears in duplicate HOT 1
- cuisine.file_write fails with 7.6 and 7.7 HOT 2
- Why `apt_get` function executes a command twice?
- What is changed between version 0.7.6 and 0.7.7? HOT 6
- SyntaxError: 'invalid syntax' cuisine.py at 342 HOT 1
- how to set up attributes (chef like ) in cuisine HOT 1
- `dir_ensure` tries to create the directory even if it exists HOT 3
- Please rename "bsd" features "freebsd" HOT 2
- file_upload() behavior for lcd context incompatible with fabric put() HOT 4
- Using hashlib breaks compatibility with CentoOS 5 HOT 2
- package_ensure_apt(package_name, update=True) upgrade all package not only selected HOT 2
- Newline at end of updated text
- process_find can't find processes due to leading spaces. HOT 3
- trapping fabric.exceptions.NetworkError HOT 3
- NameError: name 'env' is not defined HOT 2
- README links
- Support for Fabric 2.x? HOT 1
- Fix simple typo: referes -> refers
- Python 3 support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cuisine.