ntp_vm1.yml

mail@pastecode.io avatar
unknown
yaml
a month ago
859 B
1
Indexable
Never
---

- hosts:
  - vm1
  tasks:
  - name: "Install NTP-client"
    apt:
       pkg: [ "ntpdate", "tzdata" ]
    become: yes
  - name: "Add NTP-client to crontab"
    cron:
       name: "NTP-Client"
       hour: "*/1"
       job: "/usr/sbin/ntpdate pool.ntp.org"
       user: root
    become: yes
  - stat:
       path: /etc/localtime
    register: localtime
  - debug:
       msg: "islnk isn't defined (path doesn't exist)"
    when: localtime.stat.islnk is not defined
  - debug:
       msg: "islnk is defined (path must exist)"
    when: localtime.stat.islnk is defined

  - debug:
       msg: "Path exists and is a symlink"
    when: localtime.stat.islnk is defined and localtime.stat.islnk

  - debug:
      msg: "Path exists and isn't a symlink"
    when: localtime.stat.islnk is defined and localtime.stat.islnk == False
Leave a Comment