Giter VIP home page Giter VIP logo

Comments (17)

sebastien avatar sebastien commented on June 16, 2024

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.

josephmc5 avatar josephmc5 commented on June 16, 2024

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.

sebastien avatar sebastien commented on June 16, 2024

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.

 avatar commented on June 16, 2024

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.

schacki avatar schacki commented on June 16, 2024

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.

sebastien avatar sebastien commented on June 16, 2024

@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.

 avatar commented on June 16, 2024

Yes, of course, I'll try reuse the dispatch decorator. Also, will read issue #40.

from cuisine.

prune998 avatar prune998 commented on June 16, 2024

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.

sebastien avatar sebastien commented on June 16, 2024

As I don't use RHEL, all I can do is merge contributions -- feel free to send me what you have!

from cuisine.

prune998 avatar prune998 commented on June 16, 2024

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.

sebastien avatar sebastien commented on June 16, 2024

Thanks! Could you send a pull request or a gist? The indent got mangled.

from cuisine.

prune998 avatar prune998 commented on June 16, 2024

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.

sebastien avatar sebastien commented on June 16, 2024

I don't see the pull request. Did you submit it?

from cuisine.

prune998 avatar prune998 commented on June 16, 2024

done just now. This is my first pull request. Is everything ok ?

from cuisine.

sebastien avatar sebastien commented on June 16, 2024

Yes, thanks a lot!

from cuisine.

dexterbt1 avatar dexterbt1 commented on June 16, 2024

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.

sebastien avatar sebastien commented on June 16, 2024

It's done! 0.2.6

from cuisine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.