---
- name: install ntpd
  sudo: yes
  yum:
    name: ntp
    state: latest

- name: deploy config file for ntpd
  sudo: yes
  template:
    src: ntp.conf.j2
    dest: /etc/ntp.conf
  notify:
    - restart ntpd

- name: zone file for local time is changed?
  shell: cmp /usr/share/zoneinfo/Japan /etc/localtime
  register: zone_file_status
  changed_when: false
  failed_when: false

- name: copy zone file for local time of Japan
  sudo: yes
  shell: cp -pf /usr/share/zoneinfo/Japan /etc/localtime
  when: zone_file_status.rc == 1
  notify:
    - restart ntpd

- name: ntpd is running?
  command: /sbin/service ntpd status
  register: ntpd_status
  changed_when: false
  failed_when: false

- name: synchronize the time manually
  sudo: yes
  shell: ntpdate 0.jp.pool.ntp.org
  when: "'running' not in ntpd_status.stdout"

- name: enable and start ntpd
  sudo: yes
  service:
    name: ntpd
    enabled: true
    state: started

---
- name: install ntpd
  sudo: yes
  yum:
    name: ntp
    state: latest

- name: deploy config file for ntpd
  sudo: yes
  template:
    src: ntp.conf.j2
    dest: /etc/ntp.conf
  notify:
    - restart ntpd

- name: zone file for local time is changed?
  shell: cmp /usr/share/zoneinfo/Japan /etc/localtime
  register: zone_file_status
  changed_when: false
  failed_when: false

- name: copy zone file for local time of Japan
  sudo: yes
  shell: cp -pf /usr/share/zoneinfo/Japan /etc/localtime
  when: zone_file_status.rc == 1
  notify:
    - restart ntpd

- name: ntpd is running?
  shell: /sbin/service ntpd status
  register: ntpd_status
  changed_when: false
  failed_when: false

- name: synchronize the time manually
  sudo: yes
  shell: ntpdate 0.jp.pool.ntp.org
  when: "'running' not in ntpd_status.stdout"

- name: enable and start ntpd
  sudo: yes
  service:
    name: ntpd
    enabled: true
    state: started

Use shell command instead of command
Use shell command instead of command
