-
Notifications
You must be signed in to change notification settings - Fork 2
/
provision_accounts.yml
108 lines (102 loc) · 3.52 KB
/
provision_accounts.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
# Provision an accounts instance using tutor-deployment,
# but adjust the configuration slightly to use a local smtp
# rather than Amazon SES.
- name: "*slaps ansible with a fish* Use THIS python interpreter!"
hosts: local
tasks:
- when: "'VIRTUAL_ENV' in ansible_env"
# This assumes that python was Homebrew installed.
set_fact:
ansible_python_interpreter: "{{ ansible_env.VIRTUAL_ENV }}/bin/python"
- name: checkout tutor-deployment
hosts: local
vars:
source:
- name: tutor-deployment
repo: git@github.com:openstax/tutor-deployment.git
default_version: HEAD
tasks:
- include: tasks/checkout.yml
- name: generate a self-signed certificate
hosts: local
vars:
cert_password: "password"
cert_domain: "accounts.local.openstax.org"
cert_dir: "{{ source_dir }}/tutor-deployment/environments/local-accounts-vm/secrets/certs/ost"
cert_crt_filepath: "{{ cert_dir }}/ost.crt"
cert_key_filepath: "{{ cert_dir }}/ost.key"
tasks:
- file:
path: "{{ cert_dir }}"
state: directory
- stat: path="{{ cert_crt_filepath }}"
register: crt_file
- include: tasks/create_self_signed_cert.yml
when: not crt_file.stat.exists
- name: install tutor-deployment
hosts: local
tasks:
# FIXME tutor-deployment doesn't seem to work with ansible>=2.0.0
- name: setup a virtualenv for tutor-deployment
pip:
requirements: "{{ source_dir }}/tutor-deployment/requirements.txt"
virtualenv: "{{ source_dir }}/tutor-deployment"
- name: checkout accounts
git:
repo: git@github.com:openstax/accounts.git
dest: "{{ source_dir }}/accounts"
version: HEAD
# There doesn't seem to be a good reason to create a personal virtualenv
# for this, so let's just use this environment.
- name: install tutor-deployment
command: bin/ansible-playbook -vvv -i environments/local-accounts-vm/inventory accounts_only.yml
args:
chdir: "{{ source_dir }}/tutor-deployment"
- name: customize the accounts server
hosts: accounts
tasks:
- include: tasks/install_supervisor.yml
- name: setup local smtp service
become: yes
template:
src: "misc/smtp_server.py"
dest: "/usr/local/bin/smtp_server.py"
owner: root
mode: 0755
- stat: path="/etc/supervisor/conf.d/smtp_server.conf"
register: conf_file
- name: configure smtp service as a supervisor job
when: not conf_file.stat.exists
become: yes
copy:
src: etc/supervisor/conf.d/smtp_server.conf
dest: /etc/supervisor/conf.d/smtp_server.conf
- name: restart supervisor to start the smtp service
when: not conf_file.stat.exists
become: yes
service:
name: supervisor
state: restarted
- name: adjust accounts configuration
become: yes
lineinfile:
dest: /home/ostaccounts/www/accounts/config/environments/production.rb
regexp: " config.action_mailer.delivery_method = :[\\w]+"
line: " config.action_mailer.delivery_method = :smtp"
register: config_change
- name: restart accounts
when: config_change.changed
become: yes
service:
name: unicorn_accounts
state: restarted
- name: create an admin user
become: yes
become_user: ostaccounts
environment:
RAILS_ENV: production
RBENV_ROOT: /home/ostaccounts/.rbenv
command: rbenv exec bundle exec rake accounts:create_admin[nimda,password]
args:
chdir: ~/www/accounts