From 690360fffc5bdb505f7804c158dba0b37a23abb5 Mon Sep 17 00:00:00 2001 From: haxorof Date: Wed, 28 Jun 2017 00:08:37 +0200 Subject: [PATCH] Fixes #3 --- README.md | 2 ++ defaults/main.yml | 5 +++++ tasks/main-CentOS.yml | 22 +++++++++++++++++++--- tasks/main-Fedora.yml | 22 +++++++++++++++++++--- 4 files changed, 45 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 07f1bb1..3d53428 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ Variables related to this role are listed below: # docker_daemon_config: # experimental: true docker_daemon_config: +# Enable Docker CE Edge +docker_enable_ce_edge: false # Setup Docker to devicemapper as storage driver. Require space to be available on LVM partition for new logical partition. # Uses https://github.com/projectatomic/container-storage-setup docker_setup_devicemapper: false diff --git a/defaults/main.yml b/defaults/main.yml index f5a2397..c3dd585 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,7 +2,12 @@ # defaults file for ansible-role-docker-ce # Daemon configuration (https://docs.docker.com/engine/reference/commandline/dockerd/) +# Example: +# docker_daemon_config: +# experimental: true docker_daemon_config: +# Enable Docker CE Edge +docker_enable_ce_edge: false # Setup Docker to devicemapper as storage driver. Require space to be available on LVM partition for new logical partition. # Uses https://github.com/projectatomic/container-storage-setup docker_setup_devicemapper: false diff --git a/tasks/main-CentOS.yml b/tasks/main-CentOS.yml index 9600c1d..230f132 100644 --- a/tasks/main-CentOS.yml +++ b/tasks/main-CentOS.yml @@ -8,12 +8,28 @@ become: true - name: Add Docker CE repository - shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo - args: - creates: /etc/yum.repos.d/docker-ce.repo + get_url: + url: https://download.docker.com/linux/centos/docker-ce.repo + dest: /etc/yum.repos.d/docker-ce.repo + mode: 0644 become: true register: yum_repo +- name: Determine Docker CE Edge repo status + shell: yum-config-manager docker-ce-edge | grep enabled + ignore_errors: yes + changed_when: false + register: cmd_docker_ce_edge_enabled + +- name: Set current Docker CE Edge repo status fact + set_fact: + fact_docker_ce_edge_enabled: "{{ cmd_docker_ce_edge_enabled.stdout == 'enabled = True' }}" + +- name: Enable/Disable Docker CE Edge Repository + shell: yum-config-manager --{{ (docker_enable_ce_edge == true) | ternary('enable','disable') }} docker-ce-edge + become: true + when: fact_docker_ce_edge_enabled != docker_enable_ce_edge + - name: Update yum cache shell: yum makecache fast become: true diff --git a/tasks/main-Fedora.yml b/tasks/main-Fedora.yml index 638badd..1ff1427 100644 --- a/tasks/main-Fedora.yml +++ b/tasks/main-Fedora.yml @@ -2,12 +2,28 @@ # tasks file for ansible-role-docker-ce - name: Add Docker CE repository - shell: dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo - args: - creates: /etc/yum.repos.d/docker-ce.repo + get_url: + url: https://download.docker.com/linux/fedora/docker-ce.repo + dest: /etc/yum.repos.d/docker-ce.repo + mode: 0644 become: true register: dnf_repo +- name: Determine Docker CE Edge repo status + shell: dnf config-manager --dump docker-ce-edge | grep enabled + ignore_errors: yes + changed_when: false + register: cmd_docker_ce_edge_enabled + +- name: Set current Docker CE Edge repo status fact + set_fact: + fact_docker_ce_edge_enabled: "{{ cmd_docker_ce_edge_enabled.stdout == 'enabled = True' }}" + +- name: Enable/Disable Docker CE Edge Repository + shell: dnf config-manager --set-{{ (docker_enable_ce_edge == true) | ternary('enabled','disabled') }} docker-ce-edge + become: true + when: fact_docker_ce_edge_enabled != docker_enable_ce_edge + - name: Update dnf cache shell: dnf makecache fast become: true