forked from pyinfra-dev/pyinfra
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackages.py
More file actions
61 lines (50 loc) · 1.54 KB
/
packages.py
File metadata and controls
61 lines (50 loc) · 1.54 KB
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
from pyinfra import host
from pyinfra.modules import apt, pip, pkg, server, yum
# Global flag - this applies to all operations in this file!
SUDO = True
# Only apply to hosts in the `bsd` group
if 'bsd' in host.groups:
# OpenBSD packages?
pkg.packages(
{'Install Python, Pip & Git with pkg_add'},
['py-pip', 'git'],
)
# add_pkg does not automatically do this
server.shell(
{'Symlink pip to pip2.7'},
'ln -sf /usr/local/bin/pip2.7 /usr/local/bin/pip',
)
# Work with facts about the remote host
if host.fact.linux_name in ('Ubuntu', 'Debian'):
apt.packages(
{'Install Pip & Git with apt'},
['git', 'python-pip'],
update=True,
cache_time=3600,
)
elif host.fact.linux_name in ('CentOS', 'Fedora'):
if host.fact.linux_name == 'CentOS':
# Both missing in the CentOS 7 Vagrant image
yum.packages(
{'Install wget & net-tools with yum'},
['wget', 'net-tools'],
)
# Manage remote rpm files
yum.rpm(
{'Install epel RPM'},
(
'https://dl.fedoraproject.org/pub/epel/epel-release-latest-'
'{{ host.fact.linux_distribution.major }}.noarch.rpm'
),
)
# yum package manager
yum.packages(
{'Install Pip & Git with yum'},
['git', 'python-pip'],
)
# Now that we installed pip, we can use it! Note that this operation will be
# run after all the branches above.
pip.packages(
{'Install a pip package'},
'pytask',
)