Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Add tags + Listen + service pattern #1

Merged
merged 3 commits into from
Mar 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ ntp_config_restrict:
- "-6 default kod notrap nomodify nopeer noquery"
- "127.0.0.1"

ntp_config_listen:
- 127.0.0.1

ntp_config_filegen:
- "loopstats file loopstats type day enable"
- "peerstats file peerstats type day enable"
Expand Down
7 changes: 6 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
---
- name: Add the OS specific variables
include_vars: "{{ ansible_os_family }}.yml"
tags: ["configuration","packages","service","ntp"]

- name: Install the required packages in Redhat derivatives
yum: name={{ item }} state={{ npt_pkg_state }}
with_items: ntp_pkgs
when: ansible_os_family == 'RedHat'
tags: ["packages","ntp"]

- name: Install the required packages in Debian derivatives
apt: name={{ item }} state={{ npt_pkg_state }} update_cache=yes
with_items: ntp_pkgs
when: ansible_os_family == 'Debian'
tags: ["packages","ntp"]

- name: Copy the ntp.conf template file
template: src=ntp.conf.j2 dest=/etc/ntp.conf
notify:
- restart ntp
tags: ["configuration","packages","ntp"]

- name: Start/stop ntp service
service: name={{ ntp_service_name }} state={{ ntp_service_state }} enabled={{ ntp_service_enabled }}
service: name={{ ntp_service_name }} state={{ ntp_service_state }} enabled={{ ntp_service_enabled }} pattern="/ntpd"
tags: ["service","ntp"]
4 changes: 4 additions & 0 deletions templates/ntp.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ statistics {{ ntp_config_statistics }}
filegen {{ filegen }}
{% endfor %}

{% for listen in ntp_config_listen %}
interface listen {{ listen }}
{% endfor %}

{% for restrict in ntp_config_restrict %}
restrict {{ restrict }}
{% endfor %}
Expand Down