Add integration test to ensure system cron tab doesn't get removed. Increase cron integration tests separation.

pull/74497/head
Fabian Klemp 4 years ago
parent fefda12827
commit 1e37fa86b4

@ -131,40 +131,79 @@
- name: Removing a cron file when the name is specified is allowed (#57471)
when: ansible_distribution != 'Alpine'
block:
- name: Check file does not exist
stat:
path: /etc/cron.d/cron_remove_name
register: cron_file_stats
- assert:
that: not cron_file_stats.stat.exists
- name: Cron file creation
cron:
cron_file: cron_filename
cron_file: cron_remove_name
name: "integration test cron"
job: 'ls'
user: root
- name: Cron file deletion
cron:
cron_file: cron_filename
cron_file: cron_remove_name
name: "integration test cron"
state: absent
- name: Check file succesfull deletion
stat:
path: /etc/cron.d/cron_filename
path: /etc/cron.d/cron_remove_name
register: cron_file_stats
- assert:
that: not cron_file_stats.stat.exists
- name: System cron tab does not get removed
block:
- name: Add cron job
cron:
cron_file: /etc/crontab
user: root
name: "integration test cron"
job: 'ls'
- name: Remove cron job
cron:
cron_file: /etc/crontab
name: "integration test cron"
state: absent
- name: Check system crontab still exists
stat:
path: /etc/crontab
register: cron_file_stats
- assert:
that: cron_file_stats.stat.exists
- name: Allow non-ascii chars in job (#69492)
when: ansible_distribution != 'Alpine'
block:
- name: Check file does not exist
stat:
path: /etc/cron.d/cron_nonascii
register: cron_file_stats
- assert:
that: not cron_file_stats.stat.exists
- name: Cron file creation
cron:
cron_file: cron_filename
cron_file: cron_nonascii
name: "cron job that contain non-ascii chars in job (これは日本語です; This is Japanese)"
job: 'echo "うどんは好きだがお化け👻は苦手である。"'
user: root
- name: "Ensure cron_file contains job string"
replace:
path: /etc/cron.d/cron_filename
path: /etc/cron.d/cron_nonascii
regexp: "うどんは好きだがお化け👻は苦手である。"
replace: "それは機密情報🔓です。"
register: find_chars
@ -172,13 +211,13 @@
- name: Cron file deletion
cron:
cron_file: cron_filename
cron_file: cron_nonascii
name: "cron job that contain non-ascii chars in job (これは日本語です; This is Japanese)"
state: absent
- name: Check file succesfull deletion
stat:
path: /etc/cron.d/cron_filename
path: /etc/cron.d/cron_nonascii
register: cron_file_stats
- assert:

Loading…
Cancel
Save