Skip to content

Commit ee877c3

Browse files
example anisble playbook
1 parent a479dc7 commit ee877c3

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

ansible/ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
inventory=inventory

ansible/inventory

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[pythonanywhere]
2+
ssh.pythonanywhere.com
3+
4+
[pythonanywhere:vars]
5+
ansible_ssh_user=newpythonanywhereuser

ansible/update.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
- hosts: pythonanywhere
3+
vars:
4+
home: /home/newpythonanywhereuser/
5+
app_path: "{{ home }}newpythonanywhereuser.pythonanywhere.com/"
6+
virtualenv: "{{ home }}.virtualenvs/newpythonanywhereuser.pythonanywhere.com"
7+
vars_files:
8+
vars.yml
9+
tasks:
10+
- name: update code
11+
git:
12+
repo: 'https://github.com/pythonanywhere/example-django-project.git'
13+
dest: "{{ app_path }}"
14+
update: yes
15+
- name: update requirements
16+
pip:
17+
requirements: "{{ app_path }}requirements.txt"
18+
virtualenv: "{{ virtualenv }}"
19+
- name: apply django migrations
20+
django_manage:
21+
command: migrate
22+
app_path: "{{ app_path }}"
23+
settings: myproject.settings
24+
virtualenv: "{{ virtualenv }}"
25+
- name: reload web app
26+
shell: "{{ virtualenv }}/bin/pa_reload_webapp.py newpythonanywhereuser.pythonanywhere.com"
27+
environment:
28+
API_TOKEN: "{{ api_token }}"

ansible/vars.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$ANSIBLE_VAULT;1.1;AES256
2+
31376237313935636431393936323664386431633136396465656464613833653937363734353464
3+
6132306464636162336230386166363730353664316463330a613135323566343362383564653438
4+
33643937333133306430353539336139373366313036616336323132333864633562656639353736
5+
6364626561343635330a356230356563313330336164313730373033623731623731303964366238
6+
33616261616564346463353665356264643666636162343938306133636562326636356534376464
7+
36636633663236376135656339363662356439313564333937333539336235316230613165306433
8+
306665356430613737663735333536313430

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
django==3.0.6
2+
pythonanywhere==0.9.2

0 commit comments

Comments
 (0)