New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Comments
Also use apt-mark auto|manual|showauto|showmanual to keep the package selections (automatic vs manual) - it is very useful.
Other useful tool: dpkg-query
e.g:
apt-mark showauto | xargs dpkg-query -f '${Package;-30} ${Version;-20} \ ${Installed-Size;6} ${Architecture;6} ${Status} auto\n' -W
apt-mark showmanual | xargs dpkg-query -f '${Package;-30} ${Version;-20} \ ${Installed-Size;6} ${Architecture;6} ${Status} manual\n' -W
Tweak to suit your tastes/needs.
The output can later be reparsed and fed as input to dpkg --get-selections (etc.
YMMV.
Edited: Split the above example commands across lines to improve readability
You're probably thinking of declarative package installation (which is what NPM does with package.json). This isn't really possible system-wide in most distributions, because they're designed to be stateful and can't be rebuilt from a specific configuration; however, specialized distributions like NixOS do provide this kind of thing.
You can also use Nix (the package manager) on other distributions, but that'll only give you limited declarative functionality - eg. no service setup, driver/kernel management, etc.
Some more reading material about NixOS:
However, a word of caution: it will likely take months to become familiar enough with NixOS to use it in production. It's not just another Linux distribution; it's designed completely differently from traditional Linux distributions (which is a necessity to make it work), and you'll have to effectively re-learn most of Linux. The documentation and general usability of Nix also isn't where it should be, yet, so you'll sometimes have to figure out some problems for yourself.
I personally feel that it's worth it, and I'm currently slowly switching everything over to NixOS, but your tradeoffs may vary.
To address other suggestions: yes, you can save a list of installed packages and reinstall this list later. However, on stateful distributions like Debian, there's absolutely no guarantee that you'll actually end up with the same package set or that it will work the same - even installation order can matter.
That doesn't even address the problem of configuration yet, which is a pretty much impossible thing to reproduce like that on a stateful distribution.
There is configuration management which makes it easy to stand up duplicate servers. You define the packages to install, their config files, and the program takes care of getting the server in to the defined state.
To name a few: Ansible, Salt, Puppet
It doesn't, though. Basically all of these tools are purely additive, covering only the things you explicitly specify. Other parts of the system remain untouched and may interfere with your 'additive specifiation', for lack of a better term. That's also what this article is about.
In other words: it's still imperative. It doesn't get your server to a defined state, it just takes the actions that you've specified.
That's true. But apart from the purity side of stateless, if your requirement is something like "I want X,Y,Z installed, with such and such configuration for each", then these tools can get you to it.
They can, most of the time, but they can't do so reliably. That's where the problem is. There are too many factors outside of the control of the orchestration tool that can make a deployment fail, even if it worked on 200 other machines.
This can be an acceptable tradeoff depending on the situation, but it's important to recognize that these tools are just fundamentally incapable of doing it perfectly