[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: is Ansible easy to use?




On 20/10/2022 15:47, Anssi Saari wrote:
Philipp Ewald <philipp.ewald@digionline.de> writes:

Hi folks,

is ansible a easy way to configure customized hosts?
First try, its super complicated for me.
For me it has been. ssh loops work too though. Sometimes I've felt
Ansible whines needlessly, something like "please don't do what you need
to do, do it our backward way instead". I think that was about editing a
file with sed.

Ansible's philosophy is "idempotency". That is, instead of having a script that, for example "Adds a user to /etc/passwd", Ansible defines a configuration to "ensure that the user exists in /etc/passwd".

The difference between the two approaches comes when you re-run the script. If you have a script that simply append a line to a config, then you'll quickly end up with duplicated lines. But with the ansible philosophy, if the line is already there, then there are no changes to be made.

By buying into the Ansible philosophy, you get the benefit of all the core and community modules where people have already coded all the hard bits of "Find matching lines", "Rewrite the file atomically", "Handle ACLs and SELinux contexts" and all those things you might not already think of.



Trying to create multiple files with content. It takes more time to
create the playbook then creating this file by hand (this damn syntax
acomplicates everything more)
Then formatting is destroyed or need more time on creating the playbook...
Are you sure you aren't over complicating things? To me that sounds like
you need to copy a few files over? Or do you need to create host specific
files? But do they have to be created by Ansible?

It is so hard or im so bad?
I use ansible a little sometimes to propagate config stuff in my little
home network like firewall configuration and such. So, copying files and
running commands mostly. Sometimes appending lines to config files.

I don't really understand why Ansible has two interfaces, the playbook
one and the normal command line. But, for my simple needs running stuff
on the command line works and I have a bunch of notes on how to do
things. Unfortunately pretty much every example online seems to use
playbooks.
You can't check a command line into code control. You can basically only run one task or one role from the command line. But this is just the same as writing a script versus executing the commands at the bash prompt.

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


Reply to: