Skip to content
Snippets Groups Projects
Commit 850a2d88 authored by Chris Croome's avatar Chris Croome
Browse files

Ansible local_fact tasks updated

parent 752188a2
No related branches found
No related tags found
No related merge requests found
Pipeline #21958 failed
......@@ -5,8 +5,8 @@ galaxy_info:
namespace: chriscroome
description: Ansible role for installing Docker CE on Debian and Ubuntu
company: Webarchitects Co-operative
license: license (GPLv3)
min_ansible_version: 2.9
license: GNU General Public License v3.0 (GPLv3)
min_ansible_version: 2.10
platforms:
- name: debian
versions:
......
......@@ -13,34 +13,51 @@
path: /etc/ansible/facts.d
recurse: true
state: directory
mode: 0700
mode: 0755
owner: root
group: root
- name: Ansible dpkg architecture local fact script present
- name: Ansible local facts scripts present
ansible.builtin.template:
src: dpkg_arch.fact.j2
dest: /etc/ansible/facts.d/dpkg_arch.fact
mode: 0700
src: "{{ script }}.j2"
dest: "/etc/ansible/facts.d/{{ script }}"
mode: 0755
owner: root
group: root
register: apt_arch_facts
loop:
- dpkg.fact
- gpg.fact
- bash.fact
loop_control:
loop_var: script
- name: Re-read Ansible local facts
ansible.builtin.setup:
filter: ansible_local
- name: Check that ansible_local.dpkg_arch is defined
- name: Check that ansible_local facts are defined
ansible.builtin.assert:
that:
- ansible_local.dpkg_arch is defined
- ansible_local.dpkg is defined
- ansible_local.gpg is defined
- ansible_local.bash is defined
- name: Print Ansible dpkg --architecture variables
- name: Print Ansible local dpkg facts
ansible.builtin.debug:
var: ansible_local.dpkg_arch
var: ansible_local.dpkg
verbosity: 2
- name: Print Ansible local gpg facts
ansible.builtin.debug:
var: ansible_local.gpg
verbosity: 2
- name: Print Ansible local bash facts
ansible.builtin.debug:
var: ansible_local.bash
verbosity: 2
tags:
- docker
- docker
- docker_local_facts
...
......@@ -4,7 +4,10 @@
- name: Include Docker local facts tasks
ansible.builtin.include_tasks: local_facts.yml
when: ansible_local.dpkg_arch is not defined
when: >
( ansible_local.dpkg.arch is not defined ) or
( ansible_local.gpg.version is not defined ) or
( ansible_local.bash.path is not defined )
tags:
- docker_apt
- docker_compose_v1
......
#!/usr/bin/env bash
# {{ ansible_managed }}
set -euo pipefail
BASH_PATH=$(which bash)
if [[ -f "${BASH_PATH}" ]]; then
jo state=present path="${BASH_PATH}"
else
jo state=absent
fi
......@@ -2,7 +2,7 @@
Types: deb
URIs: https://download.docker.com/linux/{{ ansible_distribution | lower }}
Architectures: {{ ansible_facts.ansible_local.dpkg_arch.arch }}
Architectures: {{ ansible_facts.ansible_local.dpkg.arch }}
Components: stable
Suites: {{ ansible_distribution_release }}
Signed-By: /etc/apt/keyrings/docker.gpg
#!/usr/bin/env bash
# {{ ansible_managed }}
set -euo pipefail
DPKG="{{ apt_dpkg }}"
if [[ -f "${DPKG}" ]]; then
ARCH=$("${DPKG}" --print-architecture)
jo state=present arch="${ARCH}"
else
jo state=absent
fi
#!/usr/bin/env bash
# {{ ansible_managed }}
set -euo pipefail
GPG="{{ apt_gpg }}"
if [[ -f "${GPG}" ]]; then
VERSION=$("${GPG}" --version | head -n1 | awk '{ print $3 }')
jo state=present version="${VERSION}"
else
jo state=absent
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment