5 ms·
What seems to be missing is _updating_ the nginx.conf with sed or something. In the article, you're just copying a new magic configuration from somewhere vs. "
by hbbio 13y ago
What seems to be missing is _updating_ the nginx.conf with sed or something.
In the article, you're just copying a new magic configuration from somewhere vs. "proper" sed use (in reality, it can be a bit more than that) in the shell script.
- asb 13y agoAugeas is a safer way of updating config files http://augeas.net/ http://augeas.net/, though I have to admit I've mostly ended up just using sed myself.
- mpdehaan2 13y agoLenses are hard for people to write and error handling is poor though, so it can be very frustrating. The lineinfile method does work fine for simple files, and there's also an INI file module. In most cases, we recommend using the 'template' module for this reason, in cases where you know what you'd like to put down for the file contents.
- mattjaynes 13y agoInitially I was using Ansible's `lineinfile` module to do exactly that. It's pretty trivial to do if you want to compare true Apples to Apples. Here's an article with some examples: http://fabian-affolter.ch/blog/the-lineinfile-module-of-ansible/ http://fabian-affolter.ch/blog/the-lineinfile-module-of-ansi... However, I wanted to show the actual process I went through. Editing the file in place seemed silly to do with Ansible, so I went with putting the config file in version control and copying it over. That also had the benefit of showing how Ansible encourages better practices than shell scripts. Of course, that's totally subjective, so for some folks that use shell scripts, they may already know to put their config files in version control. However, in practice, I've not seen that be the case.
- tfinch 13y agoAlso worth noting, ansible comes with a 'template' module which allows you to generate custom files with variables.
- dalore 13y agoProper way is to install a known version of nginx and use a known conf, not editing some file which might be different based on linux distro or package maintainer.
- hbbio 13y agoProblem is sometime platforms differ a bit, so it's better to patch the config file. For instance (I know there's vagrant and stuff), I develop on a Mac but deploy on linux. My sed handles that pretty well.
- dalore 13y agoThe platforms may differ, but a known version should be able to use the same config on the different platforms.
- hbbio 13y agoJust looked up a real "sed" example in linux vs linux. DigitalOcean ships VM that don't have an admin group. So when I tried DO, I added: grep -q 'admin' /etc/group || groupadd admin Or, for changing the sshd port: sed -i -r 's/^#?Port [0-9]*/Port '"$PORT"'/' /etc/ssh/sshd_config Works great on all platforms... regardless of the default sshd_config.
- dalore 13y agoYou realise that the tools like ansible are made for making sure the groups and users you specify in your config are going to be on the server? That's the point of them. Don't rely on a presetup environment, you'r ansible scripts should setup the environment for everything you need.
- txutxu 13y agoIf the compile options in both platform matches. And nginx is full of compile options and modules to enable and disable, so maybe "the same config in the same version" does not work on different platforms.