Skip to content

Commit

Permalink
Merge pull request #38 from pcahyna/syntaxfixes
Browse files Browse the repository at this point in the history
Fixes for syntax problems found by Molecule
  • Loading branch information
pcahyna authored May 31, 2019
2 parents 4093b8e + 254ab7a commit 36b771c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
skip_list:
- '602'
58 changes: 44 additions & 14 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
- name: Check if single PTP is needed
set_fact:
timesync_mode: 2
when: timesync_mode is not defined and (timesync_ntp_servers|length == 0) and timesync_ptp_domains|length == 1 and timesync_ptp_domains[0].interfaces|length == 1
when:
- timesync_mode is not defined
- timesync_ntp_servers|length == 0
- timesync_ptp_domains|length == 1
- timesync_ptp_domains[0].interfaces|length == 1

- name: Check if both NTP and PTP are needed
set_fact:
Expand All @@ -17,24 +21,32 @@

- name: Determine current NTP provider
timesync_provider:
when: timesync_mode != 2 and timesync_ntp_provider == ''
when:
- timesync_mode != 2
- timesync_ntp_provider == ''

- name: Select NTP provider
set_fact:
timesync_ntp_provider: "{{ timesync_ntp_provider_os_default if timesync_ntp_provider_current == '' else timesync_ntp_provider_current }}"
when: timesync_mode != 2 and timesync_ntp_provider == ''
when:
- timesync_mode != 2
- timesync_ntp_provider == ''

- name: Install chrony
package:
name: chrony
state: present
when: timesync_mode != 2 and timesync_ntp_provider == 'chrony'
when:
- timesync_mode != 2
- timesync_ntp_provider == 'chrony'

- name: Install ntp
package:
name: ntp
state: present
when: timesync_mode != 2 and timesync_ntp_provider == 'ntp'
when:
- timesync_mode != 2
- timesync_ntp_provider == 'ntp'

- name: Install linuxptp
package:
Expand Down Expand Up @@ -71,7 +83,9 @@
register: timesync_ntp_version
changed_when: false
check_mode: false
when: timesync_mode != 2 and timesync_ntp_provider == 'ntp'
when:
- timesync_mode != 2
- timesync_ntp_provider == 'ntp'

- name: Generate chrony.conf file
template:
Expand All @@ -80,7 +94,9 @@
backup: true
mode: 0644
notify: restart {{ 'chronyd' if timesync_mode == 1 else 'timemaster' }}
when: timesync_mode != 2 and timesync_ntp_provider == 'chrony'
when:
- timesync_mode != 2
- timesync_ntp_provider == 'chrony'

- name: Generate chronyd sysconfig file
template:
Expand All @@ -89,7 +105,9 @@
backup: true
mode: 0644
notify: restart chronyd
when: timesync_mode == 1 and timesync_ntp_provider == 'chrony'
when:
- timesync_mode == 1
- timesync_ntp_provider == 'chrony'

- name: Generate ntp.conf file
template:
Expand All @@ -98,7 +116,9 @@
backup: true
mode: 0644
notify: restart {{ 'ntpd' if timesync_mode == 1 else 'timemaster' }}
when: timesync_mode != 2 and timesync_ntp_provider == 'ntp'
when:
- timesync_mode != 2
- timesync_ntp_provider == 'ntp'

- name: Generate ntpd sysconfig file
template:
Expand All @@ -107,7 +127,9 @@
backup: true
mode: 0644
notify: restart ntpd
when: timesync_mode == 1 and timesync_ntp_provider == 'ntp'
when:
- timesync_mode == 1
- timesync_ntp_provider == 'ntp'

- name: Generate ptp4l.conf file
template:
Expand All @@ -134,7 +156,9 @@
backup: true
mode: 0644
notify: restart phc2sys
when: timesync_mode == 2 and timesync_mode2_hwts
when:
- timesync_mode == 2
- timesync_mode2_hwts

- name: Generate timemaster.conf file
template:
Expand Down Expand Up @@ -216,14 +240,18 @@
name: chronyd
state: started
enabled: true
when: timesync_mode == 1 and timesync_ntp_provider == 'chrony'
when:
- timesync_mode == 1
- timesync_ntp_provider == 'chrony'

- name: Enable ntpd
service:
name: ntpd
state: started
enabled: true
when: timesync_mode == 1 and timesync_ntp_provider == 'ntp'
when:
- timesync_mode == 1
- timesync_ntp_provider == 'ntp'

- name: Enable ptp4l
service:
Expand All @@ -237,7 +265,9 @@
name: phc2sys
state: started
enabled: true
when: timesync_mode == 2 and timesync_mode2_hwts
when:
- timesync_mode == 2
- timesync_mode2_hwts

- name: Enable timemaster
service:
Expand Down

0 comments on commit 36b771c

Please sign in to comment.