Add portainer container
This commit is contained in:
parent
85ec051700
commit
44261862ad
72
containers/portainer/tasks.yml
Normal file
72
containers/portainer/tasks.yml
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
name: Portainer container manager
|
||||||
|
tasks:
|
||||||
|
- name: Get containers UID
|
||||||
|
ansible.builtin.command: "id -u containers"
|
||||||
|
register: uid_containers
|
||||||
|
changed_when: uid_containers.rc != 0
|
||||||
|
|
||||||
|
- name: Pull portainer image
|
||||||
|
become_user: containers
|
||||||
|
become: true
|
||||||
|
containers.podman.podman_image:
|
||||||
|
name: docker.io/portainer/portainer-ee:latest
|
||||||
|
|
||||||
|
- name: Create traefik-portainer network
|
||||||
|
containers.podman.podman_network:
|
||||||
|
name: traefik-portainer
|
||||||
|
recreate: false
|
||||||
|
state: "present"
|
||||||
|
disable_dns: true
|
||||||
|
become_user: containers
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Create portainer data volume
|
||||||
|
containers.podman.podman_volume:
|
||||||
|
state: present
|
||||||
|
name: portainer
|
||||||
|
become_user: containers
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Create portainer instance
|
||||||
|
become_user: containers
|
||||||
|
become: true
|
||||||
|
containers.podman.podman_container:
|
||||||
|
name: portainer
|
||||||
|
image: docker.io/portainer/portainer-ee:latest
|
||||||
|
state: present
|
||||||
|
security_opt:
|
||||||
|
- label=type:container_runtime_t
|
||||||
|
volume:
|
||||||
|
- /run/user/{{ uid_containers.stdout }}/podman/podman.sock:/var/run/docker.sock:z
|
||||||
|
- portainer:/data:Z
|
||||||
|
network:
|
||||||
|
- traefik-portainer
|
||||||
|
label:
|
||||||
|
io.containers.autoupdate: "registry"
|
||||||
|
traefik.enable: "true"
|
||||||
|
traefik.http.routers.portainer.entrypoints: "https"
|
||||||
|
traefik.http.routers.portainer.rule: "Path(`/portainer`)"
|
||||||
|
traefik.http.routers.portainer.tls: "true"
|
||||||
|
traefik.http.routers.portainer.tls.certresolver: "wildcard"
|
||||||
|
traefik.http.routers.portainer.service: "portainer"
|
||||||
|
traefik.http.services.portainer.loadbalancer.server.port: "9000"
|
||||||
|
traefik.docker.network: "traefik-portainer"
|
||||||
|
generate_systemd:
|
||||||
|
path: /home/containers/.config/systemd/user/
|
||||||
|
restart_policy: on-failure
|
||||||
|
names: true
|
||||||
|
new: true
|
||||||
|
|
||||||
|
- name: Start containers at boot
|
||||||
|
become_user: containers
|
||||||
|
become: true
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
scope: user
|
||||||
|
name: container-{{ item }}.service
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
daemon_reload: true
|
||||||
|
loop:
|
||||||
|
- portainer
|
Loading…
Reference in New Issue
Block a user