Add autoinstall docker
This commit is contained in:
parent
e7e0d03f17
commit
0fa2ed983e
4 changed files with 41 additions and 8 deletions
|
@ -1,7 +1,6 @@
|
||||||
---
|
---
|
||||||
- name: Install servers
|
- name: Install servers
|
||||||
hosts: servers
|
hosts: all
|
||||||
become: true
|
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- { role: docker, tags: ['docker'] }
|
- { role: docker, tags: ["docker"] }
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
---
|
|
||||||
|
|
36
roles/docker/tasks/install.yml
Normal file
36
roles/docker/tasks/install.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
- name: set mydistribution
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
mydistribution: "{{ 'rhel' if (ansible_distribution == 'Red Hat Enterprise Linux') else (ansible_distribution | lower) }}"
|
||||||
|
|
||||||
|
- name: Add signing key
|
||||||
|
ansible.builtin.rpm_key:
|
||||||
|
key: "https://download.docker.com/linux/{{ mydistribution }}/gpg"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add repository into repo.d list
|
||||||
|
ansible.builtin.yum_repository:
|
||||||
|
name: docker
|
||||||
|
description: docker repository
|
||||||
|
baseurl: "https://download.docker.com/linux/{{ mydistribution }}/$releasever/$basearch/stable"
|
||||||
|
enabled: true
|
||||||
|
gpgcheck: true
|
||||||
|
gpgkey: "https://download.docker.com/linux/{{ mydistribution }}/gpg"
|
||||||
|
|
||||||
|
- name: Install Docker
|
||||||
|
ansible.builtin.yum:
|
||||||
|
name:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-buildx-plugin
|
||||||
|
- docker-compose-plugin
|
||||||
|
state: latest
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Start Docker
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: "docker"
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
ignore_errors: true # TODO: Remove it (Not work in docker container)
|
|
@ -1,4 +1,4 @@
|
||||||
---
|
---
|
||||||
|
- ansible.builtin.import_tasks: install.yml
|
||||||
- ansible.builtin.import_tasks: base.yml
|
name: base
|
||||||
name: base
|
become: true
|
||||||
|
|
Loading…
Reference in a new issue