-
Notifications
You must be signed in to change notification settings - Fork 23
/
provision_vagrant.yml
104 lines (90 loc) · 3.05 KB
/
provision_vagrant.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
---
- hosts: all
vars:
virtualenv_path: /home/vagrant/dev
tasks:
- name: link /mos -> /vagrant
file:
src: /vagrant
dest: /mos
state: link
# update / install packages
- name: "Install packages"
become: true
apt:
update_cache: true
cache_valid_time: 3600
pkg:
- build-essential
- locales
- python3-dev
- python3-pip
- python3-venv
# - rustc
- name: "add locale de_DE.UTF-8"
become: true
locale_gen:
name: "de_DE.UTF-8"
state: present
- name: Upgrade pip3
pip:
name:
- pip
- wheel
extra_args: --upgrade
virtualenv: "{{ virtualenv_path }}"
virtualenv_command: /usr/bin/python3 -m venv
# install required python modules
- name: Install python modules
pip:
requirements: "{{ item }}"
virtualenv: "{{ virtualenv_path }}"
virtualenv_command: /usr/bin/python3 -m venv
with_items:
- /vagrant/requirements.txt
- /vagrant/requirements-dev.txt
# a generated file should contain something like: SECRET_KEY='<KVPy@&pwCO[1KCz.O[]*mZ\+Q*CfTTm#;$1Bdd_17gq@9dzaG'
- name: check the existence of the secret_key.py file and create one if it does not exist
stat: path=/mos/mos/settings/secret_key.py
register: st
- name: generate random django secret
shell: echo "SECRET_KEY=r'`cat /dev/urandom | tr -dc 'a-z0-9!@#$%^&*(-_=+)' | head -c50`'" > /mos/mos/settings/secret_key.py
when: not st.stat.exists
# prepare MOS itself
- name: generate mos sqlite database
stat: path=/mos/mos.sqlite
register: st_sqlite
- name: django makemigrations
django_manage:
app_path: /mos
command: makemigrations
virtualenv: "{{ virtualenv_path }}"
- name: django migrate
django_manage:
app_path: /mos
command: migrate
virtualenv: "{{ virtualenv_path }}"
- name: Create Admin User
django_manage:
app_path: /mos
command: "createsuperuser --noinput --username=admin [email protected]"
virtualenv: "{{ virtualenv_path }}"
when: not st_sqlite.stat.exists
- name: django loaddata
django_manage:
app_path: /mos
fixtures: 'core/fixtures/default_choices.json members/fixtures/default_choices.json members/fixtures/dummy_members.json cal/fixtures/events_2012-09-20.json'
command: loaddata
virtualenv: "{{ virtualenv_path }}"
when: not st_sqlite.stat.exists
# If calender data fixture fails because of auth.user 1 not there. Creating Admin failed...
# Delete mos.sqlite DB in folder and provision vagrant Box again.
- name: Activate virtualenv on vagrant ssh
lineinfile:
dest: /home/vagrant/.bashrc
line: 'source {{ virtualenv_path }}/bin/activate'
# set the default directory to /mos
- name: Change into mos dir on vagrant ssh
lineinfile:
dest: /home/vagrant/.bashrc
line: 'cd /mos'