From 950bd84b8721aa87a29f9afde359d10024ade0da Mon Sep 17 00:00:00 2001 From: Dorian Pula Date: Mon, 9 Mar 2015 16:02:32 -0400 Subject: [PATCH] Add role variables to meta content itself for more flexibility. Migrate email server setup to use supervisor template and dev environment flag. --- config/supervisor/mailsink_supervisor.conf | 8 -------- deployment/email_server.yaml | 13 ------------- meta/main.yml | 2 +- tasks/dev_email_server.yaml | 14 ++++++++++++++ tasks/main.yml | 1 + templates/dev_supervisor/mailsink_supervisor.conf | 8 ++++++++ vars/main.yml | 10 +++++++++- 7 files changed, 33 insertions(+), 23 deletions(-) delete mode 100644 config/supervisor/mailsink_supervisor.conf delete mode 100644 deployment/email_server.yaml create mode 100644 tasks/dev_email_server.yaml create mode 100644 templates/dev_supervisor/mailsink_supervisor.conf diff --git a/config/supervisor/mailsink_supervisor.conf b/config/supervisor/mailsink_supervisor.conf deleted file mode 100644 index c8add03..0000000 --- a/config/supervisor/mailsink_supervisor.conf +++ /dev/null @@ -1,8 +0,0 @@ -; Mailsink configuration -[program:mailsink] -command=/srv/www/virtualenvs/mail_server/bin/mailsinkd -w 8025 -s 25 -stopsignal=TERM -stdout_logfile = /srv/www/logs/supervisor/mailsink-application.log -stdout_logfile_backups = 5 -stderr_logfile=/srv/www/logs/supervisor/mailsink-error.log -stderr_logfile_backups=5 diff --git a/deployment/email_server.yaml b/deployment/email_server.yaml deleted file mode 100644 index ad618e4..0000000 --- a/deployment/email_server.yaml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- hosts: all - sudo: yes - vars: - web_server_home: /srv/www - email_server_venv: "{{ web_server_home }}/virtualenvs/mail_server" - tasks: - - - name: install mailsink test server into target virtualenv - pip: name=mailsink virtualenv={{ email_server_venv }} version=0.0.2 - - - name: restart up the mailsink program - supervisorctl: name=mailsink state=restarted config=/etc/supervisor/supervisor.conf diff --git a/meta/main.yml b/meta/main.yml index cdc565a..cedc1fc 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -122,7 +122,7 @@ galaxy_info: - web dependencies: - { role: dorianpula.nginx-uwsgi-supervisor, - app_name: rookeries, + app_name: "{{ rookeries_app_name }}", app_nginx_hostname: localhost, app_uwsgi_port: 8001, app_uwsgi_executable: "rookeries:make_rookeries_app()" } diff --git a/tasks/dev_email_server.yaml b/tasks/dev_email_server.yaml new file mode 100644 index 0000000..c219b11 --- /dev/null +++ b/tasks/dev_email_server.yaml @@ -0,0 +1,14 @@ +--- +# Sets up and runs a SMTP email sink to assist with development. +- name: install mailsink test server into target virtualenv + pip: name=mailsink virtualenv={{ rookeries_dev_email_server_venv }} version=0.0.2 + when: rookeries_environ_type == "dev" + +- name: upload supervisor configuration to web server home + template: src=dev_supervisor/mailsink_supervisor.conf dest=/etc/supervisor/conf.d/mailsink_supervisor.conf + sudo: yes + when: rookeries_environ_type == "dev" + +- name: restart up the mailsink program + supervisorctl: name=mailsink state=restarted config=/etc/supervisor/supervisor.conf + when: rookeries_environ_type == "dev" diff --git a/tasks/main.yml b/tasks/main.yml index 79950f5..9515eb3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,3 +1,4 @@ --- - include: mysql_db.yaml - include: nodejs.yaml +- include: dev_email_server.yaml diff --git a/templates/dev_supervisor/mailsink_supervisor.conf b/templates/dev_supervisor/mailsink_supervisor.conf new file mode 100644 index 0000000..5938bee --- /dev/null +++ b/templates/dev_supervisor/mailsink_supervisor.conf @@ -0,0 +1,8 @@ +; Mailsink configuration +[program:mailsink] +command= {{ rookeries_dev_email_server_venv }}/bin/mailsinkd -w 8025 -s 25 +stopsignal=TERM +stdout_logfile = {{ web_root_path }}/logs/supervisor/mailsink-application.log +stdout_logfile_backups = 5 +stderr_logfile={{ web_root_path }}/logs/supervisor/mailsink-error.log +stderr_logfile_backups=5 diff --git a/vars/main.yml b/vars/main.yml index c9d8212..04c8283 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,6 +1,14 @@ --- -# vars file for ansible-rookeries +# TODO Move into defaults/main.yaml databases: rookeries: username: rookeries password: system_admin + +# TODO Move into defaults/main.yaml +rookeries_app_name: rookeries + +# The mode of the setup. Setting to "dev" enables the use of a SMTP fake server to help with development. +# TODO Move into defaults/main.yaml +rookeries_environ_type: dev +rookeries_dev_email_server_venv: "{{ virtualenv_root_path }}/mail_server"