Merge "Apply PTP configuration at runtime"
This commit is contained in:
commit
e1b3330e6e
@ -4,7 +4,8 @@ class platform::ptp (
|
||||
$transport = 'L2',
|
||||
$phc2sys_options = '',
|
||||
$master_devices = [],
|
||||
$slave_devices = []
|
||||
$slave_devices = [],
|
||||
$runtime = false
|
||||
) {
|
||||
if empty($master_devices) {
|
||||
$slave_only = true
|
||||
@ -12,15 +13,32 @@ class platform::ptp (
|
||||
$slave_only = false
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
$ensure = 'running'
|
||||
$enable = true
|
||||
} else {
|
||||
$ensure = 'stopped'
|
||||
$enable = false
|
||||
}
|
||||
|
||||
if $runtime {
|
||||
# During runtime we set first_step_threshold to 0. This ensures there are no
|
||||
# large time changes to a running host
|
||||
$phc2sys_cmd_opts = "${phc2sys_options} -F 0"
|
||||
} else {
|
||||
$phc2sys_cmd_opts = $phc2sys_options
|
||||
}
|
||||
|
||||
file { 'ptp4l_config':
|
||||
ensure => file,
|
||||
path => '/etc/ptp4l.conf',
|
||||
mode => '0644',
|
||||
content => template('platform/ptp4l.conf.erb'),
|
||||
notify => [ Service['phc2sys'], Service['ptp4l'] ],
|
||||
}
|
||||
-> file { 'ptp4l_service':
|
||||
ensure => file,
|
||||
path => '/usr/lib/systemd/system/ptp4l.service',
|
||||
path => '/etc/systemd/system/ptp4l.service',
|
||||
mode => '0644',
|
||||
content => template('platform/ptp4l.service.erb'),
|
||||
}
|
||||
@ -32,7 +50,7 @@ class platform::ptp (
|
||||
}
|
||||
-> file { 'phc2sys_service':
|
||||
ensure => file,
|
||||
path => '/usr/lib/systemd/system/phc2sys.service',
|
||||
path => '/etc/systemd/system/phc2sys.service',
|
||||
mode => '0644',
|
||||
content => template('platform/phc2sys.service.erb'),
|
||||
}
|
||||
@ -41,33 +59,33 @@ class platform::ptp (
|
||||
path => '/etc/sysconfig/phc2sys',
|
||||
mode => '0644',
|
||||
content => template('platform/phc2sys.erb'),
|
||||
notify => Service['phc2sys'],
|
||||
}
|
||||
-> exec { 'systemctl-daemon-reload':
|
||||
command => '/usr/bin/systemctl daemon-reload',
|
||||
}
|
||||
|
||||
if $enabled {
|
||||
exec { 'enable-ptp4l':
|
||||
command => '/usr/bin/systemctl enable ptp4l.service',
|
||||
require => Exec['systemctl-daemon-reload'],
|
||||
}
|
||||
-> exec { 'enable-phc2sys':
|
||||
command => '/usr/bin/systemctl enable phc2sys.service',
|
||||
}
|
||||
-> service { 'ptp4l':
|
||||
ensure => 'running',
|
||||
enable => true,
|
||||
ensure => $ensure,
|
||||
enable => $enable,
|
||||
name => 'ptp4l',
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
-> service { 'phc2sys':
|
||||
ensure => 'running',
|
||||
enable => true,
|
||||
ensure => $ensure,
|
||||
enable => $enable,
|
||||
name => 'phc2sys',
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
}
|
||||
if $enabled {
|
||||
exec { 'enable-ptp4l':
|
||||
command => '/usr/bin/systemctl enable ptp4l.service',
|
||||
require => Service['phc2sys'],
|
||||
}
|
||||
-> exec { 'enable-phc2sys':
|
||||
command => '/usr/bin/systemctl enable phc2sys.service',
|
||||
}
|
||||
} else {
|
||||
exec { 'disable-ptp4l':
|
||||
command => '/usr/bin/systemctl disable ptp4l.service',
|
||||
@ -76,7 +94,7 @@ class platform::ptp (
|
||||
-> exec { 'disable-phc2sys':
|
||||
command => '/usr/bin/systemctl disable phc2sys.service',
|
||||
}
|
||||
exec { 'stop-ptp4l':
|
||||
-> exec { 'stop-ptp4l':
|
||||
command => '/usr/bin/systemctl stop ptp4l.service',
|
||||
}
|
||||
-> exec { 'stop-phc2sys':
|
||||
@ -84,3 +102,7 @@ class platform::ptp (
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class platform::ptp::runtime {
|
||||
class { 'platform::ptp': runtime => true }
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
OPTIONS="-a -r -f /etc/ptp4l.conf <%= @phc2sys_options %>"
|
||||
OPTIONS="-a -r -f /etc/ptp4l.conf <%= @phc2sys_cmd_opts %>"
|
||||
|
@ -5,7 +5,7 @@ After=ptp4l.service
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=-/etc/sysconfig/phc2sys
|
||||
ExecStart=-/usr/sbin/phc2sys $OPTIONS
|
||||
ExecStart=/usr/sbin/phc2sys $OPTIONS
|
||||
ExecStartPost=/bin/bash -c 'echo $MAINPID > /var/run/phc2sys.pid'
|
||||
ExecStopPost=/bin/rm -f /var/run/phc2sys.pid
|
||||
Restart=on-failure
|
||||
|
@ -6,7 +6,7 @@ Wants=network-online.target
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=-/etc/sysconfig/ptp4l
|
||||
ExecStart=-/usr/sbin/ptp4l $OPTIONS
|
||||
ExecStart=/usr/sbin/ptp4l $OPTIONS
|
||||
ExecStartPost=/bin/bash -c 'echo $MAINPID > /var/run/ptp4l.pid'
|
||||
ExecStopPost=/bin/rm -f /var/run/ptp4l.pid
|
||||
Restart=on-failure
|
||||
|
Loading…
x
Reference in New Issue
Block a user