- name: maintenance routines for debian/ubuntu systems gather_facts: no hosts: "{{target}}" become: "{{become}}" tasks: #- assert: # that: ansible_facts['os_family'] == "Debian" - name: rename as openntpd/ntpd.conf.dist ansible.builtin.shell: executable: /bin/bash cmd: "[[ ! -f /etc/openntpd/ntpd.conf.dist ]] && mv -i /etc/openntpd/ntpd.conf /etc/openntpd/ntpd.conf.dist && echo ok || true" register: result changed_when: >- 'ok' in result.stdout - name: setup openntpd/ntpd.conf ansible.builtin.template: src: templates/openntpd.conf.j2 dest: /etc/openntpd/ntpd.conf mode: 0600 notify: restart openntpd diff: true - name: backup as bash.bashrc.dist ansible.builtin.shell: executable: /bin/bash cmd: "[[ ! -f /etc/bash.bashrc.dist ]] && cp -i /etc/bash.bashrc /etc/bash.bashrc.dist && echo ok || true" register: result changed_when: >- 'ok' in result.stdout - name: block in bash.bashrc ansible.builtin.blockinfile: path: /etc/bash.bashrc block: "{{ lookup('file', 'templates_debian/blockinfile_bashrc') }}" prepend_newline: true append_newline: true diff: true - name: deploy files ansible.builtin.copy: src: templates_debian/log dest: /root/ mode: 0700 diff: true handlers: - name: restart openntpd ansible.builtin.shell: executable: /bin/bash cmd: "systemctl restart openntpd.service"