Hi,
I need to create configuration files for php5-fpm and nginx for many domains. Each php5-fpm’s worker should run on separate port starting from 127.0.0.1:9001 and so on.
I started with the following configuration:
- role: webserver
sites:
- name: user
site: - test.com
- test.org
- name: mike
site: - domain.com
- domain.org
tasks:
-
name: create nginx-domain.conf
template: src=nginx-domain.conf.j2 dest=/etc/nginx/conf.d/{{ item.1 }}.conf backup=yes
with_subelements: -
sites
-
site
notify: Reload nginx -
name: create php5-fpm-domain.conf
template: src=php5-fpm-domain.conf.j2 dest=/etc/php5/fpm/pool.d/{{ item.1 }}.conf backup=yes
with_subelements: -
sites
-
site
notify: Reload php
nginx-domain.conf.j2:
server {
listen 80;
server_name {{ item.1 }};
error_log /home/{{ item.0.name }}/logs/{{ item.1 }}.error.log error;
access_log /home/{{ item.0.name }}/logs/{{ item.1 }}.access.log combined buffer=16k flush=1m;
root /www/{{ item.0.name }}/domains/{{ item.1 }}/public_html/;
set $sock 127.0.0.1:{{ counter }}
include fastcgi_params;
fastcgi_index index.php;
fastcgi_intercept_errors on;
fastcgi_param DOCUMENT_ROOT /public_html;
fastcgi_param SCRIPT_FILENAME /public_html$fastcgi_script_name;
index index.html index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~* .php$ {
try_files $fastcgi_script_name =404;
fastcgi_pass $sock;
}
}
so, i need to increase {{ counter }} starting from 9001 in a template for every domain to use it in line ‘set $sock 127.0.0.1:{{ counter }}’, but i don’t know how to do that. i didn’t find anything useful via google/stackoverflow.
Maybe you can give me a hint or even some examples in which way to dig?