Unrelated: What you have done above is redefined the host record. In the second case you are overriding the variables for the host. To fix this, instead do:
[webservers] webservers ansible_ssh_user=root [dbservers] dbservers ansible_ssh_user=root Since you are definining "ansible_hostname" it won't use the IP address to contact things anyway. I'm unclear why your template is not working, though this may be something else not shown above, such as it using the wrong template file, etc? On Mon, Dec 16, 2013 at 8:34 AM, Marko Lisica <[email protected]>wrote: > Hello here s contents of my hosts file. I have separate files for staging > and vagrant. > > marko@FOX:~/iom/provision$ cat staging >> [webservers] >> 192.168.0.173 ansible_hostname=webservers ansible_ssh_user=root >> [dbservers] >> 192.168.0.173 ansible_hostname=dbservers ansible_ssh_user=root >> > > > > >> marko@FOX:~/iom/provision$ cat vagrant >> [vagrant] >> 33.33.33.14 ansible_hostname=vagrant >> > > > On Monday, December 16, 2013 8:37:58 AM UTC+1, Marko Lisica wrote: >> >> Hello, I am trying to make simple NGINX template. I have development >> inventory (it is vagrant) and staging which is remote VPS. I want to make >> different default root folder and different log location for these two >> environments. Ofcorse couldnt manage that :) . >> I have this in my template: >> >> {% if (inventory_hostname in groups['webservers']) %} >>> access_log /var/log/nginx/nginx-access.log; >>> error_log /var/log/nginx/nginx-error.log; >>> {% endif %} >>> >>> >> And for dev environment: >> >> >> >>> {% if (inventory_hostname in groups['vagrant']) %} >>>> access_log /vagrant/log/nginx/nginx-access.log; >>>> error_log /vagrant/log/nginx/nginx-error.log; >>>> {% endif %} >>>> >>> >> Whatever inventory I choose when depoying ansible-playbook I get BOTH of >> cases created in nginx config file. I am obviously missing something here. >> Any advice? >> >> -- > 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]. > For more options, visit https://groups.google.com/groups/opt_out. > -- Michael DeHaan <[email protected]> CTO, AnsibleWorks, Inc. http://www.ansibleworks.com/ -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
