1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/setup_cron/tasks/main.yml

73 lines
2.5 KiB
YAML
Raw Normal View History

####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- when:
- not (ansible_os_family == 'Alpine' and ansible_distribution_version is version('3.15', '<')) # TODO
2020-03-09 10:11:07 +01:00
block:
- name: Include distribution specific variables
include_vars: '{{ lookup(''first_found'', search) }}'
vars:
search:
files:
- '{{ ansible_distribution | lower }}.yml'
- '{{ ansible_os_family | lower }}.yml'
- '{{ ansible_system | lower }}.yml'
- default.yml
paths:
- vars
- name: install cron package
2020-03-09 10:11:07 +01:00
package:
name: '{{ cron_pkg }}'
when: cron_pkg | default(false, true)
register: cron_package_installed
until: cron_package_installed is success
- when: faketime_pkg | default(false, true)
2020-03-09 10:11:07 +01:00
block:
- name: install cron and faketime packages
package:
name: '{{ faketime_pkg }}'
register: faketime_package_installed
until: faketime_package_installed is success
- name: Find libfaketime path
shell: '{{ list_pkg_files }} {{ faketime_pkg }} | grep -F libfaketime.so.1'
args:
warn: false
register: libfaketime_path
- when: ansible_service_mgr == 'systemd'
block:
- name: create directory for cron drop-in file
file:
path: /etc/systemd/system/{{ cron_service }}.service.d
state: directory
owner: root
group: root
mode: '0755'
- name: Use faketime with cron service
copy:
content: '[Service]
2020-03-09 10:11:07 +01:00
Environment=LD_PRELOAD={{ libfaketime_path.stdout_lines[0].strip() }}
2020-03-09 10:11:07 +01:00
Environment="FAKETIME=+0y x10"
2020-03-09 10:11:07 +01:00
Environment=RANDOM_DELAY=0'
dest: /etc/systemd/system/{{ cron_service }}.service.d/faketime.conf
owner: root
group: root
mode: '0644'
- when: ansible_system == 'FreeBSD'
name: Use faketime with cron service
copy:
content: cron_env='LD_PRELOAD={{ libfaketime_path.stdout_lines[0].strip() }} FAKETIME="+0y x10"'
dest: /etc/rc.conf.d/cron
2020-03-09 10:11:07 +01:00
owner: root
group: wheel
2020-03-09 10:11:07 +01:00
mode: '0644'
- name: enable cron service
service:
daemon-reload: '{{ (ansible_service_mgr == ''systemd'') | ternary(true, omit) }}'
name: '{{ cron_service }}'
state: restarted