Skip to content

Commit f336b2b

Browse files
Some fixes on Ansible provision
1 parent 8991323 commit f336b2b

File tree

6 files changed

+29
-17
lines changed

6 files changed

+29
-17
lines changed

contrib/ansible_playbooks/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
provision:
1+
provision: install-python-remote
22
@ansible-playbook provision.yml -v --ask-become-pass
33

44
deploy:

contrib/ansible_playbooks/provision.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
- name: Update system.
1616
apt: update_cache=yes
1717

18-
# - name: Upgrade system.
19-
# apt: upgrade=dist
18+
- name: Upgrade system.
19+
apt: upgrade=dist
2020

2121
- name: Install required system packages.
2222
apt: pkg={{ item }} state=installed update-cache=yes allow_unauthenticated=yes
@@ -37,6 +37,9 @@
3737
- name: Create virtualenv
3838
shell: /usr/bin/python3.5 -m venv {{ virtualenv_directory }}
3939

40+
- name: Upgrade PIP.
41+
shell: "{{ virtualenv_directory }}/bin/pip install --upgrade pip"
42+
4043
- name: Install requirements of Python project.
4144
pip: requirements={{ project_root }}/requirements.txt virtualenv={{ virtualenv_directory }}
4245

@@ -70,11 +73,20 @@
7073
copy: src=secret/nginx.conf dest=/etc/nginx/sites-enabled/{{ project_name }}.conf
7174
notify: restart nginx
7275

76+
- name: Create supervisor start scripts.
77+
shell: update-rc.d supervisor defaults
78+
7379
- name: Enable supervisor on start.
74-
shell: update-rc.d supervisor defaults && update-rc.d supervisor enable
80+
shell: update-rc.d supervisor enable
7581

7682
- name: Create database.
77-
shell: SECRET_KEY={{ secret_key }} SERVER_NAME={{ server_name }} DATABASE_URI={{ database_uri }} python db_create.py
83+
shell: "SECRET_KEY={{ secret_key }} SERVER_NAME={{ server_name }} DATABASE_URI={{ database_uri }} {{ virtualenv_directory }}/bin/python3.5 {{ project_root }}/db_create.py"
84+
85+
- name: Run collect static.
86+
shell: "SECRET_KEY={{ secret_key }} SERVER_NAME={{ server_name }} DATABASE_URI={{ database_uri }} {{ virtualenv_directory }}/bin/python3.5 {{ project_root }}/manage.py collect"
87+
88+
- name: Change permissions.
89+
file: dest={{ project_home }} owner={{ project_name }} group={{ project_name }} recurse=yes
7890

7991
handlers:
8092
- include: handlers.yml
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[virtualbox-vms]
2-
vm01 ansible_port=22 ansible_ssh_host=<ip of your application host> environment_type=production branch=master ansible_ssh_pass=<your ssh password> ansible_ssh_user=<your ssh user>
2+
vm01 ansible_port=22 ansible_ssh_host=<your host here> environment_type=production branch=master ansible_ssh_pass=<your password here> ansible_ssh_user=<your user here>

contrib/ansible_playbooks/secret/nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
server {
88
listen 80;
9-
# server_name flasktutorial.abraseucodigo.com.br;
9+
server_name flasktutorial.abraseucodigo.com.br;
1010

1111
location / {
1212
client_max_body_size 5M;
@@ -16,7 +16,7 @@ server {
1616

1717
location /static {
1818
autoindex on;
19-
alias /home/flasktutorial/project/staticfiles;
19+
alias /home/flasktutorial/project/static;
2020
}
2121

2222
location /robots.txt {

contrib/ansible_playbooks/secret/uwsgi.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ stderr_logfile=/home/flasktutorial/flasktutorial_error.log
77
autostart=true
88
autorestart=true
99
stopsignal=QUIT
10-
environment=SECRET_KEY="<your secret key>",SERVER_NAME="<your server name>",DATABASE_URI="sqlite:///tvseries.sqlite3"
10+
environment=SECRET_KEY="<your secret key here>",SERVER_NAME="<your server name here>",DATABASE_URI="sqlite:///tvseries.sqlite3"
1111

contrib/ansible_playbooks/secret/vars.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ project_home: /home/flasktutorial
44
project_root: /home/flasktutorial/project
55
virtualenv_directory: /home/flasktutorial/.venv
66
project_repo: git@github.com:rafaelhenrique/flask_tutorial.git
7-
private_key_github: /home/rafael/.ssh/id_rsa
8-
public_key_github: /home/rafael/.ssh/id_rsa.pub
9-
management_user: rafael
10-
secret_key: '<your secret key>'
11-
server_name: '<your server name>'
7+
private_key_github: /home/<your local user here>/.ssh/id_rsa
8+
public_key_github: /home/<your local user here>/.ssh/id_rsa.pub
9+
management_user: <your remote user here>
10+
secret_key: '<your secret key here>'
11+
server_name: '<your server name here>'
1212
database_uri: 'sqlite:///tvseries.sqlite3'
1313
production_variables:
14-
SECRET_KEY: '<your secret key>'
15-
SERVER_NAME: '<your server name >'
16-
DATABASE_URI: 'sqlite:///tvseries.sqlite3'
14+
SECRET_KEY: "{{ secret_key }}"
15+
SERVER_NAME: "{{ server_name }}"
16+
DATABASE_URI: "{{ database_uri }}"
1717
system_packages:
1818
- build-essential
1919
- python3

0 commit comments

Comments
 (0)