Ansible snippets

From DWIKI
Revision as of 14:04, 24 November 2022 by Tony (talk | contribs) (Created page with "=Systemd= ==Randomize timer== Create '''/var/ansible/files/systemd/fstrim.conf''' [Timer] RandomizedDelaySec=3h '''Playbook''': tasks: - name: check if /etc/systemd/system/fstrim.timer.d/ exists stat: path: /etc/systemd/system/fstrim.timer.d/ register: override_dir - name: create /etc/systemd/system/fstrim.timer.d/ file: path: /etc/systemd/system/fstrim.timer.d/ state: directory when: ov...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Systemd

Randomize timer

Create /var/ansible/files/systemd/fstrim.conf

[Timer]
RandomizedDelaySec=3h

Playbook:

  tasks: 
     - name: check if /etc/systemd/system/fstrim.timer.d/ exists
       stat:
         path: /etc/systemd/system/fstrim.timer.d/
       register: override_dir
     - name: create /etc/systemd/system/fstrim.timer.d/
       file:
         path: /etc/systemd/system/fstrim.timer.d/
         state: directory
       when: override_dir.stat.exists == False
     - name: add fstrim.timer override
       copy:
         src: /var/ansible/files/systemd/fstrim.conf
         dest: /etc/systemd/system/fstrim.timer.d/override.conf
       notify: daemon-reload
   handlers:
     - name: daemon-reload
       systemd:
         daemon_reload: yes