Comment on What's the real difference between a shell script and Ansible (and which should I use)?
rtxn@lemmy.world 1 week ago
Ansible is an abstraction layer over system utilities, shell, and other programs. You can specify what you want to happen, and it will figure out how to do it. For example, you can use the ansible.builtin.package module to specify which packages you want to be present, and Ansible will decide which specific package manager module should handle it and how.
Ansible tasks are also idempotent – they are concerned with the end state instead of the action. Many of the modules (like the package
module above) take a state
parameter with the possible values of present
or absent
(instead of the more common “install” and “remove” actions). If the system’s state satisfies the task’s expected end state (e.g. the package is already present), the task will be skipped – unlike a shell script, which would simply re-run the entire script every time.
Ansible also implements strict error checking. If a task fails, it won’t run any subsequent tasks on the host since the end states would be unpredictable.
ChapulinColorado@lemmy.world 1 week ago
Great summary “a lot of common error checking has gone into it. It can be told what you want without specifics that would only potentially be applicable to 1 system type.”