Skip to content

Commit e9e3e60

Browse files
committed
playbooks: switch from docker to podman
This has been tested on a CentOS Stream 9 host. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c613b55 commit e9e3e60

File tree

9 files changed

+104
-94
lines changed

9 files changed

+104
-94
lines changed

scripts/playbooks/deploy-appliers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@
4747
template:
4848
src: "templates/applier-config.j2"
4949
dest: "{{ config_file }}"
50-
- import_tasks: tasks/docker-deploy.yml
50+
- import_tasks: tasks/podman-deploy.yml
5151
vars:
5252
instance_role: applier

scripts/playbooks/deploy-db.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
base_dir: "{{ container_dir }}/{{ instance_name }}"
1313
src_dir: "{{ base_dir }}/src"
1414
data_dir: "{{ base_dir }}/data"
15+
podman_run_args: "--net patchew"
1516
tasks:
1617
- name: Create data dir
1718
file:
1819
path: "{{ data_dir }}"
1920
state: directory
20-
- import_tasks: tasks/docker-deploy.yml
21+
- name: Create podman network
22+
containers.podman.podman_network:
23+
name: patchew
24+
become: true
25+
- import_tasks: tasks/podman-deploy.yml
2126
vars:
2227
instance_role: db

scripts/playbooks/deploy-importers-lore.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
src_dir: "{{ base_dir }}/src"
2929
data_dir: "{{ base_dir }}/data"
3030
config_file: "{{ data_dir }}/config"
31-
docker_run_args: "--init"
31+
podman_run_args: "--init"
3232
tasks:
3333
- name: Create data dir
3434
file:
@@ -38,6 +38,6 @@
3838
template:
3939
src: "templates/importer-lore-config.j2"
4040
dest: "{{ config_file }}"
41-
- import_tasks: tasks/docker-deploy.yml
41+
- import_tasks: tasks/podman-deploy.yml
4242
vars:
4343
instance_role: importer-lore

scripts/playbooks/deploy-importers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@
5858
template:
5959
src: "templates/importer-config.j2"
6060
dest: "{{ config_file }}"
61-
- import_tasks: tasks/docker-deploy.yml
61+
- import_tasks: tasks/podman-deploy.yml
6262
vars:
6363
instance_role: importer

scripts/playbooks/deploy-servers.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,23 @@
2525
src_dir: "{{ base_dir }}/src"
2626
data_dir: "{{ base_dir }}/data"
2727
db_arg: "{{ '-e PATCHEW_DB_PORT_5432_TCP_ADDR=' if db_host != '' else '' }}{{ db_host }}"
28-
docker_run_args: "--link {{ instance_name }}-db:patchew-db {{db_arg}}"
28+
podman_run_args: "--net patchew {{db_arg}}"
2929
tasks:
3030
- name: Create data dir
3131
file:
3232
path: "{{ data_dir }}"
3333
state: directory
34-
- import_tasks: tasks/docker-deploy.yml
34+
- name: Create podman network
35+
containers.podman.podman_network:
36+
name: patchew
37+
become: true
38+
- import_tasks: tasks/podman-deploy.yml
3539
vars:
3640
instance_role: server
3741
- name: Create superuser
3842
when: superuser_name != ""
3943
shell: |
40-
docker exec -i {{ instance_name }} bash -c "
44+
podman exec -i {{ instance_name }} bash -c "
4145
cd /opt/patchew &&
4246
. venv/bin/activate &&
4347
./manage.py migrate &&

scripts/playbooks/tasks/docker-deploy.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
- name: Install rsync
3+
package:
4+
name: rsync
5+
- name: Install pip
6+
package:
7+
name: python3-pip
8+
- name: Install podman
9+
package:
10+
name: podman
11+
- name: Stop systemd service for "{{ instance_name }}"
12+
service:
13+
name: "{{ instance_name }}"
14+
state: stopped
15+
ignore_errors: yes
16+
- name: Stop podman instance
17+
containers.podman.podman_container:
18+
name: "{{ instance_name }}"
19+
state: absent
20+
- name: Create patchew data folder
21+
file:
22+
path: "{{ data_dir }}"
23+
state: directory
24+
- name: Copy source
25+
synchronize:
26+
src: ../../../
27+
dest: "{{ src_dir }}"
28+
recursive: true
29+
group: no
30+
owner: no
31+
delete: yes
32+
rsync_opts:
33+
- "--exclude=__pycache__"
34+
- "--exclude=*.pyc"
35+
- "--exclude=*.pyo"
36+
- "--exclude=*.sw*"
37+
- "--exclude=/venv"
38+
- name: Check for existing backup image
39+
containers.podman.podman_image_info:
40+
name: "patchew:{{ instance_name }}-prev"
41+
register: prev_image
42+
- name: Delete old podman image stash
43+
shell: "podman untag 'patchew:{{ instance_name }}-prev'"
44+
when: prev_image.images
45+
- name: Check for existing image
46+
containers.podman.podman_image_info:
47+
name: "patchew:{{ instance_name }}"
48+
register: current_image
49+
- name: Stash podman image
50+
containers.podman.podman_tag:
51+
image: "patchew:{{ instance_name }}"
52+
target_names: "patchew:{{ instance_name }}-prev"
53+
when: current_image.images
54+
- name: Rebuild podman image
55+
# docker_image module wants a file named Dockerfile
56+
shell: "podman build -t 'patchew:{{ instance_name }}' -f '{{ src_dir }}/scripts/dockerfiles/{{ instance_role }}.docker' '{{ src_dir }}'"
57+
- name: Install systemd service
58+
template:
59+
src: "templates/podman.service.j2"
60+
dest: "/etc/systemd/system/{{ instance_name }}.service"
61+
- name: Systemd daemon reload
62+
systemd:
63+
daemon_reload: yes
64+
- name: Start podman instance
65+
service:
66+
name: "{{ instance_name }}"
67+
state: restarted
68+
enabled: yes

scripts/playbooks/templates/docker.service.j2

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[Unit]
2+
Description=Patchew podman instance control service for {{ instance_name }}
3+
Requires=network.target
4+
After=network.target
5+
StartLimitIntervalSec=0
6+
7+
[Service]
8+
Restart=always
9+
ExecStartPre=-podman stop {{ instance_name }} ; -podman rm {{ instance_name }}
10+
ExecStart=podman run --privileged --name {{ instance_name }} \
11+
-v {{ data_dir }}:/data/patchew:rw \
12+
-e PATCHEW_DATA_DIR=/data/patchew \
13+
{{ podman_run_args | default() }} \
14+
patchew:{{ instance_name }}
15+
ExecStop=podman stop -t 10 {{ instance_name }}
16+
RestartSec=60
17+
18+
[Install]
19+
WantedBy=default.target

0 commit comments

Comments
 (0)