Skip to content

Commit

Permalink
Validate systemd unit files
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
VannTen committed Nov 17, 2023
1 parent bc5b38a commit 6b72d3f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions roles/container-engine/containerd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
src: containerd.service.j2
dest: /etc/systemd/system/containerd.service
mode: 0644
validate: "systemd-analyze verify %s:containerd.service"
notify: Restart containerd

- name: Containerd | Ensure containerd directories exist
Expand Down
1 change: 1 addition & 0 deletions roles/container-engine/cri-dockerd/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
mode: 0644
validate: "systemd-analyze verify %s:{{ item }}"
with_items:
- cri-dockerd.service
- cri-dockerd.socket
Expand Down
2 changes: 2 additions & 0 deletions roles/etcd/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
dest: /etc/systemd/system/etcd.service
backup: yes
mode: 0644
validate: "systemd-analyze verify %s:etcd-{{ etcd_deployment_type }}.service"
when: is_etcd_master and etcd_cluster_setup

- name: Configure | Copy etcd-events.service systemd file
Expand All @@ -59,6 +60,7 @@
dest: /etc/systemd/system/etcd-events.service
backup: yes
mode: 0644
validate: "systemd-analyze verify %s:etcd-events-{{ etcd_deployment_type }}.service"
when: is_etcd_master and etcd_events_cluster_setup

- name: Configure | reload systemd
Expand Down
1 change: 1 addition & 0 deletions roles/kubernetes/control-plane/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
src: "{{ item }}.j2"
dest: "/etc/systemd/system/{{ item }}"
mode: 0644
validate: "systemd-analyze verify %s:{{item}}"
with_items:
- k8s-certs-renew.service
- k8s-certs-renew.timer
Expand Down
1 change: 1 addition & 0 deletions roles/kubernetes/node/tasks/kubelet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
dest: "/etc/systemd/system/kubelet.service"
backup: "yes"
mode: 0600
validate: "systemd-analyze verify %s:kubelet.service"
notify: Node | restart kubelet
tags:
- kubelet
Expand Down

0 comments on commit 6b72d3f

Please sign in to comment.