File tree Expand file tree Collapse file tree 5 files changed +37
-4
lines changed
fixtures/broken-ansible.cfg Expand file tree Collapse file tree 5 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 70
70
env :
71
71
# Number of expected test passes, safety measure for accidental skip of
72
72
# tests. Update value if you add/remove tests.
73
- PYTEST_REQPASS : 847
73
+ PYTEST_REQPASS : 848
74
74
steps :
75
75
- uses : actions/checkout@v4
76
76
with :
Original file line number Diff line number Diff line change 36
36
from filelock import FileLock , Timeout
37
37
from rich .markup import escape
38
38
39
+ from ansiblelint .constants import RC , SKIP_SCHEMA_UPDATE
40
+
41
+ # safety check for broken ansible core, needs to happen first
42
+ try :
43
+ # pylint: disable=unused-import
44
+ from ansible .parsing .dataloader import DataLoader # noqa: F401
45
+
46
+ except Exception as _exc : # pylint: disable=broad-exception-caught # noqa: BLE001
47
+ logging .fatal (_exc )
48
+ sys .exit (RC .INVALID_CONFIG )
49
+ # pylint: disable=ungrouped-imports
39
50
from ansiblelint import cli
40
51
from ansiblelint ._mockings import _perform_mockings_cleanup
41
52
from ansiblelint .app import get_app
53
64
log_entries ,
54
65
options ,
55
66
)
56
- from ansiblelint .constants import RC , SKIP_SCHEMA_UPDATE
57
67
from ansiblelint .loaders import load_ignore_txt
58
68
from ansiblelint .runner import get_matches
59
69
from ansiblelint .skip_utils import normalize_tag
Original file line number Diff line number Diff line change 36
36
"url" : " https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/molecule.json"
37
37
},
38
38
"playbook" : {
39
- "etag" : " 8ae42e48318ff6da41f6d383dc19b643221258ea6521886f834e31cb8d3a7322 " ,
39
+ "etag" : " b86e7f78281e33eb16de9c5c066da0f88798243b647cc195573441d92e1e78a5 " ,
40
40
"url" : " https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/playbook.json"
41
41
},
42
42
"requirements" : {
52
52
"url" : " https://raw.githubusercontent.com/ansible/ansible-rulebook/main/ansible_rulebook/schema/ruleset_schema.json"
53
53
},
54
54
"tasks" : {
55
- "etag" : " f9fbc0855680d1321fa3902181131d73838d922362d8dfb85a4f59402240cc07 " ,
55
+ "etag" : " 495ec0c6cb49d60feed7e2bc7c0ef0135bab473a28c3c8d4a7be4f210e8c53fc " ,
56
56
"url" : " https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/tasks.json"
57
57
},
58
58
"vars" : {
Original file line number Diff line number Diff line change
1
+ [defaults]
2
+
3
+ # This breaks ansible-core, because it loads the value as null and only
4
+ # integers are accepted.
5
+ gather_timeout =
Original file line number Diff line number Diff line change 10
10
from pytest_mock import MockerFixture
11
11
12
12
from ansiblelint .config import get_version_warning
13
+ from ansiblelint .constants import RC
13
14
14
15
15
16
@pytest .mark .parametrize (
@@ -104,3 +105,20 @@ def test_nodeps(lintable: str) -> None:
104
105
env = env ,
105
106
)
106
107
assert proc .returncode == 0 , proc
108
+
109
+
110
+ def test_broken_ansible_cfg () -> None :
111
+ """Asserts behavior when encountering broken ansible.cfg files."""
112
+ py_path = Path (sys .executable ).parent
113
+ proc = subprocess .run (
114
+ [str (py_path / "ansible-lint" ), "--version" ],
115
+ check = False ,
116
+ capture_output = True ,
117
+ text = True ,
118
+ cwd = "test/fixtures/broken-ansible.cfg" ,
119
+ )
120
+ assert proc .returncode == RC .INVALID_CONFIG , proc
121
+ assert (
122
+ "Invalid type for configuration option setting: DEFAULT_GATHER_TIMEOUT"
123
+ in proc .stderr
124
+ )
You can’t perform that action at this time.
0 commit comments