Split up the docker role definitions into separate files
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Noah Knegt <git@noahknegt.com>
This commit is contained in:
2023-03-31 11:08:42 +02:00
parent 1e3249e5e8
commit 2f19e6faa5
5 changed files with 74 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
# ===================================================================================================
# ? ABOUT
# @author : Noah Knegt
# @email : personal@noahknegt.com
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
# @createdOn : 31-03-2023
# @description : This will check if docker is installed as the latest version.
# ===================================================================================================
---
- name: Check docker version
shell: docker --version
register: docker_version
ignore_errors: true
- name: Check if latest version is stable
shell: curl -s https://api.github.com/repos/docker/cli/tags | jq -r '.[0].name' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$'
register: docker_latest_version_stable
ignore_errors: true
- name: Compare versions
set_fact:
docker_update: true
when: docker_version.stdout is not defined or docker_version.stdout != docker_latest_version_stable.stdout

View File

@@ -0,0 +1,14 @@
# ===================================================================================================
# ? ABOUT
# @author : Noah Knegt
# @email : personal@noahknegt.com
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
# @createdOn : 31-03-2023
# @description : This will check if docker is installed as the latest version.
# ===================================================================================================
---
- name: Cleanup docker script
file:
path: /tmp/get-docker.sh
state: absent

View File

@@ -0,0 +1,15 @@
# ===================================================================================================
# ? ABOUT
# @author : Noah Knegt
# @email : personal@noahknegt.com
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
# @createdOn : 31-03-2023
# @description : This will download the docker install script.
# ===================================================================================================
---
- name: Download the docker install script
get_url:
url: https://get.docker.com
dest: /tmp/get-docker.sh
mode: 0755

View File

@@ -0,0 +1,13 @@
# ===================================================================================================
# ? ABOUT
# @author : Noah Knegt
# @email : personal@noahknegt.com
# @repo : https://git.noahknegt.com/noah.knegt/ansible-automations
# @createdOn : 31-03-2023
# @description : This will download the docker install script.
# ===================================================================================================
---
- name: Run the docker install script
shell: /tmp/get-docker.sh
when: docker_update is defined

View File

@@ -8,16 +8,13 @@
# =================================================================================================== # ===================================================================================================
--- ---
- name: Get docker script - include_tasks: check_version.yml
get_url:
url: https://get.docker.com
dest: /tmp/get-docker.sh
mode: 0755
- name: Run docker script - include_tasks: download.yml
shell: /tmp/get-docker.sh when: docker_update is defined
- name: Remove docker script - include_tasks: install.yml
file: when: docker_update is defined
path: /tmp/get-docker.sh
state: absent - include_tasks: cleanup.yml
when: docker_update is defined