mirror of
https://github.com/luzifer-ansible/docker.git
synced 2024-11-09 14:20:01 +00:00
Initial version
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
commit
24a81a12d0
4 changed files with 120 additions and 0 deletions
15
defaults/main.yml
Normal file
15
defaults/main.yml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
docker_configure_ipv6: true
|
||||||
|
|
||||||
|
#docker_auth_config:
|
||||||
|
# auths:
|
||||||
|
# my.registry:
|
||||||
|
# auth: '{{ "user:pass" | b64encode }}'
|
||||||
|
docker_auth_config_user: root
|
||||||
|
docker_auth_config_homedir: /root
|
||||||
|
|
||||||
|
docker_start_opts:
|
||||||
|
- -H fd://
|
||||||
|
|
||||||
|
...
|
38
meta/main.yml
Normal file
38
meta/main.yml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: Knut Ahlers
|
||||||
|
description: |
|
||||||
|
Install and configure docker on host
|
||||||
|
|
||||||
|
license: Apache
|
||||||
|
min_ansible_version: 2.3
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: Ubuntu
|
||||||
|
versions:
|
||||||
|
- xenial
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- jessie
|
||||||
|
- stretch
|
||||||
|
|
||||||
|
categories:
|
||||||
|
#- cloud
|
||||||
|
#- cloud:ec2
|
||||||
|
#- cloud:gce
|
||||||
|
#- cloud:rax
|
||||||
|
#- clustering
|
||||||
|
#- database
|
||||||
|
#- database:nosql
|
||||||
|
#- database:sql
|
||||||
|
#- development
|
||||||
|
#- monitoring
|
||||||
|
#- networking
|
||||||
|
#- packaging
|
||||||
|
- system
|
||||||
|
#- web
|
||||||
|
|
||||||
|
dependencies: []
|
||||||
|
# List your role dependencies here, one per line.
|
||||||
|
# Be sure to remove the '[]' above if you add dependencies
|
||||||
|
# to this list.
|
64
tasks/main.yml
Normal file
64
tasks/main.yml
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Install apt-key
|
||||||
|
apt_key:
|
||||||
|
id: 0EBFCD88
|
||||||
|
keyserver: keyserver.ubuntu.com
|
||||||
|
|
||||||
|
- name: Ensure https transport to be available
|
||||||
|
apt:
|
||||||
|
name: apt-transport-https
|
||||||
|
|
||||||
|
- name: Activate apt-repo
|
||||||
|
apt_repository:
|
||||||
|
repo: 'deb https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable'
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Install docker
|
||||||
|
apt:
|
||||||
|
name: docker-ce
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
docker_global_ipv6: "{{ ansible_eth0.ipv6 | selectattr('scope', 'equalto', 'global') | first }}"
|
||||||
|
when: docker_configure_ipv6 and ansible_eth0 and ansible_eth0.ipv6 | selectattr('scope', 'equalto', 'global') | list | length > 0
|
||||||
|
|
||||||
|
- set_fact:
|
||||||
|
docker_ipv6_subnet: "{{ docker_global_ipv6.address | ipsubnet(docker_global_ipv6.prefix) | ipsubnet(80, -1) }}"
|
||||||
|
when: docker_global_ipv6 is defined
|
||||||
|
|
||||||
|
- name: Create docker drop-in directory
|
||||||
|
file:
|
||||||
|
dest: /etc/systemd/system/docker.service.d
|
||||||
|
state: directory
|
||||||
|
|
||||||
|
- name: Configure docker start options
|
||||||
|
template:
|
||||||
|
src: docker-startopts.conf
|
||||||
|
dest: /etc/systemd/system/docker.service.d/docker-startopts.conf
|
||||||
|
register: docker_startopts
|
||||||
|
|
||||||
|
- name: Restart docker to apply new config
|
||||||
|
systemd:
|
||||||
|
name: docker.service
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: yes
|
||||||
|
when: docker_startopts.changed
|
||||||
|
|
||||||
|
- name: Create docker configuration dir
|
||||||
|
file:
|
||||||
|
dest: '{{ docker_auth_config_homedir }}/.docker'
|
||||||
|
mode: 0700
|
||||||
|
owner: '{{ docker_auth_config_user }}'
|
||||||
|
state: directory
|
||||||
|
when: docker_auth_config is defined
|
||||||
|
|
||||||
|
- name: Enable authentication for private registries
|
||||||
|
copy:
|
||||||
|
content: '{{ docker_auth_config | to_nice_json }}'
|
||||||
|
dest: '{{ docker_auth_config_homedir }}/.docker/config.json'
|
||||||
|
mode: 0600
|
||||||
|
owner: '{{ docker_auth_config_user }}'
|
||||||
|
when: docker_auth_config is defined
|
||||||
|
|
||||||
|
...
|
3
templates/docker-startopts.conf
Normal file
3
templates/docker-startopts.conf
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[Service]
|
||||||
|
ExecStart=
|
||||||
|
ExecStart=/usr/bin/dockerd {{ docker_start_opts | join(" ") }} {% if docker_ipv6_subnet is defined and docker_ipv6_subnet %}--ipv6 --fixed-cidr-v6='{{ docker_ipv6_subnet }}'{% endif %}
|
Loading…
Reference in a new issue