ansible: add docker-compose on VMs
This commit is contained in:
parent
d61af93d85
commit
07c73d8dfc
4 changed files with 97 additions and 5 deletions
|
@ -1,17 +1,25 @@
|
|||
runa:
|
||||
vars:
|
||||
ansible_user: nschottelius
|
||||
ansible_become: true
|
||||
docker_compose: false
|
||||
docker_compose_version: "1.29.1"
|
||||
ssh_keys:
|
||||
- "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE9P5aA5O4Vsgg5sB6Ojk+z1f5F97hvwRRd3gi+a+GGq nico-2016"
|
||||
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjWYALKYHTs6mX7GrrpxR0TPhxwVplmmcTPAA7zjhVCZajcUwLduy3Yct4YXBwRiEydGyhExoVVB8i7UhyvMQsTheRk751uJZyKWIkqbQJoJx1LPmZ00EJNaiIEiJih762D9KWZ1GoLBfB4QAEmoWDzVm3CFJ9tBVEsQ7i9BH+Cbe2GsnqflfWjb09bZhaOSTrmWNcBxgpXirZyi8EI0SrVtmnwVzdH8HXOalvFqW57aY1q/RjE1DIh7Pp+RiGscZz6CJ5oJtSEKbjZ2aUe4gomlQwYmGNVk22RdjvB7+0KDXMwdp702Z5ETv2xYk9v5YrA/lsWk/9JX8vGYb5Y5N+GGG9woZ5M1JIRjXduxNf68VMSQbxZTeonoWkh6Q8CNgDsHyyAyNuPAss7SCCGk5G8s0q/4IDGfV0A1QKFhHOId1qEqGQtLKaRbo6ZTi9wXSieA5D3kMNh+WWufutxI/t56USzNSaeYjqpYwiICBZ8jzWBJrDamiFne4KkW3PTao7Czv6yIeXHHfGYDtdvXppMSjamw+rbA/btTes5X+pYlFxniO5sZJUa+jnJOo3SYBGoRYftqxw7Usqm/i/koHP1RM8L3Iq+/xXNr5+AyFzRBCUUuDfRw1MY1n9OJXvYykNGth4ablfVFcP1R8Qq7jVGksK1dzckzD9SmCdubzwtw== nico-2014"
|
||||
|
||||
children:
|
||||
chdc1:
|
||||
lat:
|
||||
hosts:
|
||||
mtx-elem-1.lat.internal.ru.com:
|
||||
docker_compose: true
|
||||
# 10.165.66.57
|
||||
mtx-elem-2.lat.internal.ru.com:
|
||||
docker_compose: true
|
||||
# 10.165.66.58
|
||||
mtx-syna-1.lat.internal.ru.com:
|
||||
docker_compose: true
|
||||
# 10.165.66.59
|
||||
mtx-syna-2.lat.internal.ru.com:
|
||||
docker_compose: true
|
||||
# 10.165.66.60
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
name: base
|
||||
tags:
|
||||
- base
|
||||
# - name: Add DNS to APU
|
||||
# include_role:
|
||||
# name: apu-service-dns
|
||||
# when: apu_is_service_apu is defined
|
||||
- name: Add docker-compose
|
||||
include_role:
|
||||
name: docker-compose
|
||||
tags:
|
||||
- docker
|
||||
when: docker_compose
|
||||
|
|
|
@ -5,3 +5,6 @@
|
|||
state: present
|
||||
key: "{{ item }}"
|
||||
with_items: "{{ ssh_keys }}"
|
||||
tags:
|
||||
- base
|
||||
- ssh
|
||||
|
|
79
ansible/roles/docker-compose/tasks/main.yml
Normal file
79
ansible/roles/docker-compose/tasks/main.yml
Normal file
|
@ -0,0 +1,79 @@
|
|||
- name: Remove docker if installed from CentOS repo
|
||||
yum:
|
||||
name:
|
||||
- docker
|
||||
- docker-client
|
||||
- docker-client-latest
|
||||
- docker-common
|
||||
- docker-latest
|
||||
- docker-latest-logrotate
|
||||
- docker-logrotate
|
||||
- docker-engine
|
||||
state: absent
|
||||
|
||||
- name: Install required pkgs
|
||||
yum:
|
||||
name:
|
||||
- yum-utils
|
||||
- device-mapper-persistent-data
|
||||
- lvm2
|
||||
state: latest
|
||||
|
||||
- name: Add Docker repo
|
||||
get_url:
|
||||
url: https://download.docker.com/linux/centos/docker-ce.repo
|
||||
dest: /etc/yum.repos.d/docker-ce.repo
|
||||
|
||||
- name: Install Docker
|
||||
yum:
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- containerd.io
|
||||
state: latest
|
||||
|
||||
# - name: Convert old images to new runtime
|
||||
# shell:
|
||||
# cmd: " grep -rl 'docker-runc' /var/lib/docker/containers/ | xargs sed -i 's/docker-runc/runc/g' "
|
||||
# changed_when: false
|
||||
# failed_when: false
|
||||
|
||||
- name: Start Docker service
|
||||
service:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: yes
|
||||
tags:
|
||||
- service
|
||||
- docker
|
||||
|
||||
- name: Check if /usr/local/bin/docker-compose exists.
|
||||
stat:
|
||||
path: /usr/local/bin/docker-compose
|
||||
register: docker_compose_file
|
||||
|
||||
- name: Check current docker-compose version
|
||||
shell:
|
||||
cmd: /usr/local/bin/docker-compose --version | cut -d ' ' -f3 | sed 's/.$//'
|
||||
register: docker_compose_vsn
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
args:
|
||||
warn: no
|
||||
when:
|
||||
- docker_compose_file.stat.exists
|
||||
|
||||
- set_fact:
|
||||
docker_compose_current_version: "{{ docker_compose_vsn.stdout }}"
|
||||
when:
|
||||
- docker_compose_vsn.stdout is defined and docker_compose_file.stat.exists
|
||||
|
||||
- name: Install or upgrade docker-compose
|
||||
get_url:
|
||||
url : "https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64"
|
||||
dest: /usr/local/bin/docker-compose
|
||||
mode: 'a+x'
|
||||
force: yes
|
||||
when: >
|
||||
docker_compose_current_version is not defined
|
||||
or docker_compose_current_version is version(docker_compose_latest, '<')
|
Loading…
Reference in a new issue