From 467cdcbb372f83c1953a4ef184a4875db8921dd5 Mon Sep 17 00:00:00 2001 From: Pablo Castillo Date: Wed, 15 Apr 2015 15:55:15 -0700 Subject: [PATCH] Ansible Nginx * Adding ssl cert path to variables and removing old ssl looping * Updating ssl task to use variable --- defaults/main.yml | 8 ++++++-- tasks/main.yml | 6 +++--- tasks/ssl.yml | 16 ++-------------- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index e12e149..bd66515 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -8,10 +8,14 @@ custom: 'true' nginx: version: 1.6.2 upstream_port: 5000 - user: ubuntu - group: ubuntu + ssl_cert: + crt: "" + key: "" passenger: version: 5.0.6 prestart: http://test.com +app: + user: ubuntu + group: ubuntu domains: test.com server_env: production \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index e741225..8a07c49 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -5,7 +5,7 @@ ignore_errors: yes - name: Take Ownership of /opt - file: path=/opt/ owner={{ nginx.user }} group={{ nginx.group }} recurse=yes state=directory + file: path=/opt/ owner={{ app.user }} group={{ app.group }} recurse=yes state=directory sudo: yes when: result|failed @@ -29,7 +29,7 @@ when: result|failed - name: Unzip Nginx Tar - unarchive: src=/opt/nginx-{{ nginx.version }}.tar.gz dest=/opt copy=no group={{ nginx.group }} owner={{ nginx.user }} + unarchive: src=/opt/nginx-{{ nginx.version }}.tar.gz dest=/opt copy=no group={{ app.group }} owner={{ app.user }} when: result|failed - name: Download Third Party modules @@ -37,7 +37,7 @@ when: result|failed - name: Unzip Modules - unarchive: src=/opt/nginx-{{ nginx.version }}/modules.tar.gz dest=/opt/nginx-{{ nginx.version }} copy=no group={{ nginx.group }} owner={{ nginx.user }} + unarchive: src=/opt/nginx-{{ nginx.version }}/modules.tar.gz dest=/opt/nginx-{{ nginx.version }} copy=no group={{ app.group }} owner={{ app.user }} when: result|failed - include: passenger.yml diff --git a/tasks/ssl.yml b/tasks/ssl.yml index 91d6d21..c6e886f 100644 --- a/tasks/ssl.yml +++ b/tasks/ssl.yml @@ -9,21 +9,9 @@ when: passenger == "true" - name: Copy SSL Certs to server - copy: src={{ item }} dest=/etc/nginx/ssl/ owner=root group=root force=yes + copy: src={{ nginx.ssl_cert.crt }} dest=/etc/nginx/ssl/ owner=root group=root force=yes sudo: yes - with_first_found: - - files: - - "server.crt" - paths: - - ../../../projects/{{ app_name }}/files/ssl - - ../files/ssl - name: Copy SSL Certs to server - copy: src={{ item }} dest=/etc/nginx/ssl/ owner=root group=root force=yes + copy: src={{ nginx.ssl_cert.key }} dest=/etc/nginx/ssl/ owner=root group=root force=yes sudo: yes - with_first_found: - - files: - - "server.key" - paths: - - ../../../projects/{{ app_name }}/files/ssl - - ../files/ssl