2 ms·
You can run sequential commands with ansible, but then you're just using it as a replacement for "ssh $host < script.sh". You would be missing out on most of th
by xorcist 3y ago
You can run sequential commands with ansible, but then you're just using it as a replacement for "ssh $host < script.sh". You would be missing out on most of the usefulness of the tool. It's meant to be used declaratively. The manual describes it quite well. In the same type of tools are puppet and indeed nix, but with one important difference for the latter: nix is also a package manager, which allows for more a fine grained state specification.
- matrss 3y agoTrue, nix is also a package manager, and that is the crucial step necessary to actually provide a declarative interface to system state. Without it you can only get the leaky abstraction that is ansible. To illustrate my point, imagine this playbook: --- - name: Bring system into some state hosts: localhost tasks: - name: Install hello ansible.builtin.apt: name: hello become: true Apply it and you get GNU hello installed. Now remove the package installation step, which really is just a glorified "ssh $host < script.sh": --- - name: Bring system into some state hosts: localhost tasks: Apply that and you will still have hello installed, even though it was removed from the "declared state". This just pretends to be declarative but really isn't, the tasks are still imperative steps. Not to blame ansible for this, it is just that ansible is build on a foundation that inherently makes declarative system management impossible to begin with and ansible is more or less the best thing you could do given the constraints.