[CODE] docker: always download latest docker-compose
This commit is contained in:
parent
7ddcfaee9b
commit
92e056e341
|
@ -3,3 +3,5 @@
|
||||||
|
|
||||||
telegraf_docker_file: "telegraf-docker.conf"
|
telegraf_docker_file: "telegraf-docker.conf"
|
||||||
telegraf_snmp_fra80_file: "telegraf-SNMP_fra80.conf"
|
telegraf_snmp_fra80_file: "telegraf-SNMP_fra80.conf"
|
||||||
|
|
||||||
|
dockercompose_use_pip: false
|
||||||
|
|
96
tasks/docker-Debian.yml
Normal file
96
tasks/docker-Debian.yml
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
---
|
||||||
|
# Server/Borgbackup: Install and Setup Borgbackup Backup Crobjob - Default Debian Version
|
||||||
|
# Variables:
|
||||||
|
# - dockercompose_use_pip: boolean to use pip instead of manual download (default: false)
|
||||||
|
|
||||||
|
# Detect some more host facts
|
||||||
|
- name: docker - Detect architecture
|
||||||
|
shell: dpkg --print-architecture
|
||||||
|
register: dpkg_arch
|
||||||
|
- name: docker - Detect debian distributor ID
|
||||||
|
shell: lsb_release -is
|
||||||
|
register: lsb_id
|
||||||
|
|
||||||
|
# Install docker CE
|
||||||
|
- name: docker - Install docker CE APT dependencies
|
||||||
|
become: yes
|
||||||
|
apt:
|
||||||
|
name: "{{ packages }}"
|
||||||
|
state: present
|
||||||
|
vars:
|
||||||
|
packages:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- gnupg2
|
||||||
|
- software-properties-common
|
||||||
|
- name: docker - Add docker CE repo key
|
||||||
|
become: yes
|
||||||
|
apt_key:
|
||||||
|
url: https://download.docker.com/linux/debian/gpg
|
||||||
|
state: present
|
||||||
|
|
||||||
|
# IMPORTANT: raspbian needs deb [arch=armhf] https://download.docker.com/linux/raspbian ...
|
||||||
|
- name: docker - Add docker CE repo (Debian)
|
||||||
|
become: yes
|
||||||
|
apt_repository:
|
||||||
|
repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
|
||||||
|
state: present
|
||||||
|
when: lsb_id.stdout != "Raspbian"
|
||||||
|
- name: docker - Add docker CE repo (Rasbian)
|
||||||
|
become: yes
|
||||||
|
apt_repository:
|
||||||
|
repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable"
|
||||||
|
state: present
|
||||||
|
when: lsb_id.stdout == "Raspbian"
|
||||||
|
|
||||||
|
- name: docker - Install docker CE
|
||||||
|
become: yes
|
||||||
|
apt:
|
||||||
|
name: docker-ce
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
|
|
||||||
|
# Install latest release of docker-compose (does not work for armhf/ arm64)
|
||||||
|
- name: docker-compose - Discover if raspbian is used
|
||||||
|
set_fact:
|
||||||
|
dockercompose_use_pip: true
|
||||||
|
when: lsb_id.stdout == "Raspbian"
|
||||||
|
|
||||||
|
- name: docker-compose - Install x86_46 binary
|
||||||
|
block:
|
||||||
|
- name: docker-compose - Get version number of stable
|
||||||
|
shell: |
|
||||||
|
curl -s https://api.github.com/repos/docker/compose/releases/latest \
|
||||||
|
| grep tag_name \
|
||||||
|
| cut -d '"' -f 4
|
||||||
|
args:
|
||||||
|
warn: false
|
||||||
|
register: latest_dc_version
|
||||||
|
- name: docker-compose - Download and install
|
||||||
|
become: yes
|
||||||
|
get_url:
|
||||||
|
url: "https://github.com/docker/compose/releases/download/{{ latest_dc_version.stdout }}/docker-compose-Linux-x86_64"
|
||||||
|
dest: /usr/local/bin/docker-compose
|
||||||
|
force: yes # otherwise updates will not be downloaded
|
||||||
|
- name: docker-compose - Make docker-compose executable
|
||||||
|
become: yes
|
||||||
|
file:
|
||||||
|
path: /usr/local/bin/docker-compose
|
||||||
|
mode: 0755
|
||||||
|
when: dockercompose_use_pip == false
|
||||||
|
- name: docker-compose - Install using pip3
|
||||||
|
block:
|
||||||
|
- name: docker-compose - Install requirements
|
||||||
|
become: yes
|
||||||
|
apt:
|
||||||
|
name: python3-pip
|
||||||
|
state: present
|
||||||
|
- name: docker-compose - Install using pip3
|
||||||
|
become: yes
|
||||||
|
pip:
|
||||||
|
name: docker-compose
|
||||||
|
executable: pip3
|
||||||
|
when: dockercompose_use_pip == true
|
|
@ -1,48 +1,14 @@
|
||||||
---
|
---
|
||||||
# Server/Docker: Install Docker and Docker-Compose
|
# Server/Docker: Install Docker and Docker-Compose
|
||||||
|
# Variables:
|
||||||
|
# - dockercompose_use_pip: boolean to use pip instead of manual download (default: false)
|
||||||
|
|
||||||
# Install docker CE
|
- name: docker - Install
|
||||||
- name: docker - Install docker CE APT dependencies
|
include_tasks: "{{ item }}"
|
||||||
become: yes
|
with_first_found:
|
||||||
apt:
|
- "docker-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
|
||||||
name: "{{ packages }}"
|
- "docker-{{ ansible_distribution }}.yml"
|
||||||
state: present
|
- "docker-{{ ansible_os_family }}.yml"
|
||||||
vars:
|
|
||||||
packages:
|
|
||||||
- apt-transport-https
|
|
||||||
- ca-certificates
|
|
||||||
- curl
|
|
||||||
- gnupg2
|
|
||||||
- software-properties-common
|
|
||||||
- name: docker - Add docker CE repo key
|
|
||||||
become: yes
|
|
||||||
apt_key:
|
|
||||||
url: https://download.docker.com/linux/debian/gpg
|
|
||||||
state: present
|
|
||||||
- name: docker - Add docker CE add repo
|
|
||||||
become: yes
|
|
||||||
apt_repository:
|
|
||||||
repo: deb [arch=amd64] https://download.docker.com/linux/debian stretch stable
|
|
||||||
state: present
|
|
||||||
- name: docker - Install docker CE
|
|
||||||
become: yes
|
|
||||||
apt:
|
|
||||||
name: docker-ce
|
|
||||||
state: latest
|
|
||||||
update_cache: yes
|
|
||||||
cache_valid_time: 3600
|
|
||||||
|
|
||||||
# Install docker-compose (TODO: do not use a static docker-compose version)
|
|
||||||
- name: docker - Install docker-compose
|
|
||||||
become: yes
|
|
||||||
get_url:
|
|
||||||
url: https://github.com/docker/compose/releases/download/1.23.2/docker-compose-Linux-x86_64
|
|
||||||
dest: /usr/local/bin/docker-compose
|
|
||||||
- name: docker - Make docker-compose executable
|
|
||||||
become: yes
|
|
||||||
file:
|
|
||||||
path: /usr/local/bin/docker-compose
|
|
||||||
mode: 0755
|
|
||||||
|
|
||||||
|
|
||||||
# Other setup tasks
|
# Other setup tasks
|
||||||
|
|
Loading…
Reference in a new issue