Re: Marelle: prolog for devops
Lars Yencken <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CAFC4A57f1vbTyEgWHVuxd91oRCYx81Ojsue4Eziti2SEL5Z7fg@mail.gmail.com> |
On 8 November 2013 00:31, Michael Hendricks <[email protected]> wrote: > On Nov 7, 2013 1:49 AM, "larsyencken" <[email protected]> wrote: > > At it's core, you define a handful of rules which describe a target, how > to > > check if it's been met, and how to meet it. For example, to install > > supervisor Ubuntu 12.04: > > > > pkg(supervisor). > > met(supervisor, linux(precise)) :- > > isfile('/usr/bin/supervisorctl'). > > meet(supervisor, linux(precise)) :- > > bash('sudo apt-get install -y supervisor'). > > That's a cool idea. Is there a convenience for working with package > versions? For example, to declare that 'supervisor' is the most recent > version available or has version greater than X? > I haven't pre-built many of those kinds of rules, mainly because my main use case is bootstrapping new systems from a stock base. In that situation, either the package is there, or it's not. All of the above example can be shortened to: pkg(supervisor). installs_with_apt(supervisor). installs_with_brew(supervisor). which in turn can all be shortened to: managed_pkg(supervisor). If you want the ubuntu packaged version, whatever that version is. Since supervisor is a Python package installable with pip, the pip version of the rule supports a spec, but it will only use it when installing a new package. To work with Python's packaging system instead, our rule would look like: pkg(supervisor). met(supervisor, linux(precise)) :- bash('python -c "import supervisor"'). meet(supervisor, linux(precise)) :- bash('sudo pip install supervisor'). This is common enough to be shortened to: python_pkg(supervisor). % handles pkg/1 and met/2. installs_with_pip(supervisor). % handles meet/2 This is also common enough to have shorthand: pip_pkg(supervisor). We can give pip a more specific target for this package name to get a version we want: pip_pkg(supervisor, 'supervisor>=3.0'). I general, you can easily put together these kinds of rules yourself for new packaging systems, or extend them as you like. Hope that's helpful :) Lars -------------- next part -------------- HTML attachment scrubbed and removed