added install for docker-compose, supports 'latest' as a version
This commit is contained in:
parent
f0b868b84a
commit
f1de8adce3
@ -2,7 +2,7 @@
|
|||||||
# defaults file for install_docker
|
# defaults file for install_docker
|
||||||
install_docker_edition: ce # can be ce or ee (community or enterprise)
|
install_docker_edition: ce # can be ce or ee (community or enterprise)
|
||||||
install_docker_start_service: true
|
install_docker_start_service: true
|
||||||
install_docker_compose: false
|
install_docker_compose: true
|
||||||
install_docker_compose_version: latest
|
install_docker_compose_version: latest
|
||||||
install_docker_python_packages: true
|
install_docker_python_packages: true
|
||||||
install_docker_python_packages_version: latest
|
install_docker_python_packages_version: latest
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
---
|
---
|
||||||
# task/install file for install_docker
|
# task/install file for install_docker
|
||||||
|
- name: "Configure docker repository"
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: ednxzu.manage_repositories
|
||||||
|
vars:
|
||||||
|
manage_repositories_enable_default_repo: false
|
||||||
|
manage_repositories_enable_custom_repo: true
|
||||||
|
manage_repositories_custom_repo: "{{ install_docker_repository }}"
|
||||||
|
|
||||||
- name: "Install docker packages"
|
- name: "Install docker packages"
|
||||||
ansible.builtin.include_role:
|
ansible.builtin.include_role:
|
||||||
name: ednxzu.manage_apt_packages
|
name: ednxzu.manage_apt_packages
|
||||||
|
46
tasks/install_compose.yml
Normal file
46
tasks/install_compose.yml
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
# task/install_compose file for install_docker
|
||||||
|
- name: "Get release for compose:{{ install_docker_compose_version }}"
|
||||||
|
vars:
|
||||||
|
_docker_compose_url_ext: "{% if install_docker_compose_version == 'latest'%}releases{% else %}releases/tags{% endif %}"
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "{{ install_docker_compose_github_api }}/{{ _docker_compose_url_ext }}/{{ install_docker_compose_version }}"
|
||||||
|
return_content: true
|
||||||
|
register: _docker_compose_new_release
|
||||||
|
|
||||||
|
- name: "Check current compose version"
|
||||||
|
command: "{{ install_docker_compose_path }} --version"
|
||||||
|
register: _docker_compose_old_release
|
||||||
|
check_mode: false
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: "Set facts for wanted compose release"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
install_docker_compose_wanted_version: "{{ _docker_compose_new_release.json['tag_name']|regex_replace('v', '') }}"
|
||||||
|
when: _docker_compose_new_release.json is defined
|
||||||
|
and (_docker_compose_new_release.json | length > 0)
|
||||||
|
|
||||||
|
- name: "Set facts for current compose release"
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
install_docker_compose_current_version: "{{ _docker_compose_old_release.stdout | regex_search('(\\d+(\\.\\d+)+)') }}"
|
||||||
|
when: _docker_compose_old_release.stdout is defined
|
||||||
|
and (_docker_compose_old_release.stdout | length > 0)
|
||||||
|
|
||||||
|
- name: "Remove old compose binary if different"
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ install_docker_compose_path }}"
|
||||||
|
state: absent
|
||||||
|
register: _docker_compose_binary_removed
|
||||||
|
when: install_docker_compose_current_version is defined
|
||||||
|
and install_docker_compose_wanted_version not in install_docker_compose_current_version
|
||||||
|
|
||||||
|
- name: "Download and install compose:{{ install_docker_compose_version }}"
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ install_docker_compose_github_url }}/releases/download/v{{ install_docker_compose_wanted_version }}/docker-compose-linux-{{ ansible_architecture }}"
|
||||||
|
dest: "{{ install_docker_compose_path }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0755'
|
||||||
|
when: (install_docker_compose_current_version is not defined)
|
||||||
|
or (_docker_compose_binary_removed.changed)
|
@ -1,10 +1,14 @@
|
|||||||
---
|
---
|
||||||
# task/main file for install_docker
|
# task/main file for install_docker
|
||||||
- name: "Import prerequisites.yml"
|
- name: "Import install_compose.yml"
|
||||||
ansible.builtin.include_tasks: prerequisites.yml
|
ansible.builtin.include_tasks: install_compose.yml
|
||||||
|
when: install_docker_compose
|
||||||
|
|
||||||
- name: "Import install.yml"
|
# - name: "Import prerequisites.yml"
|
||||||
ansible.builtin.include_tasks: install.yml
|
# ansible.builtin.include_tasks: prerequisites.yml
|
||||||
|
#
|
||||||
- name: "Import configure.yml"
|
# - name: "Import install.yml"
|
||||||
ansible.builtin.include_tasks: configure.yml
|
# ansible.builtin.include_tasks: install.yml
|
||||||
|
#
|
||||||
|
# - name: "Import configure.yml"
|
||||||
|
# ansible.builtin.include_tasks: configure.yml
|
@ -1,9 +1,2 @@
|
|||||||
---
|
---
|
||||||
# task/prerequisites file for install_docker
|
# task/prerequisites file for install_docker
|
||||||
- name: "Configure docker repository"
|
|
||||||
ansible.builtin.include_role:
|
|
||||||
name: ednxzu.manage_repositories
|
|
||||||
vars:
|
|
||||||
manage_repositories_enable_default_repo: false
|
|
||||||
manage_repositories_enable_custom_repo: true
|
|
||||||
manage_repositories_custom_repo: "{{ install_docker_repository }}"
|
|
@ -1,5 +1,8 @@
|
|||||||
---
|
---
|
||||||
# vars file for install_docker
|
# vars file for install_docker
|
||||||
|
install_docker_compose_path: "/usr/local/bin/docker-compose"
|
||||||
|
install_docker_compose_github_api: https://api.github.com/repos/docker/compose
|
||||||
|
install_docker_compose_github_url: https://github.com/docker/compose
|
||||||
install_docker_packages:
|
install_docker_packages:
|
||||||
- name: "docker-{{ install_docker_edition }}"
|
- name: "docker-{{ install_docker_edition }}"
|
||||||
version: latest
|
version: latest
|
||||||
@ -13,12 +16,10 @@ install_docker_packages:
|
|||||||
- name: "containerd.io"
|
- name: "containerd.io"
|
||||||
version: latest
|
version: latest
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
install_docker_compose_packages:
|
install_docker_compose_packages:
|
||||||
- name:
|
- name:
|
||||||
version:
|
version:
|
||||||
state: "{{ 'present' if install_docker_compose else 'absent' }}"
|
state: "{{ 'present' if install_docker_compose else 'absent' }}"
|
||||||
|
|
||||||
install_docker_repository:
|
install_docker_repository:
|
||||||
- uri: "https://download.docker.com/linux/{{ ansible_distribution|lower }}"
|
- uri: "https://download.docker.com/linux/{{ ansible_distribution|lower }}"
|
||||||
gpg_key: "https://download.docker.com/linux/{{ ansible_distribution|lower }}/gpg"
|
gpg_key: "https://download.docker.com/linux/{{ ansible_distribution|lower }}/gpg"
|
||||||
|
Loading…
Reference in New Issue
Block a user