Add remote_server

This commit is contained in:
Przemek Grondek 2022-06-04 22:55:54 +02:00
parent fe000e168f
commit 5b76f14734
6 changed files with 102 additions and 0 deletions

View File

@ -72,6 +72,10 @@ all:
ansible_host: 192.168.50.186
vars:
ip: 186
remote_server:
ansible_host:
ansible_become_password:
ansible_user: ubuntu
children:
raspberry:
hosts:

View File

@ -19,3 +19,7 @@
- hosts: router.lan
roles:
- router
- hosts: remote_server
roles:
- docker

View File

@ -0,0 +1,17 @@
- name: Clean docker system
become: yes
ansible.builtin.cron:
user: root
name: "clean docker system"
minute: "0"
hour: "3"
job: "/usr/bin/docker system prune -f"
- name: Clean docker image cache
become: yes
ansible.builtin.cron:
user: root
name: "clean docker system"
minute: "0"
hour: "3"
job: "/usr/bin/docker image prune -a -f"

View File

@ -0,0 +1,49 @@
---
- become: yes
block:
- name: install needed packages
apt:
update_cache: yes
pkg:
- apt-transport-https
- ca-certificates
- curl
- gnupg-agent
- software-properties-common
- name: add docker gpg key
apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
- name: add docker repo
apt_repository:
repo: deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
state: present
filename: docker
- name: install docker
apt:
update_cache: yes
pkg:
- docker-ce
- docker-ce-cli
- containerd.io
- name: add current user to docker group
user:
name: "{{ansible_user_id}}"
groups: docker
append: yes
- name: start and enable docker
systemd:
name: docker
state: started
enabled: true
- name: add current user to docker group
user:
name: "{{ ansible_user_id }}"
append: yes
groups: docker

View File

@ -0,0 +1,20 @@
---
- become: yes
block:
- name: install needed packages
apt:
update_cache: yes
pkg:
- docker.io
- name: start and enable docker
systemd:
name: docker
state: started
enabled: true
- name: add current user to docker group
user:
name: "{{ ansible_user_id }}"
append: yes
groups: docker

View File

@ -0,0 +1,8 @@
---
- import_tasks: install-docker-ce.yml
when: ansible_distribution == "Ubuntu" and ansible_distribution_version == "18.04"
- import_tasks: install-docker-io.yml
when: ansible_distribution == "Ubuntu" and ansible_distribution_version != "18.04"
- import_tasks: docker-cron.yml