user1994660 user1994660 - 1 year ago 89
Linux Question

Which is the best way to make config changes in conf files in ansible

Initially I used a

to deploy my application in

I had various
commands to replace variables like the PHP upload file size, post size, log file location etc.

Now I am shifting to ansible. I know I can copy the files, but how can I make changes to the conf files? Like if i just want to change the
upload_filesize = 50M
parameter. I don't want to make copies of the whole conf file and then replace with my file.

Sometimes it’s only a one-line change. Is there any better way to edit the config files in ansible?

Answer Source

If it's an INI file, then your specific requirements can be probably met by ini_file module (

If your change is limited just few lines (or eve one), then you can probably look at lineinfile module (

Should you however need to change large number of settings, then it may be more beneficial to use template ( or assemble ( The main disadvantage of this approach is that you may need to review your template or fragments when updating your dependency.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download