Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Can I configure role do not remove sites-enabled? #173

Closed
zherdev-artem opened this issue Apr 13, 2017 · 3 comments
Closed

Can I configure role do not remove sites-enabled? #173

zherdev-artem opened this issue Apr 13, 2017 · 3 comments

Comments

@zherdev-artem
Copy link

zherdev-artem commented Apr 13, 2017

Thank you for great role.

I learning ansible now, and I just want to have possibility add new nginx sites configs, with an option to delete other sites configs or not, how I can do it?

I'm trying this code example and now I'm always Disable unmanaged sites.

new_site.yml

---
- hosts: lemp
  sudo: yes
  
  vars_files:
    - vars_nginx.yaml

  roles:
    - role: jdauphant.nginx

vars_nginx.yaml

---
nginx_official_repo: True
keep_only_specified: True

vdomain: example.com

nginx_sites:
  "{{ vdomain }}":
    - listen *:80
    - server_name {{ vdomain }}
    - index index.html index.htm index.php
    - access_log /var/log/nginx/{{ vdomain }}.access.log combined
    - error_log /var/log/nginx/{{ vdomain }}.error.log
    - root /srv/www/{{ vdomain }}/
    - location /server-status {
            stub_status on;
            access_log false;
            allow 127.0.0.1;
            deny all; }
    - location /php-status {
            fastcgi_param SCRIPT_FILENAME /srv/www/{{ vdomain }}$fastcgi_script_name;
            fastcgi_pass php;
            include fastcgi_params;
            access_log false;
            allow 127.0.0.1;
            deny all; }
    - location / { try_files $uri $uri/ /index.php$is_args$args; }
    - location ~ .php$ { 
        try_files $uri /index.php =404;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_connect_timeout 60;
        fastcgi_ignore_client_abort off;
        fastcgi_index index.php;
        fastcgi_intercept_errors on;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param SCRIPT_FILENAME /srv/www/{{ vdomain }}$fastcgi_script_name;
        fastcgi_pass php;
        fastcgi_read_timeout 180;
        fastcgi_send_timeout 180;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_temp_file_write_size 256k;
        include fastcgi_params; }

nginx_configs:
  upstream:
    - upstream php { server unix:/var/run/php5-fpm.sock fail_timeout=10s; }`
@jdauphant
Copy link
Owner

The option "keep_only_specified: True" always disable other configuration.

To select manually what you want to remove, you can use these variables:

nginx_remove_sites: []
nginx_remove_configs: []
nginx_remove_snippets: []

@philipwigg
Copy link
Contributor

Hi @mrZherart

Unfortunately it's not possible to user a variable for the site name. This bit won't work:-

nginx_sites:
  "{{ vdomain }}":

This has been discussed a couple of times and there's no solution we know about. See #127 and #88 for example.

@zherdev-artem
Copy link
Author

zherdev-artem commented Apr 13, 2017

@philipwigg For some reason, I have everything working:

nginx_sites:
  "{{ vdomain }}":

I'm using ansible-playbook new_site.yml -e "vdomain=my-super-example.com" and see the required config name in sites-available and sites-enabled

@jdauphant Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants