Skip to content

Commit

Permalink
allow using podman network for all containers
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
bonzini committed Feb 14, 2023
1 parent 41094d8 commit 831a92b
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
4 changes: 4 additions & 0 deletions scripts/playbooks/deploy-appliers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
prompt: "The base directory for the container"
default: /data
private: no
- name: "podman_network"
prompt: "The podman network to use for the container (empty = none)"
default: ""
private: no
- name: "patchew_server"
prompt: "The address of patchew server"
default: "https://patchew.org"
Expand Down
9 changes: 4 additions & 5 deletions scripts/playbooks/deploy-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@
prompt: "The base directory for the container"
default: /data
private: no
- name: "podman_network"
prompt: "The podman network to use for the container (empty = none)"
default: ""
private: no
vars:
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
- name: Create podman network
containers.podman.podman_network:
name: patchew
become: true
- import_tasks: tasks/podman-deploy.yml
vars:
instance_role: db
4 changes: 4 additions & 0 deletions scripts/playbooks/deploy-importers-lore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
prompt: "The base directory for the container"
default: /data
private: no
- name: "podman_network"
prompt: "The podman network to use for the container (empty = none)"
default: ""
private: no
- name: "patchew_server"
prompt: "The address of patchew server"
default: "https://patchew.org"
Expand Down
4 changes: 4 additions & 0 deletions scripts/playbooks/deploy-importers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
prompt: "The base directory for the container"
default: /data
private: no
- name: "podman_network"
prompt: "The podman network to use for the container (empty = none)"
default: ""
private: no
- name: "patchew_server"
prompt: "The address of patchew server"
default: "https://patchew.org"
Expand Down
11 changes: 5 additions & 6 deletions scripts/playbooks/deploy-servers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
prompt: "The base directory for the container"
default: /data
private: no
- name: "podman_network"
prompt: "The podman network to use for the container (empty = none)"
default: ""
private: no
- name: db_host
prompt: "Host for PostgreSQL database (empty = SQLite)"
default: ""
Expand All @@ -24,8 +28,7 @@
base_dir: "{{ container_dir }}/{{ instance_name }}"
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 }}"
podman_run_args: "--net patchew {{db_arg}}"
podman_run_args: "{{ '-e PATCHEW_DB_PORT_5432_TCP_ADDR=' if db_host != '' else '' }}{{ db_host }}"
tasks:
- name: Create data dir
file:
Expand All @@ -44,10 +47,6 @@
command: "restorecon -v {{ data_dir }}/nginx.sock"
become: true
when: nginx_sock.stat.exists
- name: Create podman network
containers.podman.podman_network:
name: patchew
become: true
- import_tasks: tasks/podman-deploy.yml
vars:
instance_role: server
Expand Down
5 changes: 5 additions & 0 deletions scripts/playbooks/tasks/podman-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
file:
path: "{{ data_dir }}"
state: directory
- name: Create podman network
containers.podman.podman_network:
name: "{{ podman_network }}"
become: true
when: podman_network != ""
- name: Copy source
synchronize:
src: ../../../
Expand Down
2 changes: 1 addition & 1 deletion scripts/playbooks/templates/podman.service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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 \
{{ podman_run_args | default() }} \
{{ " --net " if podman_network else "" }}{{ podman_network }} {{ podman_run_args | default() }} \
patchew:{{ instance_name }}
ExecStop=podman stop -t 10 {{ instance_name }}
RestartSec=60
Expand Down

0 comments on commit 831a92b

Please sign in to comment.