From 4e9d6e0f0fe7b8f805609754ed125c3621ee88af Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Thu, 29 Aug 2019 06:19:26 +0000 Subject: [PATCH] Add defaults to nginx role --- ansible/roles/nginx/defaults/main.yml | 7 ++++++- ansible/roles/nginx/files/nginx.conf | 6 +++--- ansible/roles/nginx/tasks/configure.yml | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ansible/roles/nginx/defaults/main.yml b/ansible/roles/nginx/defaults/main.yml index 4c1bb16..7c3dbf3 100644 --- a/ansible/roles/nginx/defaults/main.yml +++ b/ansible/roles/nginx/defaults/main.yml @@ -1,2 +1,7 @@ --- -# defaults file for /etc/ansible/roles/nginx \ No newline at end of file +# defaults file for /etc/ansible/roles/nginx +# +domain_name: "localhost" +nginx_root_dir: "/var/www/html/" +index_files: "index.html index.htm" + diff --git a/ansible/roles/nginx/files/nginx.conf b/ansible/roles/nginx/files/nginx.conf index fcaf75b..a9c5a2b 100644 --- a/ansible/roles/nginx/files/nginx.conf +++ b/ansible/roles/nginx/files/nginx.conf @@ -11,11 +11,11 @@ http { server { listen 80; server_tokens off; - server_name localhost; + server_name {{ domain_name }}; location / { - root /var/www/html; - index index.html index.htm; + root {{ nginx_root_dir }}; + index {{ index_files }}; } # Uncomment to pass for SSL diff --git a/ansible/roles/nginx/tasks/configure.yml b/ansible/roles/nginx/tasks/configure.yml index c37d458..fbcc88e 100644 --- a/ansible/roles/nginx/tasks/configure.yml +++ b/ansible/roles/nginx/tasks/configure.yml @@ -1,7 +1,7 @@ --- - name: Copy nginx configuration file - copy: src=files/nginx.conf dest=/etc/nginx/nginx.conf + template: src=files/nginx.conf dest=/etc/nginx/nginx.conf - name: Copy index.html file - copy: src=files/index.html dest=/var/www/html + template: src=files/index.html dest=/var/www/html notify: - restart nginx