Linux/Ansible/Playbooks: Difference between revisions
No edit summary |
No edit summary |
||
Line 20: | Line 20: | ||
*: | *: | ||
<pre> | <pre> | ||
- name: Get installed docker-compose version | |||
command: docker-compose --version | |||
register: docker_compose_current_version | |||
changed_when: false | |||
failed_when: false | |||
- name: Get latest docker-compose version | |||
shell: git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | tail -n 1 | |||
register: docker_compose_latest_version | |||
changed_when: false | |||
failed_when: false | |||
- name: Delete existing docker-compose version if its different | |||
file: | |||
path: "/usr/local/bin/docker-compose" | |||
state: absent | |||
when: > | |||
docker_compose_current_version.stdout is defined | |||
and docker_compose_latest_version.stdout not in docker_compose_current_version.stdout | |||
- name: Install Docker Compose | |||
get_url: | |||
url: https://github.com/docker/compose/releases/download/{{ docker_compose_latest_version.stdout }}/docker-compose-Linux-x86_64 | |||
dest: "/usr/local/bin/docker-compose" | |||
mode: 0755 | |||
</pre> | </pre> | ||
Latest revision as of 09:24, 18 May 2019
Docker role
- Docker:
- name: Install prerequisites apt: update_cache: yes name: ["apt-transport-https", "ca-certificates", "curl", "software-properties-common"] - name: Add Docker GPG key apt_key: url=https://download.docker.com/linux/ubuntu/gpg - name: Add Docker APT repository apt_repository: repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ansible_distribution_release}} stable - name: Install Docker apt: name=docker-ce
- Docker-compose:
- name: Get installed docker-compose version command: docker-compose --version register: docker_compose_current_version changed_when: false failed_when: false - name: Get latest docker-compose version shell: git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oP "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | tail -n 1 register: docker_compose_latest_version changed_when: false failed_when: false - name: Delete existing docker-compose version if its different file: path: "/usr/local/bin/docker-compose" state: absent when: > docker_compose_current_version.stdout is defined and docker_compose_latest_version.stdout not in docker_compose_current_version.stdout - name: Install Docker Compose get_url: url: https://github.com/docker/compose/releases/download/{{ docker_compose_latest_version.stdout }}/docker-compose-Linux-x86_64 dest: "/usr/local/bin/docker-compose" mode: 0755