forked from pyinfra-dev/pyinfra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_app.py
More file actions
43 lines (39 loc) · 955 Bytes
/
python_app.py
File metadata and controls
43 lines (39 loc) · 955 Bytes
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
from pyinfra import host
from pyinfra.modules import git, pip, server
# Ensure the state of git repositories
git.repo(
{'Clone pyinfra repository'},
'git@github.com:Fizzadar/pyinfra',
host.data.app_dir,
branch='develop',
ssh_keyscan=True,
sudo=True,
# Carry SSH agent details w/sudo
preserve_sudo_env=True,
)
# Manage pip (npm, gem) packages
did_install = pip.packages(
{'Install virtualenv with pip'},
['virtualenv'],
sudo=True,
)
# Use operation meta to affect the deploy
if did_install.changed:
server.shell(
'echo "Clean package build/etc"',
)
# Create a virtualenv
server.shell(
{'Setup the virtualenv'},
'virtualenv {{ host.data.env_dir }}',
sudo=True,
sudo_user='pyinfra',
)
# and manage pip within it
pip.packages(
{'Install Python packages with pip'},
['ElasticQuery', 'JsonTest'],
virtualenv=host.data.env_dir,
sudo=True,
sudo_user='pyinfra',
)