hercules-team / augeas

A configuration editing tool and API
http://augeas.net/
GNU Lesser General Public License v2.1
486 stars 199 forks source link

nginx lens doesn't support recursive blocks #179

Closed jeffNagra closed 9 years ago

jeffNagra commented 9 years ago

As discussed with Raphink....

The nginx lens is failing the parse even the default nginx.conf supplied with the nginx package (below)…

set /augeas/load/nginx/lens "Nginx.lns" set /augeas/load/nginx/incl "/home/root/jeff" load print /augeas//error

/augeas/files/home/root/jeff/error = "parse_failed" /augeas/files/home/root/jeff/error/pos = "410" /augeas/files/home/root/jeff/error/line = "20" /augeas/files/home/root/jeff/error/char = "0" /augeas/files/home/root/jeff/error/lens = "/usr/share/augeas/lenses/dist/nginx.aug:61.10-.57:" /augeas/files/home/root/jeff/error/message = "Iterated lens matched less than it should"

Full default nginx.conf (comes with the nginx RPM):

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    index   index.html index.htm;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        server_name  localhost;
        root         /usr/share/nginx/html;

        #charset koi8-r;

        #access_log  /var/log/nginx/host.access.log  main;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page  404              /404.html;
        location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        }
    }
}
raphink commented 9 years ago

The Nginx lens is not recursive (yet).

craigloftus commented 9 years ago

The letsencrypt project is using Augeas for apache support, and would like to use it for Nginx as well.

I copied lvm.aug to add support for recursion (04cb46d8a), but I am lost as to how to support the location block syntax. The syntax for lenses has me baffled.

lutter commented 9 years ago

@craigloftus could you have a look at PR #225 and let me know if (a) that updated lens covers everything you'd need and (b) if the tree it produces is reasonable for your pruposes, especially how 'if' and 'location' directives are parsed ?