pyinfra 3.2__py2.py3-none-any.whl → 3.3__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyinfra/api/arguments_typed.py +4 -5
- pyinfra/api/command.py +22 -3
- pyinfra/api/config.py +5 -2
- pyinfra/api/facts.py +3 -0
- pyinfra/api/host.py +10 -4
- pyinfra/api/operation.py +2 -1
- pyinfra/api/state.py +1 -1
- pyinfra/connectors/base.py +34 -8
- pyinfra/connectors/chroot.py +7 -2
- pyinfra/connectors/docker.py +7 -2
- pyinfra/connectors/dockerssh.py +7 -2
- pyinfra/connectors/local.py +7 -2
- pyinfra/connectors/ssh.py +9 -2
- pyinfra/connectors/sshuserclient/client.py +16 -0
- pyinfra/connectors/sshuserclient/config.py +2 -0
- pyinfra/connectors/terraform.py +1 -1
- pyinfra/connectors/util.py +13 -9
- pyinfra/context.py +9 -2
- pyinfra/facts/apk.py +5 -0
- pyinfra/facts/apt.py +9 -1
- pyinfra/facts/brew.py +13 -0
- pyinfra/facts/bsdinit.py +3 -0
- pyinfra/facts/cargo.py +5 -0
- pyinfra/facts/choco.py +6 -0
- pyinfra/facts/crontab.py +6 -1
- pyinfra/facts/deb.py +10 -0
- pyinfra/facts/dnf.py +5 -0
- pyinfra/facts/docker.py +10 -0
- pyinfra/facts/efibootmgr.py +5 -0
- pyinfra/facts/files.py +19 -1
- pyinfra/facts/flatpak.py +7 -0
- pyinfra/facts/freebsd.py +75 -0
- pyinfra/facts/gem.py +5 -0
- pyinfra/facts/git.py +9 -0
- pyinfra/facts/gpg.py +7 -0
- pyinfra/facts/hardware.py +13 -0
- pyinfra/facts/iptables.py +9 -1
- pyinfra/facts/launchd.py +5 -0
- pyinfra/facts/lxd.py +5 -0
- pyinfra/facts/mysql.py +8 -0
- pyinfra/facts/npm.py +5 -0
- pyinfra/facts/openrc.py +8 -0
- pyinfra/facts/opkg.py +12 -0
- pyinfra/facts/pacman.py +9 -1
- pyinfra/facts/pip.py +5 -0
- pyinfra/facts/pipx.py +8 -0
- pyinfra/facts/pkg.py +4 -0
- pyinfra/facts/pkgin.py +5 -0
- pyinfra/facts/podman.py +7 -0
- pyinfra/facts/postgres.py +8 -2
- pyinfra/facts/rpm.py +11 -0
- pyinfra/facts/runit.py +7 -0
- pyinfra/facts/selinux.py +16 -0
- pyinfra/facts/server.py +49 -3
- pyinfra/facts/snap.py +7 -0
- pyinfra/facts/systemd.py +5 -0
- pyinfra/facts/sysvinit.py +4 -0
- pyinfra/facts/upstart.py +5 -0
- pyinfra/facts/util/__init__.py +4 -1
- pyinfra/facts/vzctl.py +5 -0
- pyinfra/facts/xbps.py +6 -1
- pyinfra/facts/yum.py +5 -0
- pyinfra/facts/zfs.py +19 -2
- pyinfra/facts/zypper.py +5 -0
- pyinfra/operations/apt.py +10 -3
- pyinfra/operations/docker.py +48 -44
- pyinfra/operations/files.py +47 -1
- pyinfra/operations/freebsd/__init__.py +12 -0
- pyinfra/operations/freebsd/freebsd_update.py +70 -0
- pyinfra/operations/freebsd/pkg.py +219 -0
- pyinfra/operations/freebsd/service.py +116 -0
- pyinfra/operations/freebsd/sysrc.py +92 -0
- pyinfra/operations/opkg.py +5 -5
- pyinfra/operations/postgres.py +99 -16
- pyinfra/operations/server.py +6 -4
- pyinfra/operations/util/docker.py +44 -22
- {pyinfra-3.2.dist-info → pyinfra-3.3.dist-info}/LICENSE.md +1 -1
- {pyinfra-3.2.dist-info → pyinfra-3.3.dist-info}/METADATA +25 -24
- {pyinfra-3.2.dist-info → pyinfra-3.3.dist-info}/RECORD +88 -82
- pyinfra_cli/exceptions.py +5 -0
- pyinfra_cli/log.py +3 -0
- pyinfra_cli/main.py +9 -8
- pyinfra_cli/prints.py +1 -1
- pyinfra_cli/virtualenv.py +1 -1
- tests/test_connectors/test_ssh.py +302 -182
- {pyinfra-3.2.dist-info → pyinfra-3.3.dist-info}/WHEEL +0 -0
- {pyinfra-3.2.dist-info → pyinfra-3.3.dist-info}/entry_points.txt +0 -0
- {pyinfra-3.2.dist-info → pyinfra-3.3.dist-info}/top_level.txt +0 -0
pyinfra/facts/server.py
CHANGED
|
@@ -9,7 +9,7 @@ from typing import Dict, List, Optional
|
|
|
9
9
|
|
|
10
10
|
from dateutil.parser import parse as parse_date
|
|
11
11
|
from distro import distro
|
|
12
|
-
from typing_extensions import TypedDict
|
|
12
|
+
from typing_extensions import TypedDict, override
|
|
13
13
|
|
|
14
14
|
from pyinfra.api import FactBase, ShortFactBase
|
|
15
15
|
from pyinfra.api.util import try_int
|
|
@@ -23,6 +23,7 @@ class User(FactBase):
|
|
|
23
23
|
Returns the name of the current user.
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
+
@override
|
|
26
27
|
def command(self):
|
|
27
28
|
return "echo $USER"
|
|
28
29
|
|
|
@@ -32,6 +33,7 @@ class Home(FactBase[Optional[str]]):
|
|
|
32
33
|
Returns the home directory of the given user, or the current user if no user is given.
|
|
33
34
|
"""
|
|
34
35
|
|
|
36
|
+
@override
|
|
35
37
|
def command(self, user=""):
|
|
36
38
|
return f"echo ~{user}"
|
|
37
39
|
|
|
@@ -41,6 +43,7 @@ class Path(FactBase):
|
|
|
41
43
|
Returns the path environment variable of the current user.
|
|
42
44
|
"""
|
|
43
45
|
|
|
46
|
+
@override
|
|
44
47
|
def command(self):
|
|
45
48
|
return "echo $PATH"
|
|
46
49
|
|
|
@@ -50,6 +53,7 @@ class TmpDir(FactBase):
|
|
|
50
53
|
Returns the temporary directory of the current server, if configured.
|
|
51
54
|
"""
|
|
52
55
|
|
|
56
|
+
@override
|
|
53
57
|
def command(self):
|
|
54
58
|
return "echo $TMPDIR"
|
|
55
59
|
|
|
@@ -59,6 +63,7 @@ class Hostname(FactBase):
|
|
|
59
63
|
Returns the current hostname of the server.
|
|
60
64
|
"""
|
|
61
65
|
|
|
66
|
+
@override
|
|
62
67
|
def command(self):
|
|
63
68
|
return "uname -n"
|
|
64
69
|
|
|
@@ -68,6 +73,7 @@ class Kernel(FactBase):
|
|
|
68
73
|
Returns the kernel name according to ``uname``.
|
|
69
74
|
"""
|
|
70
75
|
|
|
76
|
+
@override
|
|
71
77
|
def command(self):
|
|
72
78
|
return "uname -s"
|
|
73
79
|
|
|
@@ -77,6 +83,7 @@ class KernelVersion(FactBase):
|
|
|
77
83
|
Returns the kernel version according to ``uname``.
|
|
78
84
|
"""
|
|
79
85
|
|
|
86
|
+
@override
|
|
80
87
|
def command(self):
|
|
81
88
|
return "uname -r"
|
|
82
89
|
|
|
@@ -90,6 +97,7 @@ class Os(FactBase[str]):
|
|
|
90
97
|
This fact is deprecated/renamed, please use the ``server.Kernel`` fact.
|
|
91
98
|
"""
|
|
92
99
|
|
|
100
|
+
@override
|
|
93
101
|
def command(self):
|
|
94
102
|
return "uname -s"
|
|
95
103
|
|
|
@@ -103,6 +111,7 @@ class OsVersion(FactBase[str]):
|
|
|
103
111
|
This fact is deprecated/renamed, please use the ``server.KernelVersion`` fact.
|
|
104
112
|
"""
|
|
105
113
|
|
|
114
|
+
@override
|
|
106
115
|
def command(self):
|
|
107
116
|
return "uname -r"
|
|
108
117
|
|
|
@@ -114,6 +123,7 @@ class Arch(FactBase[str]):
|
|
|
114
123
|
|
|
115
124
|
# ``uname -p`` is not portable and returns ``unknown`` on Debian.
|
|
116
125
|
# ``uname -m`` works on most Linux and BSD systems.
|
|
126
|
+
@override
|
|
117
127
|
def command(self):
|
|
118
128
|
return "uname -m"
|
|
119
129
|
|
|
@@ -123,6 +133,7 @@ class Command(FactBase[str]):
|
|
|
123
133
|
Returns the raw output lines of a given command.
|
|
124
134
|
"""
|
|
125
135
|
|
|
136
|
+
@override
|
|
126
137
|
def command(self, command):
|
|
127
138
|
return command
|
|
128
139
|
|
|
@@ -132,6 +143,7 @@ class Which(FactBase[Optional[str]]):
|
|
|
132
143
|
Returns the path of a given command according to `command -v`, if available.
|
|
133
144
|
"""
|
|
134
145
|
|
|
146
|
+
@override
|
|
135
147
|
def command(self, command):
|
|
136
148
|
return "command -v {0} || true".format(command)
|
|
137
149
|
|
|
@@ -143,9 +155,11 @@ class Date(FactBase[datetime]):
|
|
|
143
155
|
|
|
144
156
|
default = datetime.now
|
|
145
157
|
|
|
158
|
+
@override
|
|
146
159
|
def command(self):
|
|
147
160
|
return f"date +'{ISO_DATE_FORMAT}'"
|
|
148
161
|
|
|
162
|
+
@override
|
|
149
163
|
def process(self, output) -> datetime:
|
|
150
164
|
return datetime.strptime(list(output)[0], ISO_DATE_FORMAT)
|
|
151
165
|
|
|
@@ -155,9 +169,11 @@ class MacosVersion(FactBase[str]):
|
|
|
155
169
|
Returns the installed MacOS version.
|
|
156
170
|
"""
|
|
157
171
|
|
|
172
|
+
@override
|
|
158
173
|
def requires_command(self) -> str:
|
|
159
174
|
return "sw_vers"
|
|
160
175
|
|
|
176
|
+
@override
|
|
161
177
|
def command(self):
|
|
162
178
|
return "sw_vers -productVersion"
|
|
163
179
|
|
|
@@ -188,9 +204,11 @@ class Mounts(FactBase[Dict[str, MountsDict]]):
|
|
|
188
204
|
|
|
189
205
|
default = dict
|
|
190
206
|
|
|
207
|
+
@override
|
|
191
208
|
def command(self):
|
|
192
209
|
return "mount"
|
|
193
210
|
|
|
211
|
+
@override
|
|
194
212
|
def process(self, output) -> dict[str, MountsDict]:
|
|
195
213
|
devices: dict[str, MountsDict] = {}
|
|
196
214
|
|
|
@@ -236,11 +254,13 @@ class KernelModules(FactBase):
|
|
|
236
254
|
}
|
|
237
255
|
"""
|
|
238
256
|
|
|
257
|
+
@override
|
|
239
258
|
def command(self):
|
|
240
259
|
return "! test -f /proc/modules || cat /proc/modules"
|
|
241
260
|
|
|
242
261
|
default = dict
|
|
243
262
|
|
|
263
|
+
@override
|
|
244
264
|
def process(self, output):
|
|
245
265
|
modules = {}
|
|
246
266
|
|
|
@@ -277,12 +297,15 @@ class LsbRelease(FactBase):
|
|
|
277
297
|
}
|
|
278
298
|
"""
|
|
279
299
|
|
|
300
|
+
@override
|
|
280
301
|
def command(self):
|
|
281
302
|
return "lsb_release -ca"
|
|
282
303
|
|
|
304
|
+
@override
|
|
283
305
|
def requires_command(self):
|
|
284
306
|
return "lsb_release"
|
|
285
307
|
|
|
308
|
+
@override
|
|
286
309
|
def process(self, output):
|
|
287
310
|
items = {}
|
|
288
311
|
|
|
@@ -321,9 +344,11 @@ class OsRelease(FactBase):
|
|
|
321
344
|
}
|
|
322
345
|
"""
|
|
323
346
|
|
|
347
|
+
@override
|
|
324
348
|
def command(self):
|
|
325
349
|
return "cat /etc/os-release"
|
|
326
350
|
|
|
351
|
+
@override
|
|
327
352
|
def process(self, output):
|
|
328
353
|
items = {}
|
|
329
354
|
|
|
@@ -352,11 +377,13 @@ class Sysctl(FactBase):
|
|
|
352
377
|
|
|
353
378
|
default = dict
|
|
354
379
|
|
|
380
|
+
@override
|
|
355
381
|
def command(self, keys=None):
|
|
356
382
|
if keys is None:
|
|
357
383
|
return "sysctl -a"
|
|
358
384
|
return f"sysctl {' '.join(keys)}"
|
|
359
385
|
|
|
386
|
+
@override
|
|
360
387
|
def process(self, output):
|
|
361
388
|
sysctls = {}
|
|
362
389
|
|
|
@@ -390,11 +417,13 @@ class Groups(FactBase[List[str]]):
|
|
|
390
417
|
Returns a list of groups on the system.
|
|
391
418
|
"""
|
|
392
419
|
|
|
420
|
+
@override
|
|
393
421
|
def command(self):
|
|
394
422
|
return "cat /etc/group"
|
|
395
423
|
|
|
396
424
|
default = list
|
|
397
425
|
|
|
426
|
+
@override
|
|
398
427
|
def process(self, output) -> list[str]:
|
|
399
428
|
groups: list[str] = []
|
|
400
429
|
|
|
@@ -434,13 +463,13 @@ class Users(FactBase):
|
|
|
434
463
|
}
|
|
435
464
|
"""
|
|
436
465
|
|
|
466
|
+
@override
|
|
437
467
|
def command(self):
|
|
438
468
|
return """
|
|
439
469
|
|
|
440
470
|
for i in `cat /etc/passwd | cut -d: -f1`; do
|
|
441
471
|
ENTRY=`grep ^$i: /etc/passwd`;
|
|
442
|
-
|
|
443
|
-
LASTLOG=`echo $LASTLOG_RAW | grep ^$i | tr -s ' '`;
|
|
472
|
+
LASTLOG=`(((lastlog -u $i || lastlogin $i) 2> /dev/null) | grep ^$i | tr -s ' ')`;
|
|
444
473
|
PASSWORD=`grep ^$i: /etc/shadow | cut -d: -f2`;
|
|
445
474
|
echo "$ENTRY|`id -gn $i`|`id -Gn $i`|$LASTLOG|$PASSWORD";
|
|
446
475
|
done
|
|
@@ -448,6 +477,7 @@ class Users(FactBase):
|
|
|
448
477
|
|
|
449
478
|
default = dict
|
|
450
479
|
|
|
480
|
+
@override
|
|
451
481
|
def process(self, output):
|
|
452
482
|
users = {}
|
|
453
483
|
rex = r"[A-Z][a-z]{2} [A-Z][a-z]{2} {1,2}\d+ .+$"
|
|
@@ -519,6 +549,7 @@ class LinuxDistribution(FactBase[LinuxDistributionDict]):
|
|
|
519
549
|
}
|
|
520
550
|
"""
|
|
521
551
|
|
|
552
|
+
@override
|
|
522
553
|
def command(self) -> str:
|
|
523
554
|
return (
|
|
524
555
|
"cd /etc/ && for file in $(ls -pdL *-release | grep -v /); "
|
|
@@ -537,6 +568,7 @@ class LinuxDistribution(FactBase[LinuxDistributionDict]):
|
|
|
537
568
|
"debian": "Debian",
|
|
538
569
|
}
|
|
539
570
|
|
|
571
|
+
@override
|
|
540
572
|
@staticmethod
|
|
541
573
|
def default() -> LinuxDistributionDict:
|
|
542
574
|
return {
|
|
@@ -546,6 +578,7 @@ class LinuxDistribution(FactBase[LinuxDistributionDict]):
|
|
|
546
578
|
"release_meta": {},
|
|
547
579
|
}
|
|
548
580
|
|
|
581
|
+
@override
|
|
549
582
|
def process(self, output) -> LinuxDistributionDict:
|
|
550
583
|
parts = {}
|
|
551
584
|
for part in "\n".join(output).strip().split("---"):
|
|
@@ -608,6 +641,7 @@ class LinuxName(ShortFactBase[str]):
|
|
|
608
641
|
|
|
609
642
|
fact = LinuxDistribution
|
|
610
643
|
|
|
644
|
+
@override
|
|
611
645
|
def process_data(self, data) -> str:
|
|
612
646
|
return data["name"]
|
|
613
647
|
|
|
@@ -627,18 +661,22 @@ class Selinux(FactBase[SelinuxDict]):
|
|
|
627
661
|
}
|
|
628
662
|
"""
|
|
629
663
|
|
|
664
|
+
@override
|
|
630
665
|
def command(self):
|
|
631
666
|
return "sestatus"
|
|
632
667
|
|
|
668
|
+
@override
|
|
633
669
|
def requires_command(self) -> str:
|
|
634
670
|
return "sestatus"
|
|
635
671
|
|
|
672
|
+
@override
|
|
636
673
|
@staticmethod
|
|
637
674
|
def default() -> SelinuxDict:
|
|
638
675
|
return {
|
|
639
676
|
"mode": None,
|
|
640
677
|
}
|
|
641
678
|
|
|
679
|
+
@override
|
|
642
680
|
def process(self, output) -> SelinuxDict:
|
|
643
681
|
selinux_info = self.default()
|
|
644
682
|
|
|
@@ -657,6 +695,7 @@ class LinuxGui(FactBase[List[str]]):
|
|
|
657
695
|
Returns a list of available Linux GUIs.
|
|
658
696
|
"""
|
|
659
697
|
|
|
698
|
+
@override
|
|
660
699
|
def command(self):
|
|
661
700
|
return "ls /usr/bin/*session || true"
|
|
662
701
|
|
|
@@ -670,6 +709,7 @@ class LinuxGui(FactBase[List[str]]):
|
|
|
670
709
|
"/usr/bin/xfce4-session": "XFCE 4",
|
|
671
710
|
}
|
|
672
711
|
|
|
712
|
+
@override
|
|
673
713
|
def process(self, output) -> list[str]:
|
|
674
714
|
gui_names = []
|
|
675
715
|
|
|
@@ -688,6 +728,7 @@ class HasGui(ShortFactBase[bool]):
|
|
|
688
728
|
|
|
689
729
|
fact = LinuxGui
|
|
690
730
|
|
|
731
|
+
@override
|
|
691
732
|
def process_data(self, data) -> bool:
|
|
692
733
|
return len(data) > 0
|
|
693
734
|
|
|
@@ -701,14 +742,17 @@ class Locales(FactBase[List[str]]):
|
|
|
701
742
|
["C.UTF-8", "en_US.UTF-8"]
|
|
702
743
|
"""
|
|
703
744
|
|
|
745
|
+
@override
|
|
704
746
|
def command(self) -> str:
|
|
705
747
|
return "locale -a"
|
|
706
748
|
|
|
749
|
+
@override
|
|
707
750
|
def requires_command(self) -> str:
|
|
708
751
|
return "locale"
|
|
709
752
|
|
|
710
753
|
default = list
|
|
711
754
|
|
|
755
|
+
@override
|
|
712
756
|
def process(self, output) -> list[str]:
|
|
713
757
|
# replace utf8 with UTF-8 to match names in /etc/locale.gen
|
|
714
758
|
# return a list of enabled locales
|
|
@@ -773,11 +817,13 @@ class SecurityLimits(FactBase):
|
|
|
773
817
|
]
|
|
774
818
|
"""
|
|
775
819
|
|
|
820
|
+
@override
|
|
776
821
|
def command(self):
|
|
777
822
|
return "cat /etc/security/limits.conf"
|
|
778
823
|
|
|
779
824
|
default = list
|
|
780
825
|
|
|
826
|
+
@override
|
|
781
827
|
def process(self, output):
|
|
782
828
|
limits = []
|
|
783
829
|
|
pyinfra/facts/snap.py
CHANGED
|
@@ -2,12 +2,15 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
|
|
5
|
+
from typing_extensions import override
|
|
6
|
+
|
|
5
7
|
from pyinfra.api import FactBase
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class SnapBaseFact(FactBase):
|
|
9
11
|
abstract = True
|
|
10
12
|
|
|
13
|
+
@override
|
|
11
14
|
def requires_command(self, *args, **kwargs) -> str:
|
|
12
15
|
return "snap"
|
|
13
16
|
|
|
@@ -36,9 +39,11 @@ class SnapPackage(SnapBaseFact):
|
|
|
36
39
|
"version": r"^installed:[ ]+([\w\d.-]+).*$",
|
|
37
40
|
}
|
|
38
41
|
|
|
42
|
+
@override
|
|
39
43
|
def command(self, package):
|
|
40
44
|
return f"snap info {package}"
|
|
41
45
|
|
|
46
|
+
@override
|
|
42
47
|
def process(self, output):
|
|
43
48
|
data = {}
|
|
44
49
|
for line in output:
|
|
@@ -67,9 +72,11 @@ class SnapPackages(SnapBaseFact):
|
|
|
67
72
|
|
|
68
73
|
default = list
|
|
69
74
|
|
|
75
|
+
@override
|
|
70
76
|
def command(self) -> str:
|
|
71
77
|
return "snap list"
|
|
72
78
|
|
|
79
|
+
@override
|
|
73
80
|
def process(self, output):
|
|
74
81
|
# Discard header output line from snap list command
|
|
75
82
|
# 'snap list' command example output lines:
|
pyinfra/facts/systemd.py
CHANGED
|
@@ -3,6 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
import re
|
|
4
4
|
from typing import Dict, Iterable
|
|
5
5
|
|
|
6
|
+
from typing_extensions import override
|
|
7
|
+
|
|
6
8
|
from pyinfra.api import FactBase, QuoteString, StringCommand
|
|
7
9
|
|
|
8
10
|
# Valid unit names consist of a "name prefix" and a dot and a suffix specifying the unit type.
|
|
@@ -55,6 +57,7 @@ class SystemdStatus(FactBase[Dict[str, bool]]):
|
|
|
55
57
|
}
|
|
56
58
|
"""
|
|
57
59
|
|
|
60
|
+
@override
|
|
58
61
|
def requires_command(self, *args, **kwargs) -> str:
|
|
59
62
|
return "systemctl"
|
|
60
63
|
|
|
@@ -63,6 +66,7 @@ class SystemdStatus(FactBase[Dict[str, bool]]):
|
|
|
63
66
|
state_key = "SubState"
|
|
64
67
|
state_values = ["running", "waiting", "exited", "listening"]
|
|
65
68
|
|
|
69
|
+
@override
|
|
66
70
|
def command(
|
|
67
71
|
self,
|
|
68
72
|
user_mode: bool = False,
|
|
@@ -94,6 +98,7 @@ class SystemdStatus(FactBase[Dict[str, bool]]):
|
|
|
94
98
|
*service_strs,
|
|
95
99
|
)
|
|
96
100
|
|
|
101
|
+
@override
|
|
97
102
|
def process(self, output) -> Dict[str, bool]:
|
|
98
103
|
services: Dict[str, bool] = {}
|
|
99
104
|
|
pyinfra/facts/sysvinit.py
CHANGED
|
@@ -3,6 +3,8 @@ from __future__ import annotations
|
|
|
3
3
|
import re
|
|
4
4
|
from typing import Optional
|
|
5
5
|
|
|
6
|
+
from typing_extensions import override
|
|
7
|
+
|
|
6
8
|
from pyinfra.api import FactBase
|
|
7
9
|
|
|
8
10
|
|
|
@@ -18,6 +20,7 @@ class InitdStatus(FactBase):
|
|
|
18
20
|
http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
|
|
19
21
|
"""
|
|
20
22
|
|
|
23
|
+
@override
|
|
21
24
|
def command(self) -> str:
|
|
22
25
|
return """
|
|
23
26
|
for SERVICE in `ls /etc/init.d/`; do
|
|
@@ -33,6 +36,7 @@ class InitdStatus(FactBase):
|
|
|
33
36
|
regex = r"([a-zA-Z0-9\-]+)=([0-9]+)"
|
|
34
37
|
default = dict
|
|
35
38
|
|
|
39
|
+
@override
|
|
36
40
|
def process(self, output) -> dict[str, Optional[bool]]:
|
|
37
41
|
services: dict[str, Optional[bool]] = {}
|
|
38
42
|
|
pyinfra/facts/upstart.py
CHANGED
|
@@ -2,6 +2,8 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
4
|
|
|
5
|
+
from typing_extensions import override
|
|
6
|
+
|
|
5
7
|
from pyinfra.api import FactBase
|
|
6
8
|
|
|
7
9
|
|
|
@@ -10,15 +12,18 @@ class UpstartStatus(FactBase):
|
|
|
10
12
|
Returns a dict of name -> status for upstart managed services.
|
|
11
13
|
"""
|
|
12
14
|
|
|
15
|
+
@override
|
|
13
16
|
def requires_command(self) -> str:
|
|
14
17
|
return "initctl"
|
|
15
18
|
|
|
16
19
|
regex = r"^([a-z\-]+) [a-z]+\/([a-z]+)"
|
|
17
20
|
default = dict
|
|
18
21
|
|
|
22
|
+
@override
|
|
19
23
|
def command(self):
|
|
20
24
|
return "initctl list"
|
|
21
25
|
|
|
26
|
+
@override
|
|
22
27
|
def process(self, output):
|
|
23
28
|
services = {}
|
|
24
29
|
|
pyinfra/facts/util/__init__.py
CHANGED
pyinfra/facts/vzctl.py
CHANGED
|
@@ -2,6 +2,8 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
|
|
5
|
+
from typing_extensions import override
|
|
6
|
+
|
|
5
7
|
from pyinfra.api import FactBase
|
|
6
8
|
|
|
7
9
|
|
|
@@ -20,14 +22,17 @@ class OpenvzContainers(FactBase):
|
|
|
20
22
|
}
|
|
21
23
|
"""
|
|
22
24
|
|
|
25
|
+
@override
|
|
23
26
|
def command(self) -> str:
|
|
24
27
|
return "vzlist -a -j"
|
|
25
28
|
|
|
29
|
+
@override
|
|
26
30
|
def requires_command(self) -> str:
|
|
27
31
|
return "vzlist"
|
|
28
32
|
|
|
29
33
|
default = dict
|
|
30
34
|
|
|
35
|
+
@override
|
|
31
36
|
def process(self, output):
|
|
32
37
|
combined_json = "".join(output)
|
|
33
38
|
vz_data = json.loads(combined_json)
|
pyinfra/facts/xbps.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing_extensions import override
|
|
4
|
+
|
|
3
5
|
from pyinfra.api import FactBase
|
|
4
6
|
|
|
5
7
|
from .util.packaging import parse_packages
|
|
@@ -16,15 +18,18 @@ class XbpsPackages(FactBase):
|
|
|
16
18
|
}
|
|
17
19
|
"""
|
|
18
20
|
|
|
21
|
+
@override
|
|
19
22
|
def requires_command(self) -> str:
|
|
20
23
|
return "xbps-query"
|
|
21
24
|
|
|
22
25
|
default = dict
|
|
23
26
|
|
|
24
|
-
regex = r"^.. ([a-zA-Z0-9_
|
|
27
|
+
regex = r"^.. ([a-zA-Z0-9_\-\+\.]+)\-([0-9a-z\.]+_[0-9]+)"
|
|
25
28
|
|
|
29
|
+
@override
|
|
26
30
|
def command(self):
|
|
27
31
|
return "xbps-query -l"
|
|
28
32
|
|
|
33
|
+
@override
|
|
29
34
|
def process(self, output):
|
|
30
35
|
return parse_packages(self.regex, output)
|
pyinfra/facts/yum.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing_extensions import override
|
|
4
|
+
|
|
3
5
|
from pyinfra.api import FactBase
|
|
4
6
|
|
|
5
7
|
from .util import make_cat_files_command
|
|
@@ -23,16 +25,19 @@ class YumRepositories(FactBase):
|
|
|
23
25
|
]
|
|
24
26
|
"""
|
|
25
27
|
|
|
28
|
+
@override
|
|
26
29
|
def command(self) -> str:
|
|
27
30
|
return make_cat_files_command(
|
|
28
31
|
"/etc/yum.conf",
|
|
29
32
|
"/etc/yum.repos.d/*.repo",
|
|
30
33
|
)
|
|
31
34
|
|
|
35
|
+
@override
|
|
32
36
|
def requires_command(self) -> str:
|
|
33
37
|
return "yum"
|
|
34
38
|
|
|
35
39
|
default = list
|
|
36
40
|
|
|
41
|
+
@override
|
|
37
42
|
def process(self, output):
|
|
38
43
|
return parse_yum_repositories(output)
|
pyinfra/facts/zfs.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Gather information about ZFS filesystems.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
from typing_extensions import override
|
|
6
|
+
|
|
5
7
|
from pyinfra.api import FactBase, ShortFactBase
|
|
6
8
|
|
|
7
9
|
|
|
@@ -16,17 +18,29 @@ def _process_zfs_props_table(output):
|
|
|
16
18
|
|
|
17
19
|
|
|
18
20
|
class ZfsPools(FactBase):
|
|
19
|
-
|
|
21
|
+
@override
|
|
22
|
+
def command(self) -> str:
|
|
20
23
|
return "zpool get -H all"
|
|
21
24
|
|
|
25
|
+
@override
|
|
26
|
+
def requires_command(self) -> str:
|
|
27
|
+
return "zpool"
|
|
28
|
+
|
|
29
|
+
@override
|
|
22
30
|
def process(self, output):
|
|
23
31
|
return _process_zfs_props_table(output)
|
|
24
32
|
|
|
25
33
|
|
|
26
34
|
class ZfsDatasets(FactBase):
|
|
27
|
-
|
|
35
|
+
@override
|
|
36
|
+
def command(self) -> str:
|
|
28
37
|
return "zfs get -H all"
|
|
29
38
|
|
|
39
|
+
@override
|
|
40
|
+
def requires_command(self) -> str:
|
|
41
|
+
return "zfs"
|
|
42
|
+
|
|
43
|
+
@override
|
|
30
44
|
def process(self, output):
|
|
31
45
|
return _process_zfs_props_table(output)
|
|
32
46
|
|
|
@@ -34,6 +48,7 @@ class ZfsDatasets(FactBase):
|
|
|
34
48
|
class ZfsFilesystems(ShortFactBase):
|
|
35
49
|
fact = ZfsDatasets
|
|
36
50
|
|
|
51
|
+
@override
|
|
37
52
|
def process_data(self, data):
|
|
38
53
|
return {name: props for name, props in data.items() if props.get("type") == "filesystem"}
|
|
39
54
|
|
|
@@ -41,6 +56,7 @@ class ZfsFilesystems(ShortFactBase):
|
|
|
41
56
|
class ZfsSnapshots(ShortFactBase):
|
|
42
57
|
fact = ZfsDatasets
|
|
43
58
|
|
|
59
|
+
@override
|
|
44
60
|
def process_data(self, data):
|
|
45
61
|
return {name: props for name, props in data.items() if props.get("type") == "snapshot"}
|
|
46
62
|
|
|
@@ -48,6 +64,7 @@ class ZfsSnapshots(ShortFactBase):
|
|
|
48
64
|
class ZfsVolumes(ShortFactBase):
|
|
49
65
|
fact = ZfsDatasets
|
|
50
66
|
|
|
67
|
+
@override
|
|
51
68
|
def process_data(self, data):
|
|
52
69
|
return {name: props for name, props in data.items() if props.get("type") == "volume"}
|
|
53
70
|
|
pyinfra/facts/zypper.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from typing_extensions import override
|
|
4
|
+
|
|
3
5
|
from pyinfra.api import FactBase
|
|
4
6
|
|
|
5
7
|
from .util import make_cat_files_command
|
|
@@ -23,15 +25,18 @@ class ZypperRepositories(FactBase):
|
|
|
23
25
|
]
|
|
24
26
|
"""
|
|
25
27
|
|
|
28
|
+
@override
|
|
26
29
|
def command(self) -> str:
|
|
27
30
|
return make_cat_files_command(
|
|
28
31
|
"/etc/zypp/repos.d/*.repo",
|
|
29
32
|
)
|
|
30
33
|
|
|
34
|
+
@override
|
|
31
35
|
def requires_command(self) -> str:
|
|
32
36
|
return "zypper"
|
|
33
37
|
|
|
34
38
|
default = list
|
|
35
39
|
|
|
40
|
+
@override
|
|
36
41
|
def process(self, output):
|
|
37
42
|
return parse_zypper_repositories(output)
|
pyinfra/operations/apt.py
CHANGED
|
@@ -333,7 +333,7 @@ def upgrade(auto_remove: bool = False):
|
|
|
333
333
|
"""
|
|
334
334
|
Upgrades all apt packages.
|
|
335
335
|
|
|
336
|
-
+
|
|
336
|
+
+ auto_remove: removes transitive dependencies that are no longer needed.
|
|
337
337
|
|
|
338
338
|
**Example:**
|
|
339
339
|
|
|
@@ -363,10 +363,12 @@ _upgrade = upgrade # noqa: E305 (for use below where update is a kwarg)
|
|
|
363
363
|
|
|
364
364
|
|
|
365
365
|
@operation()
|
|
366
|
-
def dist_upgrade():
|
|
366
|
+
def dist_upgrade(auto_remove: bool = False):
|
|
367
367
|
"""
|
|
368
368
|
Updates all apt packages, employing dist-upgrade.
|
|
369
369
|
|
|
370
|
+
+ auto_remove: removes transitive dependencies that are no longer needed.
|
|
371
|
+
|
|
370
372
|
**Example:**
|
|
371
373
|
|
|
372
374
|
.. code:: python
|
|
@@ -376,7 +378,12 @@ def dist_upgrade():
|
|
|
376
378
|
)
|
|
377
379
|
"""
|
|
378
380
|
|
|
379
|
-
|
|
381
|
+
command = ["dist-upgrade"]
|
|
382
|
+
|
|
383
|
+
if auto_remove:
|
|
384
|
+
command.append("--autoremove")
|
|
385
|
+
|
|
386
|
+
yield from _simulate_then_perform(" ".join(command))
|
|
380
387
|
|
|
381
388
|
|
|
382
389
|
@operation()
|