ansible-nginx
ansible-nginx copied to clipboard
nginx_servers not deployed
whenever I run the nginx role, it seems to avoid the nginx_servers variable I've set. It looks like this:
nginx_servers:
-
enabled: True
name: [ 'hmsvr' ]
type: 'custom'
filename: 'usenet'
options: |
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
Using debops ansible-debug I've confirmed that this variable is set correctly when I run the nginx role. But when the role gets to the "Generate nginx server configuration" task, the output is something like this:
ok: [hmsvr] => (item={'index': 'index.html index.htm index.php doku.php', 'name': [u'wiki.home.leviwheatcroft.com'], 'root': u'/srv/www/dokuwiki/sites/wikihmsvr/public', 'enabled': True, 'by_role': 'debops.dokuwiki', 'options': u'autoindex off;\nclient_max_body_size 30M;\nclient_body_buffer_size 128k;', 'php5_options': 'fastcgi_intercept_errors on;\nfastcgi_ignore_client_abort off;\nfastcgi_connect_timeout 60;\nfastcgi_send_timeout 180;\nfastcgi_read_timeout 180;\nfastcgi_buffer_size 128k;\nfastcgi_buffers 4 256k;\nfastcgi_busy_buffers_size 256k;\nfastcgi_temp_file_write_size 256k;\n', 'php5': 'php5_dokuwiki', 'type': 'php5', 'auth_basic_realm': u'Wiki access is restricted', 'access_policy': u'', 'location': {'~ /(data|conf|bin|inc|install.php)/': 'deny all;\n', '~ ^/lib.*\\.(gif|png|ico|jpg)$': 'expires 31536000s;\nadd_header Pragma "public";\nadd_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";\nlog_not_found off;\n', '@dokuwiki': 'rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;\nrewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;\nrewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;\nrewrite ^/(.*) /doku.php?id=$1 last;\n', '/': 'try_files $uri $uri/ @dokuwiki;\n'}})
This host is a member of the dokuwiki group, and has dokuwiki installed. In trying to figure this out I was thinking that maybe dokuwiki config is overriding my custom nginx config, but I'm having trouble even figuring out how dokuwiki role defines it's nginx config.
Sorry to bother you with something so silly, but I'm stuck.. sorry!
You go that right. Since you enabled only [debops_dokuwiki] on this host, nginx role is run in debops.dokuwiki context, which overrides default nginx_servers list with its own.
When you add that host to [debops_nginx] group, and run debops -t nginx, it will have "its own" set of tasks which then will use configuration from Ansible inventory to set up a nginx server configuration.