This has been tested on a CentOS Stream 9 host.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/playbooks/deploy-appliers.yml | 2 +-
scripts/playbooks/deploy-db.yml | 7 ++-
scripts/playbooks/deploy-importers-lore.yml | 4 +-
scripts/playbooks/deploy-importers.yml | 2 +-
scripts/playbooks/deploy-servers.yml | 10 +++-
.../{docker-deploy.yml => podman-deploy.yml} | 55 ++++++++++---------
.../{docker.service.j2 => podman.service.j2} | 12 ++--
7 files changed, 50 insertions(+), 42 deletions(-)
rename scripts/playbooks/tasks/{docker-deploy.yml => podman-deploy.yml} (45%)
rename scripts/playbooks/templates/{docker.service.j2 => podman.service.j2} (38%)
diff --git a/scripts/playbooks/deploy-appliers.yml b/scripts/playbooks/deploy-appliers.yml
index fa5118e..863c167 100644
--- a/scripts/playbooks/deploy-appliers.yml
+++ b/scripts/playbooks/deploy-appliers.yml
@@ -47,6 +47,6 @@
template:
src: "templates/applier-config.j2"
dest: "{{ config_file }}"
- - import_tasks: tasks/docker-deploy.yml
+ - import_tasks: tasks/podman-deploy.yml
vars:
instance_role: applier
diff --git a/scripts/playbooks/deploy-db.yml b/scripts/playbooks/deploy-db.yml
index 2bb514f..daac7b5 100644
--- a/scripts/playbooks/deploy-db.yml
+++ b/scripts/playbooks/deploy-db.yml
@@ -12,11 +12,16 @@
base_dir: "{{ container_dir }}/{{ instance_name }}"
src_dir: "{{ base_dir }}/src"
data_dir: "{{ base_dir }}/data"
+ podman_run_args: "--net patchew"
tasks:
- name: Create data dir
file:
path: "{{ data_dir }}"
state: directory
- - import_tasks: tasks/docker-deploy.yml
+ - name: Create podman network
+ containers.podman.podman_network:
+ name: patchew
+ become: true
+ - import_tasks: tasks/podman-deploy.yml
vars:
instance_role: db
diff --git a/scripts/playbooks/deploy-importers-lore.yml b/scripts/playbooks/deploy-importers-lore.yml
index 0ccbf8e..ab76ba6 100644
--- a/scripts/playbooks/deploy-importers-lore.yml
+++ b/scripts/playbooks/deploy-importers-lore.yml
@@ -28,7 +28,7 @@
src_dir: "{{ base_dir }}/src"
data_dir: "{{ base_dir }}/data"
config_file: "{{ data_dir }}/config"
- docker_run_args: "--init"
+ podman_run_args: "--init"
tasks:
- name: Create data dir
file:
@@ -38,6 +38,6 @@
template:
src: "templates/importer-lore-config.j2"
dest: "{{ config_file }}"
- - import_tasks: tasks/docker-deploy.yml
+ - import_tasks: tasks/podman-deploy.yml
vars:
instance_role: importer-lore
diff --git a/scripts/playbooks/deploy-importers.yml b/scripts/playbooks/deploy-importers.yml
index 1ef6c80..3711dbd 100644
--- a/scripts/playbooks/deploy-importers.yml
+++ b/scripts/playbooks/deploy-importers.yml
@@ -58,6 +58,6 @@
template:
src: "templates/importer-config.j2"
dest: "{{ config_file }}"
- - import_tasks: tasks/docker-deploy.yml
+ - import_tasks: tasks/podman-deploy.yml
vars:
instance_role: importer
diff --git a/scripts/playbooks/deploy-servers.yml b/scripts/playbooks/deploy-servers.yml
index bf709a0..6b81f9a 100644
--- a/scripts/playbooks/deploy-servers.yml
+++ b/scripts/playbooks/deploy-servers.yml
@@ -25,19 +25,23 @@
src_dir: "{{ base_dir }}/src"
data_dir: "{{ base_dir }}/data"
db_arg: "{{ '-e PATCHEW_DB_PORT_5432_TCP_ADDR=' if db_host != '' else '' }}{{ db_host }}"
- docker_run_args: "--link {{ instance_name }}-db:patchew-db {{db_arg}}"
+ podman_run_args: "--net patchew {{db_arg}}"
tasks:
- name: Create data dir
file:
path: "{{ data_dir }}"
state: directory
- - import_tasks: tasks/docker-deploy.yml
+ - name: Create podman network
+ containers.podman.podman_network:
+ name: patchew
+ become: true
+ - import_tasks: tasks/podman-deploy.yml
vars:
instance_role: server
- name: Create superuser
when: superuser_name != ""
shell: |
- docker exec -i {{ instance_name }} bash -c "
+ podman exec -i {{ instance_name }} bash -c "
cd /opt/patchew &&
. venv/bin/activate &&
./manage.py migrate &&
diff --git a/scripts/playbooks/tasks/docker-deploy.yml b/scripts/playbooks/tasks/podman-deploy.yml
similarity index 45%
rename from scripts/playbooks/tasks/docker-deploy.yml
rename to scripts/playbooks/tasks/podman-deploy.yml
index 2cd2f32..6d7792f 100644
--- a/scripts/playbooks/tasks/docker-deploy.yml
+++ b/scripts/playbooks/tasks/podman-deploy.yml
@@ -4,27 +4,17 @@
name: rsync
- name: Install pip
package:
- name: python-pip
-- name: Install docker
+ name: python3-pip
+- name: Install podman
package:
- name: docker
-- name: Start docker daemon
- service:
- name: docker
- state: started
-- name: Install docker python library for ansible
- pip:
- name: docker-py
-- name: Install SELinux python bindings (for systemd setup)
- package:
- name: libselinux-python
+ name: podman
- name: Stop systemd service for "{{ instance_name }}"
service:
name: "{{ instance_name }}"
state: stopped
ignore_errors: yes
-- name: Stop docker instance
- docker_container:
+- name: Stop podman instance
+ containers.podman.podman_container:
name: "{{ instance_name }}"
state: absent
- name: Create patchew data folder
@@ -40,27 +30,38 @@
owner: no
delete: yes
rsync_opts:
+ - "--exclude=__pycache__"
- "--exclude=*.pyc"
- - "--exclude=*.swp"
+ - "--exclude=*.pyo"
+ - "--exclude=*.sw*"
- "--exclude=/venv"
-- name: Delete old docker image stash
- docker_image:
- force_absent: yes
+- name: Check for existing backup image
+ containers.podman.podman_image_info:
name: "patchew:{{ instance_name }}-prev"
- state: absent
-- name: Stash docker image
- shell: docker tag "patchew:{{ instance_name }}" "patchew:{{ instance_name }}-prev" || true
-- name: Rebuild docker image
- # docker_image module doesn't work on Fedora
- shell: docker build -t "patchew:{{ instance_name }}" -f "{{ src_dir }}/scripts/dockerfiles/{{ instance_role }}.docker" "{{ src_dir }}"
+ register: prev_image
+- name: Delete old podman image stash
+ shell: "podman untag 'patchew:{{ instance_name }}-prev'"
+ when: prev_image.images
+- name: Check for existing image
+ containers.podman.podman_image_info:
+ name: "patchew:{{ instance_name }}"
+ register: current_image
+- name: Stash podman image
+ containers.podman.podman_tag:
+ image: "patchew:{{ instance_name }}"
+ target_names: "patchew:{{ instance_name }}-prev"
+ when: current_image.images
+- name: Rebuild podman image
+ # docker_image module wants a file named Dockerfile
+ shell: "podman build -t 'patchew:{{ instance_name }}' -f '{{ src_dir }}/scripts/dockerfiles/{{ instance_role }}.docker' '{{ src_dir }}'"
- name: Install systemd service
template:
- src: "templates/docker.service.j2"
+ src: "templates/podman.service.j2"
dest: "/etc/systemd/system/{{ instance_name }}.service"
- name: Systemd daemon reload
systemd:
daemon_reload: yes
-- name: Start docker instance
+- name: Start podman instance
service:
name: "{{ instance_name }}"
state: restarted
diff --git a/scripts/playbooks/templates/docker.service.j2 b/scripts/playbooks/templates/podman.service.j2
similarity index 38%
rename from scripts/playbooks/templates/docker.service.j2
rename to scripts/playbooks/templates/podman.service.j2
index 85dd9d2..e1edfb9 100644
--- a/scripts/playbooks/templates/docker.service.j2
+++ b/scripts/playbooks/templates/podman.service.j2
@@ -1,18 +1,18 @@
[Unit]
-Description=Patchew docker instance control service for {{ instance_name }}
-Requires=docker.service
-After=docker.service
+Description=Patchew podman instance control service for {{ instance_name }}
+Requires=network.target
+After=network.target
StartLimitIntervalSec=0
[Service]
Restart=always
-ExecStartPre=-/usr/bin/docker stop {{ instance_name }} ; -/usr/bin/docker rm {{ instance_name }}
-ExecStart=/usr/bin/docker run --privileged --name {{ instance_name }} \
+ExecStartPre=-podman stop {{ instance_name }} ; -podman rm {{ instance_name }}
+ExecStart=podman run --privileged --name {{ instance_name }} \
-v {{ data_dir }}:/data/patchew:rw \
-e PATCHEW_DATA_DIR=/data/patchew \
- {{ docker_run_args | default() }} \
+ {{ podman_run_args | default() }} \
patchew:{{ instance_name }}
-ExecStop=/usr/bin/docker stop -t 10 {{ instance_name }}
+ExecStop=podman stop -t 10 {{ instance_name }}
RestartSec=60
[Install]
--
2.38.1
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/patchew-devel
© 2016 - 2024 Red Hat, Inc.