Validate systemd unit files (#10597)
* Validate systemd unit files This ensure that we fail early if we have a bad systemd unit file (syntax error, using a version not available in the local version, etc) * Hack to check systemd version for service files validation factory-reset.target was introduced in system 250, same version as the aliasing feature we need for verifying systemd services with ansible. So we only actually executes the validation if that target is present. This is an horrible hack which should be reverted as soon as we drop support for distributions with systemd<250.pull/10627/head
parent
bc5b38a771
commit
0d4f57aa22
|
@ -61,6 +61,9 @@
|
||||||
src: containerd.service.j2
|
src: containerd.service.j2
|
||||||
dest: /etc/systemd/system/containerd.service
|
dest: /etc/systemd/system/containerd.service
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
validate: "sh -c '[ -f /usr/bin/systemd/system/factory-reset.target ] || exit 0 && systemd-analyze verify %s:containerd.service'"
|
||||||
|
# FIXME: check that systemd version >= 250 (factory-reset.target was introduced in that release)
|
||||||
|
# Remove once we drop support for systemd < 250
|
||||||
notify: Restart containerd
|
notify: Restart containerd
|
||||||
|
|
||||||
- name: Containerd | Ensure containerd directories exist
|
- name: Containerd | Ensure containerd directories exist
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
src: "{{ item }}.j2"
|
src: "{{ item }}.j2"
|
||||||
dest: "/etc/systemd/system/{{ item }}"
|
dest: "/etc/systemd/system/{{ item }}"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
validate: "sh -c '[ -f /usr/bin/systemd/system/factory-reset.target ] || exit 0 && systemd-analyze verify %s:{{ item }}'"
|
||||||
|
# FIXME: check that systemd version >= 250 (factory-reset.target was introduced in that release)
|
||||||
|
# Remove once we drop support for systemd < 250
|
||||||
with_items:
|
with_items:
|
||||||
- cri-dockerd.service
|
- cri-dockerd.service
|
||||||
- cri-dockerd.socket
|
- cri-dockerd.socket
|
||||||
|
|
|
@ -51,6 +51,9 @@
|
||||||
dest: /etc/systemd/system/etcd.service
|
dest: /etc/systemd/system/etcd.service
|
||||||
backup: yes
|
backup: yes
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
# FIXME: check that systemd version >= 250 (factory-reset.target was introduced in that release)
|
||||||
|
# Remove once we drop support for systemd < 250
|
||||||
|
validate: "sh -c '[ -f /usr/bin/systemd/system/factory-reset.target ] || exit 0 && systemd-analyze verify %s:etcd-{{ etcd_deployment_type }}.service'"
|
||||||
when: is_etcd_master and etcd_cluster_setup
|
when: is_etcd_master and etcd_cluster_setup
|
||||||
|
|
||||||
- name: Configure | Copy etcd-events.service systemd file
|
- name: Configure | Copy etcd-events.service systemd file
|
||||||
|
@ -59,6 +62,9 @@
|
||||||
dest: /etc/systemd/system/etcd-events.service
|
dest: /etc/systemd/system/etcd-events.service
|
||||||
backup: yes
|
backup: yes
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
validate: "sh -c '[ -f /usr/bin/systemd/system/factory-reset.target ] || exit 0 && systemd-analyze verify %s:etcd-events-{{ etcd_deployment_type }}.service'"
|
||||||
|
# FIXME: check that systemd version >= 250 (factory-reset.target was introduced in that release)
|
||||||
|
# Remove once we drop support for systemd < 250
|
||||||
when: is_etcd_master and etcd_events_cluster_setup
|
when: is_etcd_master and etcd_events_cluster_setup
|
||||||
|
|
||||||
- name: Configure | reload systemd
|
- name: Configure | reload systemd
|
||||||
|
|
|
@ -113,6 +113,9 @@
|
||||||
src: "{{ item }}.j2"
|
src: "{{ item }}.j2"
|
||||||
dest: "/etc/systemd/system/{{ item }}"
|
dest: "/etc/systemd/system/{{ item }}"
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
validate: "sh -c '[ -f /usr/bin/systemd/system/factory-reset.target ] || exit 0 && systemd-analyze verify %s:{{item}}'"
|
||||||
|
# FIXME: check that systemd version >= 250 (factory-reset.target was introduced in that release)
|
||||||
|
# Remove once we drop support for systemd < 250
|
||||||
with_items:
|
with_items:
|
||||||
- k8s-certs-renew.service
|
- k8s-certs-renew.service
|
||||||
- k8s-certs-renew.timer
|
- k8s-certs-renew.timer
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
dest: "/etc/systemd/system/kubelet.service"
|
dest: "/etc/systemd/system/kubelet.service"
|
||||||
backup: "yes"
|
backup: "yes"
|
||||||
mode: 0600
|
mode: 0600
|
||||||
|
validate: "sh -c '[ -f /usr/bin/systemd/system/factory-reset.target ] || exit 0 && systemd-analyze verify %s:kubelet.service'"
|
||||||
|
# FIXME: check that systemd version >= 250 (factory-reset.target was introduced in that release)
|
||||||
|
# Remove once we drop support for systemd < 250
|
||||||
notify: Node | restart kubelet
|
notify: Node | restart kubelet
|
||||||
tags:
|
tags:
|
||||||
- kubelet
|
- kubelet
|
||||||
|
|
Loading…
Reference in New Issue