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

回眸只為那壹抹淺笑 提交于 2019-11-30 03:10:56

问题


Initially I used a makefile to deploy my application in linux.

I had various sed 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?


回答1:


If it's an INI file, then your specific requirements can be probably met by ini_file module (http://docs.ansible.com/ini_file_module.html).

If your change is limited just few lines (or eve one), then you can probably look at lineinfile module (http://docs.ansible.com/lineinfile_module.html).

Should you however need to change large number of settings, then it may be more beneficial to use template (http://docs.ansible.com/template_module.html) or assemble (http://docs.ansible.com/assemble_module.html). The main disadvantage of this approach is that you may need to review your template or fragments when updating your dependency.




回答2:


Depending on the operating system, you can add files here /etc/php/apache2/conf.d/10-someinifilewithsetting.ini



来源:https://stackoverflow.com/questions/22339832/which-is-the-best-way-to-make-config-changes-in-conf-files-in-ansible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!