mirror of
https://github.com/JamesTurland/JimsGarage.git
synced 2024-11-24 00:40:21 +00:00
docker
This commit is contained in:
parent
83ca476110
commit
a7b12f0b32
10 changed files with 124 additions and 0 deletions
8
Ansible/Playbooks/Docker-Portainer/inventory.yaml
Normal file
8
Ansible/Playbooks/Docker-Portainer/inventory.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
docker:
|
||||
hosts:
|
||||
docker01:
|
||||
ansible_host: 192.168.200.222
|
||||
ansible_user: 'ubuntu'
|
||||
ansible_become: true
|
||||
ansible_become_method: sudo
|
7
Ansible/Playbooks/Docker-Portainer/playbook.yaml
Normal file
7
Ansible/Playbooks/Docker-Portainer/playbook.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
- name: Install Docker on Ubuntu
|
||||
hosts: all
|
||||
become: true
|
||||
roles:
|
||||
- docker_install
|
||||
- portainer_deploy
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: Restart Docker
|
||||
ansible.builtin.systemd:
|
||||
name: docker
|
||||
state: restarted
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
- name: Ensure apt is using HTTPS
|
||||
ansible.builtin.apt:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
loop:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- software-properties-common
|
||||
|
||||
- name: Add Docker GPG key
|
||||
ansible.builtin.apt_key:
|
||||
url: "https://download.docker.com/linux/ubuntu/gpg"
|
||||
state: present
|
||||
|
||||
- name: Add Docker repository
|
||||
ansible.builtin.apt_repository:
|
||||
repo: "{{ docker_apt_repository }}"
|
||||
state: present
|
||||
|
||||
- name: Install Docker CE
|
||||
ansible.builtin.apt:
|
||||
name: docker-ce
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Configure Docker daemon options
|
||||
ansible.builtin.template:
|
||||
src: "templates/docker_daemon.json.j2"
|
||||
dest: "/etc/docker/daemon.json"
|
||||
owner: 'root'
|
||||
group: 'root'
|
||||
mode: '0755' # Optional file permissions
|
||||
notify: Restart Docker
|
||||
|
||||
- name: Ensure Docker service is enabled and running
|
||||
ansible.builtin.systemd:
|
||||
name: docker
|
||||
enabled: true
|
||||
state: started
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"storage-driver": "{{ docker_daemon_options['storage-driver'] }}"
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
docker_apt_release_channel: "stable"
|
||||
docker_apt_repository: "deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
||||
docker_daemon_options:
|
||||
storage-driver: "overlay2"
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Start Portainer
|
||||
community.docker.docker_compose:
|
||||
project_src: /home/ubuntu/docker-compose/portainer
|
||||
state: present
|
||||
restarted: true
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
- name: Ensure docker-compose is installed
|
||||
ansible.builtin.package:
|
||||
name: docker-compose
|
||||
state: present
|
||||
|
||||
- name: Ensure Docker service is running
|
||||
ansible.builtin.service:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
- name: Setup Portainer directory
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/docker-compose/portainer
|
||||
state: directory
|
||||
mode: '0755' # Optional file permissions
|
||||
owner: ubuntu # Optional ownership
|
||||
group: ubuntu # Optional group ownership
|
||||
|
||||
- name: Deploy Portainer using Docker Compose
|
||||
ansible.builtin.template:
|
||||
src: "templates/docker_compose.yaml.j2"
|
||||
dest: "/home/ubuntu/docker-compose/portainer/docker-compose.yaml"
|
||||
mode: '0755' # Optional file permissions
|
||||
owner: ubuntu # Optional ownership
|
||||
group: ubuntu # Optional group ownership
|
||||
notify:
|
||||
- Start Portainer
|
||||
|
||||
- name: Run Portainer docker-compose up
|
||||
community.docker.docker_compose:
|
||||
project_src: /home/ubuntu/docker-compose/portainer
|
||||
state: present
|
|
@ -0,0 +1,13 @@
|
|||
version: '3.3'
|
||||
services:
|
||||
portainer:
|
||||
image: portainer/portainer-ce:{{ portainer_version }}
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
- portainer_data:/data
|
||||
ports:
|
||||
- "9000:9000"
|
||||
restart: always
|
||||
|
||||
volumes:
|
||||
portainer_data:
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
portainer_version: "latest"
|
Loading…
Reference in a new issue