Fix for debian testing
This commit is contained in:
parent
736ad7f351
commit
3c13fb3e78
|
@ -17,7 +17,7 @@ docker_compose_path: /usr/local/bin/docker-compose
|
|||
# Used only for Debian/Ubuntu. Switch 'stable' to 'edge' if needed.
|
||||
docker_apt_release_channel: stable
|
||||
docker_apt_arch: amd64
|
||||
docker_apt_repository: "deb [arch={{ docker_apt_arch }}] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}"
|
||||
docker_apt_repository: "deb [arch={{ docker_apt_arch }}] https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_local.debian_docker_version.safe_version }} {{ docker_apt_release_channel }}"
|
||||
docker_apt_ignore_key_error: true
|
||||
|
||||
# Used only for RedHat/CentOS/Fedora.
|
||||
|
|
37
files/debian_docker_version.fact
Normal file
37
files/debian_docker_version.fact
Normal file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
DEBIAN_VERSION_MAP = {8: "jessie", 9: "stretch", 10: "buster", 11: "bullseye"}
|
||||
|
||||
|
||||
def debian_distribution():
|
||||
with open("/etc/debian_version") as f:
|
||||
debian_version_string = f.read().strip("\n")
|
||||
if debian_version_string.endswith("/sid"):
|
||||
return debian_version_string.strip("/sid")
|
||||
try:
|
||||
major, minor = debian_version_string.split(".")
|
||||
release_number = int(major)
|
||||
return DEBIAN_VERSION_MAP[release_number]
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
def debian_distribution_docker_safe():
|
||||
debian_version = debian_distribution()
|
||||
if debian_version == "bullseye":
|
||||
json.dump({"version": "bullseye", "safe_version": "buster"}, sys.stdout)
|
||||
elif debian_version is not None:
|
||||
json.dump(
|
||||
{"version": debian_version, "safe_version": debian_version}, sys.stdout
|
||||
)
|
||||
else:
|
||||
json.dump("", sys.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
debian_distribution_docker_safe()
|
|
@ -1,4 +1,20 @@
|
|||
---
|
||||
- name: Ensure custom facts directory is present
|
||||
file:
|
||||
path: /etc/ansible/facts.d/
|
||||
state: directory
|
||||
|
||||
- name: Ensure custom fact is present
|
||||
copy:
|
||||
src: files/debian_docker_version.fact
|
||||
dest: /etc/ansible/facts.d
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
- name: reload facts
|
||||
setup: filter=ansible_local
|
||||
|
||||
- name: Ensure old versions of Docker are not installed.
|
||||
package:
|
||||
name:
|
||||
|
@ -11,11 +27,12 @@
|
|||
name:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- gnupg2
|
||||
state: present
|
||||
|
||||
- name: Add Docker apt key.
|
||||
apt_key:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
url: https://download.docker.com/linux/debian/gpg
|
||||
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
|
||||
state: present
|
||||
register: add_repository_key
|
||||
|
@ -28,7 +45,7 @@
|
|||
- name: Add Docker apt key (alternative for older systems without SNI).
|
||||
shell: |
|
||||
set -o pipefail
|
||||
curl -sSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||
curl -sSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
|
||||
args:
|
||||
warn: false
|
||||
when: add_repository_key is failed
|
||||
|
|
Loading…
Reference in New Issue
Block a user