File tree Expand file tree Collapse file tree
tests/facts/crontab.Crontab Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,7 +102,21 @@ def to_json(self):
102102 return self .commands
103103
104104
105- _crontab_env_re = re .compile (r"^\s*([A-Z_]+)=(.*)$" )
105+ # crontab(5) env line: ``name = value`` with optional spaces around ``=``. The
106+ # name may be a bare identifier or placed in matching single/double quotes; the
107+ # value runs to end-of-line (the caller handles any quoting in the value).
108+ _crontab_env_re = re .compile (
109+ r"""
110+ ^\s*
111+ (?:
112+ "[^"]*" # "quoted name"
113+ | '[^']*' # 'quoted name'
114+ | [A-Za-z_][A-Za-z0-9_]* # bare identifier
115+ )
116+ \s*=
117+ """ ,
118+ re .VERBOSE ,
119+ )
106120
107121
108122class Crontab (FactBase [CrontabFile ]):
Original file line number Diff line number Diff line change 1+ {
2+ "command" : " crontab -l || true" ,
3+ "requires_command" : " crontab" ,
4+ "output" : [
5+ " MAILTO=me@example.com" ,
6+ " CRON_TZ=Europe/Amsterdam" ,
7+ " @reboot echo rebooted" ,
8+ " 0 0 * * * apt update"
9+ ],
10+ "fact" : [
11+ {
12+ "env" : " MAILTO=me@example.com" ,
13+ "comments" : []
14+ },
15+ {
16+ "env" : " CRON_TZ=Europe/Amsterdam" ,
17+ "comments" : []
18+ },
19+ {
20+ "command" : " echo rebooted" ,
21+ "special_time" : " @reboot" ,
22+ "comments" : []
23+ },
24+ {
25+ "command" : " apt update" ,
26+ "minute" : 0 ,
27+ "hour" : 0 ,
28+ "month" : " *" ,
29+ "day_of_month" : " *" ,
30+ "day_of_week" : " *" ,
31+ "comments" : []
32+ }
33+ ]
34+ }
Original file line number Diff line number Diff line change 1+ {
2+ "command" : " crontab -l || true" ,
3+ "requires_command" : " crontab" ,
4+ "output" : [
5+ " MAILTO = me@example.com" ,
6+ " cron_tz = Europe/Amsterdam" ,
7+ " SHELL=/bin/bash" ,
8+ " 0 * * * * echo hi"
9+ ],
10+ "fact" : [
11+ {
12+ "env" : " MAILTO = me@example.com" ,
13+ "comments" : []
14+ },
15+ {
16+ "env" : " cron_tz = Europe/Amsterdam" ,
17+ "comments" : []
18+ },
19+ {
20+ "env" : " SHELL=/bin/bash" ,
21+ "comments" : []
22+ },
23+ {
24+ "command" : " echo hi" ,
25+ "minute" : 0 ,
26+ "hour" : " *" ,
27+ "month" : " *" ,
28+ "day_of_month" : " *" ,
29+ "day_of_week" : " *" ,
30+ "comments" : []
31+ }
32+ ]
33+ }
You can’t perform that action at this time.
0 commit comments