103 lines
2.4 KiB
YAML
103 lines
2.4 KiB
YAML
|
---
|
||
|
- name: Update apt cache
|
||
|
apt:
|
||
|
update_cache: yes
|
||
|
|
||
|
- name: Install prerequisite packages
|
||
|
apt:
|
||
|
name:
|
||
|
- apt-transport-https
|
||
|
- ca-certificates
|
||
|
- curl
|
||
|
- gnupg
|
||
|
- lsb-release
|
||
|
state: present
|
||
|
|
||
|
- name: Add Docker GPG key
|
||
|
apt_key:
|
||
|
url: https://download.docker.com/linux/debian/gpg
|
||
|
state: present
|
||
|
|
||
|
- name: Add Docker repository
|
||
|
apt_repository:
|
||
|
repo: "deb [arch=amd64] https://download.docker.com/linux/debian {{ ansible_lsb.codename }} stable"
|
||
|
state: present
|
||
|
|
||
|
- name: Install Docker
|
||
|
apt:
|
||
|
name: docker-ce
|
||
|
state: present
|
||
|
|
||
|
- name: Start and enable Docker service
|
||
|
service:
|
||
|
name: docker
|
||
|
state: started
|
||
|
enabled: yes
|
||
|
|
||
|
- name: Download Docker Compose
|
||
|
get_url:
|
||
|
url: "https://github.com/docker/compose/releases/latest/download/docker-compose-Linux-x86_64"
|
||
|
dest: /usr/local/bin/docker-compose
|
||
|
mode: 'u=rwx,g=rx,o=rx'
|
||
|
|
||
|
- name: Set executable permissions for Docker Compose
|
||
|
file:
|
||
|
path: /usr/local/bin/docker-compose
|
||
|
mode: 'u=rwx,g=rx,o=rx'
|
||
|
|
||
|
- name: install git
|
||
|
apt:
|
||
|
name:
|
||
|
- git
|
||
|
- python3
|
||
|
- python3-pip
|
||
|
update_cache: yes
|
||
|
cache_valid_time: 3600
|
||
|
|
||
|
- name: Install docker package
|
||
|
pip:
|
||
|
name:
|
||
|
- docker
|
||
|
- docker-compose
|
||
|
state: present
|
||
|
|
||
|
# Monitoring
|
||
|
|
||
|
## node exporter
|
||
|
|
||
|
- name: clone private git repository
|
||
|
git:
|
||
|
repo: https://git:{{ git_token }}@git.front.kjuulh.io/kjuulh/node-exporter-local.git
|
||
|
dest: ~/git/git.front.kjuulh.io/kjuulh/node-exporter-local
|
||
|
version: main
|
||
|
force: yes
|
||
|
|
||
|
- name: ensure docker compose file exists
|
||
|
stat:
|
||
|
path: ~/git/git.front.kjuulh.io/kjuulh/node-exporter-local/docker-compose.yml
|
||
|
register: compose_file_stat
|
||
|
|
||
|
- name: run docker compose
|
||
|
docker_compose:
|
||
|
project_src: ~/git/git.front.kjuulh.io/kjuulh/node-exporter-local/
|
||
|
when: compose_file_stat.stat.exists
|
||
|
|
||
|
## container exporter
|
||
|
|
||
|
- name: clone private git repository
|
||
|
git:
|
||
|
repo: https://git:{{ git_token }}@git.front.kjuulh.io/kjuulh/container-exporter-local.git
|
||
|
dest: ~/git/git.front.kjuulh.io/kjuulh/container-exporter-local
|
||
|
version: main
|
||
|
force: yes
|
||
|
|
||
|
- name: ensure docker compose file exists
|
||
|
stat:
|
||
|
path: ~/git/git.front.kjuulh.io/kjuulh/container-exporter-local/docker-compose.yml
|
||
|
register: compose_file_stat
|
||
|
|
||
|
- name: run docker compose
|
||
|
docker_compose:
|
||
|
project_src: ~/git/git.front.kjuulh.io/kjuulh/container-exporter-local/
|
||
|
when: compose_file_stat.stat.exists
|