Add remote_server
This commit is contained in:
parent
fe000e168f
commit
5b76f14734
@ -72,6 +72,10 @@ all:
|
|||||||
ansible_host: 192.168.50.186
|
ansible_host: 192.168.50.186
|
||||||
vars:
|
vars:
|
||||||
ip: 186
|
ip: 186
|
||||||
|
remote_server:
|
||||||
|
ansible_host:
|
||||||
|
ansible_become_password:
|
||||||
|
ansible_user: ubuntu
|
||||||
children:
|
children:
|
||||||
raspberry:
|
raspberry:
|
||||||
hosts:
|
hosts:
|
||||||
|
4
main.yml
4
main.yml
@ -19,3 +19,7 @@
|
|||||||
- hosts: router.lan
|
- hosts: router.lan
|
||||||
roles:
|
roles:
|
||||||
- router
|
- router
|
||||||
|
|
||||||
|
- hosts: remote_server
|
||||||
|
roles:
|
||||||
|
- docker
|
||||||
|
17
roles/docker/tasks/docker-cron.yml
Normal file
17
roles/docker/tasks/docker-cron.yml
Normal 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"
|
49
roles/docker/tasks/install-docker-ce.yml
Normal file
49
roles/docker/tasks/install-docker-ce.yml
Normal 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
|
20
roles/docker/tasks/install-docker-io.yml
Normal file
20
roles/docker/tasks/install-docker-io.yml
Normal 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
|
8
roles/docker/tasks/main.yml
Normal file
8
roles/docker/tasks/main.yml
Normal 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
|
Loading…
Reference in New Issue
Block a user