hello all,
i started recently to look at ansible and, so far, it’s a great
tool that amazes me and helps me in my work.
At the moment i’m puzzled with the following problem and i’m not
sure if ansible is able to solve it and if so, what is the best practice to do that.
Suppose i have a service to update, let’s suppose for simplicity it’s
apache and i just need to change some virtual hosts.
For sake of simplicity let’s say i’m using a directory conf.d so given /etc/apache2/apache.conf
as the main config file, i put all my virtual hosts file inside a directory named
/etc/apache2/sites-enabled/ carefully putting one virtualhost per file.
In this way i can easily change VirtualHost configuration without modifying my main config
and test config syntax by using command “apachectl configtest”; if that command goes OK
i can safely restart apache otherwise i need to figure out what was wrong
This solve all those typo and syntax problem you may end up (e.g. adding a proxy pass directive
without having mod_proxy enabled and so on) while multitasking .
Now let’s suppose i have to do the same thing on 30 servers, i don’t want just to pull config files
inside /etc/apache2/sites-enabled/ , do apachectl configtest and if it fail print a warning and
revert back to old config for all hosts and warn me; if the command succedes then restart apache.
Does ansible support such a complex task? if so, what is the best practice to do that?
so far i could only thing of something like “one master, many slaves” in which there’s a
master apache to pull all my config to all the other slaves but i fail to see how to revert back
to old config in case of failure.
The other solution would be based on git/svn where last config resides: every apache “pulls” config
from that git and in case of fails revert to the previous but even this one doesn’t seems to be a viable
one.
Am i on the right track, or i’m simply using ansible for something it wasn’t build for ?
Many Thanks
Samuele