From a634aac67fee4f2e26f3e358e5066d72200896b9 Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Thu, 8 Jan 2015 18:22:39 -0500 Subject: [PATCH] Migrate Ansible setup to use an external role to handle setup of the NGINX, UWSGI and supervisord setup. Allow for greater reusability of Ansible playbooks. --- pre_deployment.yaml | 21 ++++++++++++++------- pre_deployment/base_linux.yaml | 12 ++++-------- pre_deployment/mysql_db.yaml | 31 +++++++++++-------------------- pre_deployment/nodejs.yaml | 28 ++++++++++++---------------- requirements.yaml | 1 + 5 files changed, 42 insertions(+), 51 deletions(-) create mode 100644 requirements.yaml diff --git a/pre_deployment.yaml b/pre_deployment.yaml index 60a92cc..4dac7b6 100644 --- a/pre_deployment.yaml +++ b/pre_deployment.yaml @@ -1,10 +1,17 @@ --- -- include: pre_deployment/base_linux.yaml -- include: pre_deployment/python.yaml -- include: pre_deployment/mysql_db.yaml -- include: pre_deployment/nginx.yaml -- include: pre_deployment/supervisor.yaml -- include: pre_deployment/web_data_folders.yaml -- include: pre_deployment/nodejs.yaml +- hosts: all + sudo: yes + + roles: + - ansible-nginx-uwsgi-supervisor + tasks: + - include: pre_deployment/base_linux.yaml + - include: pre_deployment/mysql_db.yaml + vars: + databases: + rookeries: + username: rookeries + password: system_admin + - include: pre_deployment/nodejs.yaml # TODO Add in globally defined values for webapp and virtualenv folders diff --git a/pre_deployment/base_linux.yaml b/pre_deployment/base_linux.yaml index ee8dcfd..c6ae026 100644 --- a/pre_deployment/base_linux.yaml +++ b/pre_deployment/base_linux.yaml @@ -1,10 +1,6 @@ --- -- hosts: all - sudo: yes - tasks: +- name: install vim + apt: pkg=vim state=present - - name: install vim - apt: pkg=vim state=present - - - name: configure vim - copy: src=../config/base/_vimrc dest=/home/vagrant/.vimrc +- name: configure vim + copy: src=../config/base/_vimrc dest=/home/vagrant/.vimrc diff --git a/pre_deployment/mysql_db.yaml b/pre_deployment/mysql_db.yaml index e3e3f43..0db5cdf 100644 --- a/pre_deployment/mysql_db.yaml +++ b/pre_deployment/mysql_db.yaml @@ -1,23 +1,14 @@ --- -- hosts: all - sudo: yes - vars: - databases: - rookeries: - username: rookeries - password: system_admin - tasks: +- name: setup MySQL server + Python dependencies + apt: pkg={{ item }} state=present + with_items: + - mysql-server + - python-mysqldb - - name: setup MySQL server + Python dependencies - apt: pkg={{ item }} state=present - with_items: - - mysql-server - - python-mysqldb +- name: setup MySQL databases for rookeries. + mysql_db: name={{ item.key }} state=present + with_dict: databases - - name: setup MySQL databases for rookeries. - mysql_db: name={{ item.key }} state=present - with_dict: databases - - - name: add MySQL database users for rookeries. - mysql_user: name={{ item.value.username }} password={{ item.value.password }} priv={{ item.key }}:ALL - with_dict: databases +- name: add MySQL database users for rookeries. + mysql_user: name={{ item.value.username }} password={{ item.value.password }} priv={{ item.key }}:ALL + with_dict: databases diff --git a/pre_deployment/nodejs.yaml b/pre_deployment/nodejs.yaml index 3eca965..4edb33d 100644 --- a/pre_deployment/nodejs.yaml +++ b/pre_deployment/nodejs.yaml @@ -1,19 +1,15 @@ --- -- hosts: all - sudo: yes - tasks: +- name: install nodejs + npm dependencies + apt: pkg={{ item }} state=present + with_items: + - nodejs + - npm - - name: install nodejs + npm dependencies - apt: pkg={{ item }} state=present - with_items: - - nodejs - - npm +- name: link nodejs binary correctly + file: src=/usr/bin/nodejs dest=/usr/bin/node state=link - - name: link nodejs binary correctly - file: src=/usr/bin/nodejs dest=/usr/bin/node state=link - - - name: install coffeescript + less dependencies - npm: name={{ item }} global=yes state=present - with_items: - - coffee-script - - less +- name: install coffeescript + less dependencies + npm: name={{ item }} global=yes state=present + with_items: + - coffee-script + - less diff --git a/requirements.yaml b/requirements.yaml new file mode 100644 index 0000000..e6f0b67 --- /dev/null +++ b/requirements.yaml @@ -0,0 +1 @@ +- src: git+https://bitbucket.org/dorianpula/ansible-nginx-uwsgi-supervisor