I never used Ansible but since a few weeks, I try to figure out what good Ansible could be in comparison with shell scrips–Which proves, at least in my case, that the haunting ad-campaigns they run are effective! After many unsuccessful attempts–which proves how their documentation fail at answering one of the most obvious question–I think I finally got it:.
NowMy conclusion is that over shell scripting, let's watch the introduction video and go randomly asAnsible essentially offers 1. The possibility of checking that a potential new user throughsystem agrees with a desired state, 2. the introduction materialability to integrate with Ansible ans let's compare it to whatTower, which is a skilled shell programmer can produce right-offpaying system that seems to include monitoring abilities. In some important cases, like when implementing the shelfimmutable server pattern, the point 1 is probably not very useful, so the list of advantages is rather thin.
My conclusion isIt seems to me that the benefits offered by Ansible over shell scripting, Ansible essentially offers 1. The possibility of checking that a system agrees with a desired state-scripting, 2.as the ability to integrate with Ansible Towerdocumentation present them, which iscould be sensible in a paying system that seems to include monitoring abilities. In some importantfew handful of optimistic cases, like when implementing the immutable server pattern, well covered by available modules but are small or even hypothetical in the point 1 is probably not very usefulgeneral case. For a skilled shell-programmer, sothese benefits are most likely counter-balanced by other aspects of the list, is rather thintrade-off.
MyBut my conclusion is that the benefits offered by Ansible over shell-scripting, asmaybe only proves how bad the documentation present them, could be sensible in a few handful of optimistic cases well covered by available modules but are small or even hypothetical inintroduction material is at displaying the general case. For a skilled shell-programmer probably, these benefits are most likely counter-balanced by other aspectsactual advantages of the trade-off.this software!
But this maybe only proves how badNow, I propose to watch the introduction video and go randomly as a potential new user through the introduction material is!to Ansible an let's compare it to what a skilled shell programmer can produce in a reasonable time.
be easier to read than the corresponding yum invocation found in a shell-script? Furthermore, anybody who had contact to AppleScript dies laughing when they read “human readable automation”automation.”
1.2 No special coding skills required – What is coding if not writing formal specifications? They haveAnsible has conditionals, variables, so, how is it not coding? And why would I need something I cannot program, that would henceforth be inflexible? The statement is happily inaccurate!
Here Ansible can do “app deployment” – but shell script surely do, “configuration management” but this is a mere statement of the purpose of the tool, not a feature, and “workflow orchestration” which looks a bit pretentious but no example in this document goes beyond what GNU Parallel can do.
To populate the column, they wrote in three different manners that this only needs ssh, which, as everybody knows is a daemon and has nothing to do with these agents pervading the world of configuration management!
EC2 is the computing service from Amazon, interacting with it is supported by some Ansible module. (Other popular cloud computing providers are also provided.):
The largest part of this guide does not display any really interesting feature: it introduces variables (IIRC, shell scripts also have variables)!, and an Ansible module that handles mysql, so that if instead of searching after “how do I create a mysql user with privileges on X Y” and end with something like
# Create Applicationcreate_application_db_user()
{
DB User
mysql --host "${mysql_host}" --user "${mysql_user}" --password "${mysql_password}" "${mysql_table}" <<EOF
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
EOF
}
The documentation of Ansible draws the attention on the necessity of writing idempotent configuration steps. More precisely, configuration steps should be written so that the step sequence a b a can be simplified to a b, i.e. we do not need to repeat configuration step. This is a stronger condition than idempotency. Since Ansible allows playbooks to use arbitrary shell commands, Ansible itself is unable to guarantee that this stronger condition is respected. This only relies on the programmer's discipline and the importance of this variation of idempotency when writing configuration scripts is certainly not a novelty.
Post-Scriptum. Since this answer seems to enjoy a relative popularity, I fixed a few embarrassing syntax errors and typos. By a twist of life I also had to use Ansible two years in my work. Overall my experience confirms what I foreseen here and I hardly can think about a situation where shell scripts would have been really outperformed by Ansible. On some aspects, Ansible is just worse than shell scripting. At least the shell has functions, these functions can be mocked, it is possible to test part of all of them, so overall the shell has much better software engineering features than Ansible has. In a shell script it is also possible to process data and awk can express all what SQL can, which is very important when programming configuration – the information we are working with here is not intrinsically hierarchical, so there is a need for extracting an rewriting. Ansible is so bad at extracting and rewriting data! Treatments must be expressed with a mixture of YAMl-templating at the playbook step level and a dialect of Jinja at the dictionary member level… this is cumbersome, ugly, hard to write, hard to test and poorly documented (I regularly looked up the Jinja filter implementations!).