Hi
I have a situation where I have several web servers that are load balanced
and are updated daily through Octopus.
Although we still have issues when uses will go onto the Windows machines
and manually edit config files (Eg: web.config file).
Is there anything that Ansible can do to check that all web.config files
are identical, and if a change is made to one of them it fails?
I would like to run a scheduled playbook that checks that all the we.config
files are identical and if one has been changed it fails....and if possible
can show where the file has been changed?
I have been playing around with the following below, and although it works
to a certain point, its just not what im looking for.
So really just trying to find out if there is something that I dont know
about? Or some options I can look at?
Tried the below playbook, and it works great. But if the web.config is
changed everyday through Octopus, then the md5 changes. Which means I would
need to edit this everytime there is an update?
- name: Check Web.config file
hosts: all
tasks:
- name: Stat the web.config file
win_stat:
path: C:\Websites\Live\Web.config
register: hosts_fileinfo
- name: show web.config file stats for debugging purposes
debug:
var: hosts_fileinfo
- name: fail file not there
fail:
msg: "WEB.CONFIG file is missing"
when: hosts_fileinfo.stat.exists != true
- name: fail if modified
fail:
msg: "WEB.CONFIG file has been modified"
when: hosts_fileinfo.stat.checksum !=
"7ebf68e867b5b51570758ba81fd23258f1da9029"
Tried the below to search for a line in the file on all the servers, and it
works. But if a file is missing this line, it just puts it at the bottom of
the file. Which doesn't help....I would need it to look like all the other
web.config's?
---
- name: Check if line is present in config
hosts: all
tasks:
- name: Check if line is present in config
win_lineinfile:
dest: C:\Websites\Live\Web.config
regexp: <error statusCode="500" redirect="~/Errors/500page" />
line: ' <error statusCode="500" redirect="~/Errors/500page" />'
I really just want a playbook that validate that all config files are
always uniform, and if possible tell me if something has manually be
changed and what?
Cheers
Mark
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/f2ce3221-e8aa-4b2f-8270-6a26002bfd94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.