add daemon file template
This commit is contained in:
parent
2e5ad45315
commit
eb59034462
@ -8,3 +8,9 @@ docker_restart_handler_state: restarted
|
|||||||
|
|
||||||
# A list of users who will be added to the docker group.
|
# A list of users who will be added to the docker group.
|
||||||
docker_users: []
|
docker_users: []
|
||||||
|
## yaml docker config convert in json in template
|
||||||
|
# exemaple:
|
||||||
|
# docker_daemon_config:
|
||||||
|
# dns:
|
||||||
|
# - 172.17.0.1
|
||||||
|
docker_daemon_config:
|
||||||
|
@ -1,32 +1,49 @@
|
|||||||
- name: Include OS-specific variables.
|
- name: Include OS-specific variables.
|
||||||
include_vars: "{{ ansible_os_family }}.yml"
|
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
|
||||||
|
|
||||||
- name: Add CentOS repository
|
- name: Add CentOS repository
|
||||||
|
when: ansible_os_family == "RedHat"
|
||||||
|
become: true
|
||||||
block:
|
block:
|
||||||
|
|
||||||
- name: Add Docker repository.
|
- name: Add Docker repository.
|
||||||
get_url:
|
ansible.builtin.get_url:
|
||||||
url: "https://download.docker.com/linux/centos/docker-ce.repo"
|
url: "https://download.docker.com/linux/centos/docker-ce.repo"
|
||||||
dest: '/etc/yum.repos.d/docker-ce.repo'
|
dest: '/etc/yum.repos.d/docker-ce.repo'
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: "0644"
|
||||||
when: ansible_os_family == "RedHat"
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Install Docker.
|
- name: Install Docker.
|
||||||
package:
|
ansible.builtin.package:
|
||||||
name: "{{ docker_package }}"
|
name: "{{ docker_package }}"
|
||||||
state: present
|
state: present
|
||||||
notify: restart docker
|
notify: restart docker
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
- name: Ensure /etc/docker exist
|
||||||
|
ansible.builtin.file:
|
||||||
|
dest: /etc/docker/
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
state: directory
|
||||||
|
become: true
|
||||||
|
|
||||||
|
- name: Template daemon.json
|
||||||
|
ansible.builtin.template:
|
||||||
|
dest: /etc/docker/daemon.json
|
||||||
|
src: template/daemon.json.j2
|
||||||
|
mode: "0644"
|
||||||
|
notify: restart docker
|
||||||
|
become: true
|
||||||
|
|
||||||
- name: Ensure Docker is started and enabled at boot.
|
- name: Ensure Docker is started and enabled at boot.
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: docker
|
name: docker
|
||||||
state: "{{ docker_service_state }}"
|
state: "{{ docker_service_state }}"
|
||||||
enabled: "{{ docker_service_enabled }}"
|
enabled: "{{ docker_service_enabled }}"
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- include_tasks: docker-users.yml
|
- name: Include Users task
|
||||||
|
ansible.builtin.include_tasks: docker-users.yml
|
||||||
when: docker_users | length > 0
|
when: docker_users | length > 0
|
||||||
|
1
template/daemon.json.j2
Normal file
1
template/daemon.json.j2
Normal file
@ -0,0 +1 @@
|
|||||||
|
{{ docker_daemon_config|to_json(indent=4) }}
|
Loading…
Reference in New Issue
Block a user