Initial commit - Install server + agent.
This commit is contained in:
parent
1e984d21be
commit
891ea2a47b
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cSpell.words": [
|
||||||
|
"domainname",
|
||||||
|
"portainer"
|
||||||
|
]
|
||||||
|
}
|
@ -1,4 +1,6 @@
|
|||||||
---
|
---
|
||||||
# defaults file for ansible-clean-vagrant
|
# defaults file for ansible-clean-vagrant
|
||||||
|
|
||||||
# TODO: Add the necessary variables
|
server_host: none
|
||||||
|
portainer_config: /tmp/config
|
||||||
|
portainer_port: "8000"
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
hosts: all
|
hosts: all
|
||||||
become: true
|
become: true
|
||||||
# Set default variables (if any)
|
# Set default variables (if any)
|
||||||
vars: []
|
vars:
|
||||||
|
server_host: "portainer-server"
|
||||||
|
domain_suffix: "laurii.lan"
|
||||||
|
|
||||||
# Use pre_tasks when you need a setup to be executed each time you run converge.
|
# Use pre_tasks when you need a setup to be executed each time you run converge.
|
||||||
# Otherwise, 'prepare.yml' is the way to go
|
# Otherwise, 'prepare.yml' is the way to go
|
||||||
@ -15,5 +17,5 @@
|
|||||||
# name: "docker_repository"
|
# name: "docker_repository"
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: ansible-clean-vagrant
|
- role: docker.portainer
|
||||||
become: true
|
become: true
|
||||||
|
@ -8,14 +8,24 @@ driver:
|
|||||||
provider:
|
provider:
|
||||||
name: virtualbox
|
name: virtualbox
|
||||||
platforms:
|
platforms:
|
||||||
- name: ubuntu-2004
|
- name: portainer-server
|
||||||
box: generic/ubuntu2004
|
box: generic/ubuntu2004
|
||||||
memory: 8192
|
memory: 8192
|
||||||
cpus: 4
|
cpus: 4
|
||||||
instance_raw_config_args:
|
instance_raw_config_args:
|
||||||
# Forward the necessary ports for your app (if any)
|
# Forward the necessary ports for your app (if any)
|
||||||
#
|
#
|
||||||
- "vm.network 'forwarded_port', guest: 1880, host: 1880"
|
- "vm.network 'forwarded_port', guest: 8000, host: 8000"
|
||||||
|
- "vm.network 'forwarded_port', guest: 9000, host: 9000"
|
||||||
|
|
||||||
|
- name: portainer-agent
|
||||||
|
box: generic/ubuntu2004
|
||||||
|
memory: 8192
|
||||||
|
cpus: 4
|
||||||
|
instance_raw_config_args:
|
||||||
|
# Forward the necessary ports for your app (if any)
|
||||||
|
#
|
||||||
|
- "vm.network 'forwarded_port', guest: 9001, host: 9001"
|
||||||
|
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
|
@ -11,8 +11,11 @@
|
|||||||
apt:
|
apt:
|
||||||
name: ansible
|
name: ansible
|
||||||
state: present
|
state: present
|
||||||
|
autoclean: yes
|
||||||
|
autoremove: yes
|
||||||
|
update_cache: yes
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
# Install docker (and update repos)
|
# Install docker (and update repos)
|
||||||
#
|
#
|
||||||
- name: "Set up docker on the machine"
|
- name: "Set up docker on the machine"
|
||||||
|
@ -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
|
Loading…
Reference in New Issue
Block a user