bundles/systemd: also manage systemd-timesyncd
This commit is contained in:
parent
5dc60eb24e
commit
d6da47fc1e
2 changed files with 83 additions and 44 deletions
|
@ -1,57 +1,74 @@
|
|||
timezone = node.metadata.get('timezone', 'UTC')
|
||||
|
||||
actions = {
|
||||
'systemd-reload': {
|
||||
'command': 'systemctl daemon-reload',
|
||||
'cascade_skip': False,
|
||||
'triggered': True,
|
||||
'needed_by': {
|
||||
'svc_systemd:',
|
||||
},
|
||||
},
|
||||
'systemd-hostname': {
|
||||
'command': 'hostnamectl set-hostname {}'.format(node.metadata['hostname']),
|
||||
'unless': '[ "$(hostnamectl --static)" = "{}" ]'.format(node.metadata['hostname']),
|
||||
# Provided by bundle:basic
|
||||
'needs': {
|
||||
'file:/etc/hosts',
|
||||
},
|
||||
},
|
||||
'systemd-timezone': {
|
||||
'command': 'timedatectl set-timezone {}'.format(timezone),
|
||||
'unless': 'timedatectl status | grep -Fi \'time zone\' | grep -i \'{}\''.format(timezone.lower()),
|
||||
},
|
||||
'systemd-enable-ntp': {
|
||||
'command': 'timedatectl set-ntp true',
|
||||
'unless': 'timedatectl status | grep -Fi \'ntp service\' | grep -i \'active\'',
|
||||
actions['systemd-reload'] = {
|
||||
'command': 'systemctl daemon-reload',
|
||||
'cascade_skip': False,
|
||||
'triggered': True,
|
||||
'needed_by': {
|
||||
'svc_systemd:',
|
||||
},
|
||||
}
|
||||
|
||||
files = {
|
||||
'/etc/systemd/journald.conf': {
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'journal': node.metadata.get('systemd/journal', {}),
|
||||
},
|
||||
'triggers': {
|
||||
'svc_systemd:systemd-journald:restart',
|
||||
},
|
||||
actions['systemd-hostname'] = {
|
||||
'command': 'hostnamectl set-hostname {}'.format(node.metadata['hostname']),
|
||||
'unless': '[ "$(hostnamectl --static)" = "{}" ]'.format(node.metadata['hostname']),
|
||||
# Provided by bundle:basic
|
||||
'needs': {
|
||||
'file:/etc/hosts',
|
||||
},
|
||||
}
|
||||
|
||||
directories = {
|
||||
'/usr/local/lib/systemd/system': {
|
||||
'purge': True,
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
},
|
||||
directories['/usr/local/lib/systemd/system'] = {
|
||||
'purge': True,
|
||||
'triggers': {
|
||||
'action:systemd-reload',
|
||||
},
|
||||
}
|
||||
|
||||
svc_systemd = {
|
||||
'systemd-journald': {
|
||||
'needs': {
|
||||
'file:/etc/systemd/journald.conf',
|
||||
},
|
||||
|
||||
# journal settings
|
||||
files['/etc/systemd/journald.conf'] = {
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'journal': node.metadata.get('systemd/journal', {}),
|
||||
},
|
||||
'triggers': {
|
||||
'svc_systemd:systemd-journald:restart',
|
||||
},
|
||||
}
|
||||
|
||||
svc_systemd['systemd-journald'] = {
|
||||
'needs': {
|
||||
'file:/etc/systemd/journald.conf',
|
||||
},
|
||||
}
|
||||
|
||||
# NTP
|
||||
files['/etc/systemd/timesyncd.conf'] = {
|
||||
'triggers': {
|
||||
'svc_systemd:systemd-timesyncd:restart',
|
||||
},
|
||||
}
|
||||
|
||||
actions['systemd-timezone'] = {
|
||||
'command': 'timedatectl set-timezone {}'.format(timezone),
|
||||
'unless': 'timedatectl status | grep -Fi \'time zone\' | grep -i \'{}\''.format(timezone.lower()),
|
||||
'after': {
|
||||
'svc_systemd:systemd-timesyncd',
|
||||
},
|
||||
}
|
||||
|
||||
actions['systemd-enable-ntp'] = {
|
||||
'command': 'timedatectl set-ntp true',
|
||||
'unless': 'timedatectl status | grep -Fi \'ntp service\' | grep -i \'active\'',
|
||||
'after': {
|
||||
'svc_systemd:systemd-timesyncd',
|
||||
},
|
||||
}
|
||||
|
||||
svc_systemd['systemd-timesyncd'] = {
|
||||
'needs': {
|
||||
'file:/etc/systemd/timesyncd.conf',
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue