Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 1 | # Copyright (c) 2023 VEXXHOST, Inc. |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 15 | - name: Remove containerd package |
| 16 | ansible.builtin.package: |
| 17 | name: "{{ containerd_package_name }}" |
| 18 | state: absent |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 19 | |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 20 | - name: Install containerd binaries |
| 21 | ansible.builtin.copy: |
| 22 | src: "{{ containerd_download_unarchive_dest }}/{{ item }}" |
| 23 | dest: "{{ containerd_bin_dir }}/{{ item }}" |
| 24 | mode: "0755" |
| 25 | remote_src: true |
| 26 | loop: "{{ containerd_binaries }}" |
| 27 | notify: Restart containerd |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 28 | |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 29 | - name: Remove containerd orphaned binaries |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 30 | ansible.builtin.file: |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 31 | path: "/usr/bin/{{ item }}" |
| 32 | state: absent |
| 33 | loop: "{{ containerd_binaries }}" |
| 34 | when: containerd_bin_dir != "/usr/bin" |
| 35 | |
| 36 | - name: Create systemd service file for containerd |
| 37 | ansible.builtin.template: |
| 38 | src: containerd.service.j2 |
| 39 | dest: /etc/systemd/system/containerd.service |
| 40 | mode: "0644" |
| 41 | notify: |
| 42 | - Reload systemd |
| 43 | - Restart containerd |
| 44 | |
| 45 | - name: Create folders for configuration |
| 46 | ansible.builtin.file: |
| 47 | dest: "{{ item }}" |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 48 | state: directory |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 49 | mode: "0755" |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 50 | owner: root |
| 51 | group: root |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 52 | with_items: |
| 53 | - "{{ containerd_cfg_dir }}" |
| 54 | - "{{ containerd_storage_dir }}" |
| 55 | - "{{ containerd_state_dir }}" |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 56 | notify: |
| 57 | - Restart containerd |
| 58 | |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 59 | - name: Create containerd config file |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 60 | ansible.builtin.template: |
| 61 | src: config.toml.j2 |
| 62 | dest: /etc/containerd/config.toml |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 63 | owner: root |
| 64 | group: root |
Tadas Sutkaitis | 4ace418 | 2023-02-27 04:31:52 +0200 | [diff] [blame] | 65 | mode: "0644" |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 66 | notify: |
| 67 | - Restart containerd |
| 68 | |
| 69 | - name: Force any restarts if necessary |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 70 | ansible.builtin.meta: flush_handlers |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 71 | |
| 72 | - name: Enable and start service |
| 73 | ansible.builtin.service: |
| 74 | name: containerd |
| 75 | enabled: true |
| 76 | state: started |