This repository has been archived by the owner on Dec 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
PackageHasRetryRule.py
72 lines (67 loc) · 1.79 KB
/
PackageHasRetryRule.py
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
62
63
64
65
66
67
68
69
70
71
72
# Copyright (c) 2016, Will Thames and contributors
# Copyright (c) 2018, Ansible Project
from ansiblelint import AnsibleLintRule
class PackageHasRetryRule(AnsibleLintRule):
id = '405'
shortdesc = 'Remote package tasks should have a retry'
description = ('Package operations are unreliable as they require'
'network communication and the availability of remote'
'servers. To mitigate the potential problems, retries '
'should be used.')
tags = ['module', 'reliability']
# module list generated with:
# find lib/ansible/modules/packaging/ -type f -printf '%f\n' \
# | sort | awk -F '/' \
# '/__|dpkg|_repo|_facts|_sub|_chan/{next} {split($NF, words, ".");
# print "\""words[1]"\","}'
package_modules = [
"apk",
"apt_key",
"apt",
"apt_rpm",
"bower",
"bundler",
"composer",
"cpanm",
"dnf",
"easy_install",
"flatpak",
"flatpak_remote",
"gem",
"homebrew_cask",
"homebrew",
"homebrew_tap",
"layman",
"macports",
"maven_artifact",
"npm",
"openbsd_pkg",
"opkg",
"package",
"pacman",
"pear",
"pip",
"pkg5_publisher",
"pkg5",
"pkgin",
"pkgng",
"pkgutil",
"portage",
"portinstall",
"rhn_register",
"rpm_key",
"slackpkg",
"snap",
"sorcery",
"svr4pkg",
"swdepot",
"swupd",
"urpmi",
"xbps",
"yarn",
"yum",
"zypper",
]
def matchtask(self, file, task):
return (task['action']['__ansible_module__'] in self.package_modules
and 'until' not in task)