49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
---
|
|
# tasks file for portainer role
|
|
|
|
#
|
|
# Install portainer server on the server host
|
|
#
|
|
- name: Skip server installation
|
|
debug:
|
|
msg: "Skip server installation because server_host is {{ server_host }}"
|
|
when: server_host == "none"
|
|
|
|
#
|
|
# Install portainer server on the server host
|
|
#
|
|
- name: Install server
|
|
docker_container:
|
|
name: "portainer_{{ inventory_hostname }}"
|
|
hostname: "portainer_{{ inventory_hostname}}"
|
|
domainname: "{{ domain_suffix }}"
|
|
image: "portainer/portainer-ce"
|
|
recreate: yes
|
|
restart: yes
|
|
restart_policy: "always"
|
|
ports:
|
|
- "{{ portainer_port}}:8000"
|
|
- "9000:9000"
|
|
volumes:
|
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
|
- "{{ portainer_config }}:/data"
|
|
when: inventory_hostname == server_host and server_host and server_host != "none"
|
|
|
|
#
|
|
# Install portainer server on the server host
|
|
#
|
|
- name: Install agent
|
|
docker_container:
|
|
name: "portainer_agent_{{ inventory_hostname }}"
|
|
hostname: "portainer_agent_{{ inventory_hostname}}"
|
|
domainname: "{{ domain_suffix }}"
|
|
image: "portainer/agent"
|
|
recreate: yes
|
|
restart: yes
|
|
restart_policy: "always"
|
|
ports:
|
|
- "9001:9001"
|
|
volumes:
|
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
|
- "/var/lib/docker/volumes:/var/lib/docker/volumes"
|
|
when: inventory_hostname != server_host and server_host |