@stacksofplates said in wetting my feet with CM software:
@matteo-nunziati said in wetting my feet with CM software:
@stacksofplates said in wetting my feet with CM software:
@matteo-nunziati said in wetting my feet with CM software:
it can leverage full Jinjia2 templating straight inside state files (playbooks) letting you avoiding to split playbooks or add all of those ‘when’ directives all around;
See, I don't see this as a plus. You can do full j2 templating with Ansible also, but why? Why are you splitting playbooks?
You can't do full j2 in templates. j2 is a plus to me because I've been exposed to j2 for at least 1,5 years and it is really handy to me.
That is trying to use Jinja2 syntax in a yaml file, obviously it's not going to work. You can do full j2 templating in the j2 templates, not the playbooks.
mmm... AFAIK roles are useful to discriminate between functions, like webserver, database server and so... but when you have to manage heterogeneous OSes like CentOS and Ubuntu I'd like to prefer the {%if %} {%else%} approach of Salt.
In my small trip around ansible I've had to put a lot of whens all around. The alternative was to write a playbook for the webserver role of CentOS and one for the webserver role of Ubuntu, and then include both into an "abstract" webserver playbook.
Unless I'm missing something, having an if/else turned more handy to me.How do you cope with different OSes and how do you abstract away differences with Ansible in your daily job?
All of that functionality should be in the role. The role should be standalone so it can run on any machine, that "logic" shouldn't be in the playbooks. For example, a role that installs apache could be set up like this:
main.yml has your include and conditionals:
--- - include: rhel.yml when: ansible_os_family == "RedHat" - include: ubuntu.yml when: ansible_os_family == "Debian"
Then the specific tasks for each would be included in those yml files.
There are other ways to do this, like using variables in conditionals for package names, but this is a simple setup. That way you need one conditional at the beginning.
Take a look at how people set things up on Ansible Galaxy. The playbooks should only tell what roles to run on what hosts. So a site.yml is your main playbook that has includes for everything, and then you can break out your playbooks into dev, test, and prod machines. Or however you want to separate them.
yes, that's what I was thinking of. in Salt you do this by writing a single file with an if/else statement, beacuse you can mix yaml and jinja. You just have a single webserver.sls. I simply feel more comfortable with this approach because all the logic is in one place.
I mean: if you have tasks which are common to RedHat and Ubuntu, you put them into the main.yaml I suppose, to not duplicate code. At that point if you have interleaved common/specific tasks you have to create a lot of fragmentation with all that includes and a number of "micro" files, or you end up duplicating code in files to have less fragmentation...
I can't imagine otherwise... I'll look at Galaxy.