2019-10-10 00:33:25 +02:00
|
|
|
- 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
|
|
|
|
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)
|
|
|
|
block:
|
2020-08-07 21:28:10 +02:00
|
|
|
- name: install faketime packages
|
2019-10-10 00:33:25 +02:00
|
|
|
package:
|
|
|
|
name: '{{ faketime_pkg }}'
|
|
|
|
register: faketime_package_installed
|
|
|
|
until: faketime_package_installed is success
|
2020-08-07 21:28:10 +02:00
|
|
|
when: ansible_distribution != 'Alpine'
|
|
|
|
|
|
|
|
- name: install faketime packages - Alpine
|
|
|
|
command: apk add -U {{ faketime_pkg }} --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
|
|
|
|
when: ansible_distribution == 'Alpine'
|
2019-10-10 00:33:25 +02:00
|
|
|
|
|
|
|
- name: Find libfaketime path
|
|
|
|
shell: '{{ list_pkg_files }} {{ faketime_pkg }} | grep -F libfaketime.so.1'
|
|
|
|
args:
|
|
|
|
warn: false
|
|
|
|
register: libfaketime_path
|
2020-08-07 21:28:10 +02:00
|
|
|
when: list_pkg_files is defined
|
2019-10-10 00:33:25 +02:00
|
|
|
|
|
|
|
- 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]
|
|
|
|
Environment=LD_PRELOAD={{ libfaketime_path.stdout_lines[0].strip() }}
|
|
|
|
Environment="FAKETIME=+0y x10"
|
|
|
|
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'
|
|
|
|
owner: root
|
|
|
|
group: wheel
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: enable cron service
|
|
|
|
service:
|
|
|
|
daemon-reload: "{{ (ansible_service_mgr == 'systemd') | ternary(true, omit) }}"
|
|
|
|
name: '{{ cron_service }}'
|
|
|
|
state: restarted
|
2020-08-07 21:28:10 +02:00
|
|
|
when: ansible_distribution != 'Alpine'
|
|
|
|
|
|
|
|
- name: enable cron service - Alpine
|
|
|
|
command: nohup crond
|
|
|
|
environment:
|
|
|
|
FAKETIME: "+0y x10"
|
|
|
|
LD_PRELOAD: "/usr/lib/faketime/libfaketime.so.1"
|
|
|
|
when: ansible_distribution == 'Alpine'
|