Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timesync #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 15 additions & 10 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,32 @@ perfsonar_optional_packages:
- perfsonar-toolkit-sysctl
- perfsonar-toolkit-systemenv-testpoint

# You can change the default variables for different platforms to which clock synchronization service to use.
# Recognized options are { ntpd ,chrony }
timesync: ntpd

# List of NTP servers you want to use on your perfSONAR hosts
# If empty, any already configured NTP server will not be changed
# If you also install the 'perfsonar-toolkit-ntp' package below, the perfSONAR
# provided script will choose the closest NTP servers for you.
perfsonar_ntp_servers: []
#perfsonar_ntp_servers:

#perfsonar_ntp_servers:
# - { name: "NTP 1", hostname: ntp.switch.ch }
# - { name: "NTP 2", hostname: 0.ch.pool.ntp.org }
# - { name: "NTP 3", hostname: 1.ch.pool.ntp.org }
# - { name: "NTP 4", hostname: 2.ch.pool.ntp.org }
# - { name: "NTP 5", hostname: 3.ch.pool.ntp.org }

# You can change the default variables for different platforms to which clock synchronization service to use.
# You can use chrony/chronyd instead of ntp

timesync_service:
Debian: ntp
RedHat: ntpd
default: ntp

ntp_service: "{{ timesync_service[ansible_os_family] | default(timesync_service['default']) }}"
#Delete# # You can change the default variables for different platforms to which clock synchronization service to use.
#Delete# # You can use chrony/chronyd instead of ntp
#Delete#
#Delete# timesync_service:
#Delete# Debian: ntp
#Delete# RedHat: ntpd
#Delete# default: ntp
#Delete#
#Delete# ntp_service: "{{ timesync_service[ansible_os_family] | default(timesync_service['default']) }}"

# Disable ssh root access
perfsonar_disable_root_ssh: True
Expand Down
6 changes: 3 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
# handlers file for perfsonar-testpoint

- name: restart ntp
- name: SvcRestart TimeSync
service:
name: "{{ ntp_service }}"
name: "{{ timesync_service }}"
state: restarted

- name: restart ssh
- name: SvcRestart SSH
service:
name: "{{ ssh_service }}"
state: restarted
Expand Down
36 changes: 25 additions & 11 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- name: Gather facts to load OS information
tags: [ 'ps::install', 'ps::running', 'ps::config' ]
setup:
become: no
become: false

- name: Load variables based on OS type
tags: [ 'ps::install', 'ps::running', 'ps::config' ]
Expand All @@ -18,6 +18,17 @@
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"


#####
# Install of additional packages: ps::install tag
#####

- name: Install Time Synchronization Service
tags: [ 'ps::install' ]
package:
name: "{{ timesynchash[timesync][ansible_os_family]['pkg'] }}"
state: latest

#####
# Configuration part: ps::config tag
#####
Expand All @@ -30,16 +41,19 @@
regexp: '127\.0\..*[\s]+{{ ansible_fqdn }}[\s]+.*'

# NTP is essential for good measurements
- name: Configure additional NTP servers
# Issue (item=chrony) => {"ansible_loop_var": "item", "changed": false, "item": "chrony", "msg": "Unable to start service chrony: Failed to start chrony.service: Unit chrony.service is masked.\n"}
# Solution remove package ntpd

- name: Configure additional Time servers
tags: [ 'ps::config' ]
blockinfile:
path: /etc/ntp.conf
path: "{{ timesynchash[timesync][ansible_os_family]['cfg'] }}"
block: |
server {{ item.hostname }} iburst
marker: "# {mark} ansible-role-perfsonar {{ item.name }}"
with_items: "{{ perfsonar_ntp_servers }}"
notify:
- restart ntp
- SvcRestart TimeSync

- name: Disable ssh root access
tags: [ 'ps::config' ]
Expand All @@ -50,7 +64,7 @@
line: "PermitRootLogin no"
when: perfsonar_disable_root_ssh
notify:
- restart ssh
- SvcRestart SSH

- name: Configure LS registration
tags: [ 'ps::config' ]
Expand All @@ -62,14 +76,14 @@
tags: [ 'ps::config' ]
shell: psconfig remote list --agent pscheduler | tail -n +2 | jq -r .[].url
register: psconfig_remotes
changed_when: False
changed_when: false

# And list of configured remotes with archiving
- name: Look at current psconfig remote list with configured archives
tags: [ 'ps::config' ]
shell: psconfig remote list --agent pscheduler | tail -n +2 | jq -r '.[] | select(."configure-archives"==true) | .url'
register: psconfig_remotes_archives
changed_when: False
changed_when: false

# The 2 lists are used in psconfig_remotes.yml
- name: add/delete remote mesh configurations that have a valid URL and state
Expand All @@ -87,6 +101,7 @@
loop_control:
loop_var: auth_interface


#####
# Verifying part: ps::running tag
#####
Expand All @@ -104,8 +119,8 @@
name: "{{ item }}"
state: started
with_flattened:
- "{{ perfsonar_services }}"
- "{{ perfsonar_os_specific_services }}"
- "{{ perfsonar_services }}"
- "{{ perfsonar_os_specific_services }}"

# Get some useful info out of the system
- name: Check system status
Expand All @@ -119,12 +134,11 @@
register: pscheduler_troubleshoot
until: pscheduler_troubleshoot is succeeded
retries: 3
changed_when: False
changed_when: false

- name: Report pscheduler troubleshoot output
tags: [ 'ps::running', 'ps::monitor' ]
debug:
msg:
- "{{ pscheduler_troubleshoot.stdout.replace('\n\n','\n').split('\n') }}"
when: pscheduler_troubleshoot is defined

2 changes: 1 addition & 1 deletion vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# variables specific to Debian OS family
---
# Default NTP service name: ntp

# List of perfSONAR services to check are running on Debian hosts
perfsonar_testpoint_os_specific_services:
- apache2
- postgresql
- "{{ timesync_service }}"

perfsonar_toolkit_config_daemon: perfsonar-toolkit-config-daemon
1 change: 1 addition & 0 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
perfsonar_testpoint_os_specific_services:
- httpd
- postgresql-10
- "{{ timesync_service }}"

perfsonar_toolkit_config_daemon: perfsonar-configdaemon
25 changes: 25 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,34 @@
# This means they cannot be overwritten in inventory or playbook.
# See http://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable

# stays here, so that noone can just overwrite it
#Time synchronization #TODO
timesynchash:
chrony:
Debian:
pkg: chrony
svc: chrony
cfg: /etc/chrony/chrony.conf
RedHat:
pkg: chrony
svc: chronyd
cfg: /etc/chrony.conf
ntpd:
Debian:
pkg: ntp
svc: ntpd
cfg: /etc/ntp.conf
RedHat:
pkg: ntp
svc: ntpd
cfg: /etc/ntp.conf

# SSH daemon service
ssh_service: sshd

# Time Sync service
timesync_service: "{{ timesynchash[timesync][ansible_os_family]['svc'] }}"

# List of perfSONAR services to check are running on a testpoint install
perfsonar_testpoint_services:
- pscheduler-scheduler
Expand Down