I have compiled a configuration for NTP for my Linux Servers (RedHat, SLES,
Debian, Ubuntu). When I run my playbook I get an error only for Debian. See
below:
main.yaml
---
## PLAYBOOK TO INSTALL AND CONFIGURE NTP ON REDHAT/ DEBIAN SYSTEMS
- name: Include OS-specific variables
include_vars: "{{ ansible_distribution }}.yaml"
- include: redhat-ntp.yaml
when: ansible_distribution|lower == 'redhat'
- include: debian-ntp.yaml
when: ansible_distribution|lower == 'debian'
- include: sles-ntp.yaml
when: ansible_distribution|lower == 'sles'
- include: ubuntu-ntp.yaml
when: ansible_distribution|lower == 'ubuntu'
- name: Configure NTP timezone file
become: yes
file:
src: '/usr/share/zoneinfo/{{ ntp_timezone }}'
dest: '/etc/localtime'
state: 'link'
force: yes
owner: 'root'
group: 'root'
mode: '0644'
notify: 'restart ntp'
- name: Configure NTP conf file
become: yes
template:
src: '{{ ntp_conf_template }}'
dest: '/etc/ntp.conf'
owner: 'root'
group: 'root'
mode: '0644'
notify: 'restart ntp'
- name: Force NTP update
shell: "service {{ ntp_service }} stop && ntpdate -s {{ ntpdate_server }}
&& service {{ ntp_service }} start"
...
ntp.yaml
---
- hosts: buildservers
remote_user: root
tasks:
- name: Detect OS and run appropriate tasks
include_tasks: "{{ ansible_distribution|lower }}-ntp.yaml"
debian-ntp.yaml
---
- name: debian | installing packages
apt:
name: ["ntp"]
state: present
become: true
register: result
until: result is successful
- name: debian | configuring ntp
file:
src: /roles/gen10tools/files/debian-ntp.conf
dest: /etc/ntp.conf
owner: root
group: root
mode: 0644
become: true
- name: debian | enable ntp
systemd:
name: ntp
enabled: yes
- name: debian | ensure ntpd is started
systemd:
name: ntp
state: started
...
redhat-ntp.yaml
---
- name: redhat | installing packages
yum:
name: ["ntp"]
state: present
become: true
register: result
until: result is successful
when: ansible_distribution|lower == "redhat"
- name: redhat | Configure NTP conf file
become: yes
file:
src: /roles/gen10tools/files/redhat-ntp.conf
dest: /etc/ntp.conf
owner: root
group: root
mode: 0644
- name: redhat | ensuring ntpd service is started and enabled on boot
service:
name: ntpd
state: started
enabled: true
become: true
...
sles-ntp.yaml
---
- name: sles | installing packages
zypper:
name: ["ntp"]
state: present
become: true
register: result
until: result is successful
when: ansible_distribution|lower == "sles"
- name: sles | configuring ntp
file:
src: /roles/gen10tools/files/sles-ntp.conf
dest: /etc/ntp.conf
owner: root
group: root
mode: 0644
become: true
- name: sles | ensuring ntpd service is started and enabled on boot
service:
name: ntpd
state: started
enabled: true
become: true
...
ubuntu-ntp.yaml
---
- name: ubuntu | installing packages
apt:
name: ["ntp"]
state: present
become: true
register: result
until: result is successful
- name: ubuntu | configuring ntp
file:
src: /roles/gen10tools/files/ubuntu-ntp.conf
dest: /etc/ntp.conf
owner: root
group: root
mode: 0644
notify: restart ntp
become: true
...
TASK [debian | configuring ntp]
Error: fatal: [abldeb7ex6403]: FAILED! => {"changed": false, "msg": "file
(/etc/ntp.conf) is absent, cannot continue", "path": "/etc/ntp.conf"}
Error: fatal: [abldeb7ex6401]: FAILED! => {"changed": false, "msg": "Failed
to find required executable systemctl in paths:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11"}
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7889a84b-fb8d-468b-b38f-1c4aad69cb17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.