From 72ccc89765c3205e13530b0639ac740012c106d9 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Sat, 21 Jan 2017 16:05:53 +0300 Subject: [PATCH] Add server configuration playbook --- Makefile | 3 +++ ansible/configuration.yml | 16 +++++++++++++++ ansible/roles/nginx/templates/site.conf.j2 | 4 +++- ansible/vagrant-provision.yml | 22 +++++++++++++++++++-- ansible/vars/all.yml | 23 ---------------------- 5 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 ansible/configuration.yml delete mode 100755 ansible/vars/all.yml diff --git a/Makefile b/Makefile index c2424c0..b6c7d7a 100644 --- a/Makefile +++ b/Makefile @@ -4,3 +4,6 @@ deploy: rollback: ansible-playbook --inventory "ansible/hosts_prod" --user=deployer ansible/rollback.yml + +configure: + ansible-playbook --inventory "ansible/hosts_prod" --user=av --ask-become-pass ansible/configuration.yml diff --git a/ansible/configuration.yml b/ansible/configuration.yml new file mode 100644 index 0000000..1fc614c --- /dev/null +++ b/ansible/configuration.yml @@ -0,0 +1,16 @@ +--- +- hosts: all + become: true + + vars: + timezone: UTC + nginx_conf_name: 'anwinged.ru.conf' + nginx_conf_root: '{{ application_root }}/current' + nginx_conf_domain: 'anwinged.ru' + + nginx_remove_default_vhost: true + + roles: + - yatesr.timezone + - geerlingguy.nginx + - nginx diff --git a/ansible/roles/nginx/templates/site.conf.j2 b/ansible/roles/nginx/templates/site.conf.j2 index de18b12..dc4612b 100755 --- a/ansible/roles/nginx/templates/site.conf.j2 +++ b/ansible/roles/nginx/templates/site.conf.j2 @@ -5,8 +5,10 @@ server { location / { root {{ nginx_conf_root }}; index index.html; - try_files $uri /index.html; + try_files $uri $uri/ =404; } + {% if not nginx_conf_sendfile|default(true) %} sendfile off; + {% endif %} } diff --git a/ansible/vagrant-provision.yml b/ansible/vagrant-provision.yml index 8964f64..2ded5c5 100644 --- a/ansible/vagrant-provision.yml +++ b/ansible/vagrant-provision.yml @@ -1,8 +1,26 @@ --- - hosts: all - vars_files: - - vars/all.yml + vars: + application_root: /vagrant + + timezone: UTC + + nginx_conf_name: anwinged.conf + nginx_conf_root: '{{ application_root }}/output_dev' + nginx_conf_domain: anwinged.ru + nginx_conf_sendfile: false + + nginx_remove_default_vhost: true + + php_enable_webserver: false + php_packages: + - php7.1 + - php7.1-mbstring + - php7.1-intl + - php7.1-curl + - php7.1-xml + pre_tasks: - name: Ensure that PHP Ondrej PPA is added diff --git a/ansible/vars/all.yml b/ansible/vars/all.yml deleted file mode 100755 index f5a3725..0000000 --- a/ansible/vars/all.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -application_root: /vagrant - -site: - www_dir: anwinged - domain: anwinged.ru - conf_name: anwinged.conf - -timezone: UTC - -nginx_conf_name: 'anwinged.conf' -nginx_conf_root: '{{ application_root }}/output_dev' -nginx_conf_domain: 'anwinged' - -nginx_remove_default_vhost: true - -php_enable_webserver: false -php_packages: - - php7.1 - - php7.1-mbstring - - php7.1-intl - - php7.1-curl - - php7.1-xml