-
Notifications
You must be signed in to change notification settings - Fork 0
/
homelab.yml
124 lines (107 loc) · 3.37 KB
/
homelab.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
- hosts: homelab
become: true
gather_facts: false
pre_tasks:
- name: Get facts from 1Password
run_once: true
set_fact:
ansible_become_password: "{{ lookup('community.general.onepassword', 'Homelab', field='password') }}"
ansible_user: "{{ lookup('community.general.onepassword', 'Homelab', field='username') }}"
ansible_ssh_pass: "{{ lookup('community.general.onepassword', 'Homelab', field='password') }}"
- name: Gather facts
ansible.builtin.gather_facts:
tasks:
- name: Update apt
apt:
state: latest
update_cache: true
- name: Required packages
apt:
pkg:
- curl
- ca-certificates
- python3-pip
- bluez
state: latest
- name: Add Docker GPG apt Key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: Add Docker Repository
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu jammy stable
state: present
- name: Install docker
apt:
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
state: latest
- name: Python requirements
ansible.builtin.pip:
state: latest
name:
- docker
- name: Init a new swarm with default parameters
community.docker.docker_swarm:
state: present
- name: Python requirements
ansible.builtin.pip:
state: latest
name:
- jsondiff
- pyyaml
- name: Install Portainer
docker_stack:
state: present
name: portainer
compose:
- version: '3.2'
services:
agent:
image: portainer/agent:2.19.5
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
networks:
- agent_network
deploy:
mode: global
placement:
constraints: [node.platform.os == linux]
portainer:
image: portainer/portainer-ce:2.19.5
command: -H tcp://tasks.agent:9001 --tlsskipverify
ports:
- "9443:9443"
- "9000:9000"
- "8000:8000"
volumes:
- portainer_data:/data
networks:
- agent_network
deploy:
mode: replicated
replicas: 1
placement:
constraints: [node.role == manager]
networks:
agent_network:
driver: overlay
attachable: true
volumes:
portainer_data:
- name: Install HomeAssistant
community.docker.docker_container:
name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
privileged: true
restart_policy: unless-stopped
network_mode: host
volumes:
- /home/homelab/ha_config:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro