diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/setup_cron | |
parent | Initial commit. (diff) | |
download | ansible-core-upstream/2.14.3.tar.xz ansible-core-upstream/2.14.3.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
10 files changed, 119 insertions, 0 deletions
diff --git a/test/integration/targets/setup_cron/defaults/main.yml b/test/integration/targets/setup_cron/defaults/main.yml new file mode 100644 index 0000000..a6d1965 --- /dev/null +++ b/test/integration/targets/setup_cron/defaults/main.yml @@ -0,0 +1 @@ +remote_dir: "{{ remote_tmp_dir }}" diff --git a/test/integration/targets/setup_cron/meta/main.yml b/test/integration/targets/setup_cron/meta/main.yml new file mode 100644 index 0000000..1810d4b --- /dev/null +++ b/test/integration/targets/setup_cron/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/test/integration/targets/setup_cron/tasks/main.yml b/test/integration/targets/setup_cron/tasks/main.yml new file mode 100644 index 0000000..730926d --- /dev/null +++ b/test/integration/targets/setup_cron/tasks/main.yml @@ -0,0 +1,99 @@ +- 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: + - name: install faketime packages + package: + name: '{{ faketime_pkg }}' + register: faketime_package_installed + until: faketime_package_installed is success + when: ansible_distribution != 'Alpine' + + - name: install faketime packages - Alpine + # NOTE: The `faketime` package is currently only available in the + # NOTE: `edge` branch. + # FIXME: If it ever becomes available in the `main` repository for + # FIXME: currently tested Alpine versions, the `--repository=...` + # FIXME: option can be dropped. + command: apk add -U {{ faketime_pkg }} --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing + when: ansible_distribution == 'Alpine' + + - name: Find libfaketime path + shell: '{{ list_pkg_files }} {{ faketime_pkg }} | grep -F libfaketime.so.1' + register: libfaketime_path + when: list_pkg_files is defined + + - 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 + 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' + +- name: See if /etc/pam.d/crond exists + stat: + path: /etc/pam.d/crond + register: pamd + +# https://github.com/lxc/lxc/issues/661#issuecomment-222444916 +# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=726661 +- name: Work around containers not being able to write to /proc/self/loginuid + command: sed -i '/pam_loginuid\.so$/ s/required/optional/' /etc/pam.d/crond + when: + - pamd.stat.exists diff --git a/test/integration/targets/setup_cron/vars/alpine.yml b/test/integration/targets/setup_cron/vars/alpine.yml new file mode 100644 index 0000000..37e6fc3 --- /dev/null +++ b/test/integration/targets/setup_cron/vars/alpine.yml @@ -0,0 +1 @@ +faketime_pkg: libfaketime diff --git a/test/integration/targets/setup_cron/vars/debian.yml b/test/integration/targets/setup_cron/vars/debian.yml new file mode 100644 index 0000000..cd04871 --- /dev/null +++ b/test/integration/targets/setup_cron/vars/debian.yml @@ -0,0 +1,3 @@ +cron_pkg: cron +cron_service: cron +list_pkg_files: dpkg -L diff --git a/test/integration/targets/setup_cron/vars/default.yml b/test/integration/targets/setup_cron/vars/default.yml new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/integration/targets/setup_cron/vars/default.yml diff --git a/test/integration/targets/setup_cron/vars/fedora.yml b/test/integration/targets/setup_cron/vars/fedora.yml new file mode 100644 index 0000000..b80a51b --- /dev/null +++ b/test/integration/targets/setup_cron/vars/fedora.yml @@ -0,0 +1,3 @@ +cron_pkg: cronie +cron_service: crond +list_pkg_files: rpm -ql diff --git a/test/integration/targets/setup_cron/vars/freebsd.yml b/test/integration/targets/setup_cron/vars/freebsd.yml new file mode 100644 index 0000000..41ed449 --- /dev/null +++ b/test/integration/targets/setup_cron/vars/freebsd.yml @@ -0,0 +1,3 @@ +cron_pkg: +cron_service: cron +list_pkg_files: pkg info --list-files diff --git a/test/integration/targets/setup_cron/vars/redhat.yml b/test/integration/targets/setup_cron/vars/redhat.yml new file mode 100644 index 0000000..2dff13d --- /dev/null +++ b/test/integration/targets/setup_cron/vars/redhat.yml @@ -0,0 +1,4 @@ +cron_pkg: cronie +cron_service: crond +faketime_pkg: +list_pkg_files: rpm -ql diff --git a/test/integration/targets/setup_cron/vars/suse.yml b/test/integration/targets/setup_cron/vars/suse.yml new file mode 100644 index 0000000..cd3677a --- /dev/null +++ b/test/integration/targets/setup_cron/vars/suse.yml @@ -0,0 +1,3 @@ +cron_pkg: cron +cron_service: cron +list_pkg_files: rpm -ql |