Initial commit - Install server + agent.

This commit is contained in:
2021-09-17 08:37:23 +02:00
parent 1e984d21be
commit 891ea2a47b
6 changed files with 77 additions and 7 deletions

View File

@@ -1,2 +1,49 @@
---
# tasks file for ansible_role
# 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