Commit a42bfea8 authored by nimrod's avatar nimrod
Browse files

- Seperated the NTP parts from the common role.

parent 0728e02c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
---
# defaults file for ansible-role-example
# defaults file for ansible-role-ntp-client
+11 −1
Original line number Diff line number Diff line
---
# handlers file for ansible-role-example
# handlers file for ansible-role-ntp-client

- name: Restart ntpd
  service:
    name: '{{ ntpd_service[ansible_os_family] }}'
    state: restarted

- name: Restart systemd-timesyncd
  service:
    name: systemd-timesyncd
    state: restarted
+6 −6
Original line number Diff line number Diff line
galaxy_info:
  author: Nimrod Adar
  description: An example Ansible role
  description: An Ansible role for configuring NTP time syncronization.
  company: Shore technologies
  license: MIT
  min_ansible_version: 2.0
@@ -8,8 +8,8 @@ galaxy_info:
  - name: OpenBSD
    versions:
    - 5.9
  galaxy_tags: [ ansible ]
dependencies:
    - src: https://www.shore.co.il/git/ansible-role-openbsd-bootstrap
      scm: git
      name: bootstrap
  - name: Debian
    versions:
    - jessie
  galaxy_tags: [ ntp ]
dependencies: []
+5 −1
Original line number Diff line number Diff line
@@ -12,8 +12,12 @@ vagrant:
  platforms:
  - name: openbsd
    box: kaorimatz/openbsd-5.9-amd64
  - name: debian
    box: debian/jessie64
  - name: ubuntu
    box: ubuntu/trusty64
  instances:
  - name: ansible-role-example
  - name: ansible-role-ntp-client
    options:
        append_platform_to_hostname: yes
  raw_config_args:
+39 −5
Original line number Diff line number Diff line
---
# tasks file for ansible-role-example
# tasks file for ansible-role-ntp-client

- assert:
    that:
        - ansible_os_family == 'OpenBSD'
        - ansible_distribution_release == '5.9'
- name: Assert
  assert:
    that: ansible_os_family in [ 'Debian', 'OpenBSD' ]

- name: apt install
  when: ansible_pkg_mgr == 'apt' and not ansible_service_mgr == 'systemd'
  apt:
    name: openntpd
    state: present
    update_cache: yes
    cache_valid_time: 3600

- name: Configure OpenNTPD
  when: not ansible_service_mgr == 'systemd'
  template:
    src: ntpd.conf.j2
    dest: '{{ ntpd_conf[ansible_os_family] }}'
    owner: root
    group: 0
    mode: 0o0644
  notify:
  - Restart ntpd

- name: Configure systemd-timesyncd
  when: ansible_service_mgr == 'systemd'
  lineinfile:
    dest: /etc/systemd/timesyncd.conf
    line: 'NTP=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org'
    regexp: '^NTP='
    state: present
  notify:
  - 'Restart systemd-timesyncd'

- name: Enable service
  service:
    name: '{{ "systemd-timesyncd" if ansible_service_mgr == "systemd" else ntpd_service[ansible_os_family] }}'
    enabled: yes
    state: started
Loading