-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
57 lines (51 loc) · 1.64 KB
/
playbook.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
- name: Raspberry Pi Post Install
hosts: all
become: true
vars:
debug: true
tasks:
- name: Update and upgrade apt packages
become: true
ansible.builtin.apt:
upgrade: true
update_cache: true
cache_valid_time: 86400
- name: Install Docker
ansible.builtin.apt:
name: ["runc", "docker.io", "docker-compose"]
allow_unauthenticated: true
state: present
become: true
become_method: ansible.builtin.sudo
- name: Create "docker" group
ansible.builtin.group:
name: "docker"
state: present
- name: Add "pi" user to "docker" group
ansible.builtin.user:
name: "pi"
groups: "docker"
append: true
- name: Install docker-compose from official github repo
ansible.builtin.get_url:
url: https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64
dest: /usr/local/bin/docker-compose
mode: "u+x,g+x"
# https://docs.ansible.com/ansible/latest/collections/community/docker/docker_container_module.html#ansible-collections-community-docker-docker-container-module
- name: Create portainer container
community.docker.docker_container:
name: portainer
image: portainer/portainer-ce
state: started
recreate: true
restart_policy: always
published_ports:
- "8000:8000"
- "9000:9000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
- name: Congratulations!
ansible.builtin.debug:
msg:
- "Your Raspberry Pi is ready now!"