websoft9/apps/tasks/install.yml

69 lines
2.0 KiB
YAML
Raw Normal View History

2022-07-05 14:28:45 +08:00
- name: Create docker network websoft9
shell: docker network create websoft9
2022-07-05 14:41:02 +08:00
failed_when: False
2022-07-05 14:37:42 +08:00
2022-07-08 16:22:36 +08:00
- name: Git Clone app docker repository
block:
2022-07-11 16:05:06 +08:00
- name: Delete {{app}} dir for Second installation
2022-07-08 16:22:36 +08:00
shell: rm -rf {{installpath}}/{{app}}
2022-07-11 16:05:06 +08:00
2022-07-08 16:22:36 +08:00
- name: Clone {{app}} in Websoft9
git:
repo: "https://github.com/Websoft9/docker-{{app}}.git"
dest: "{{installpath}}/{{app}}"
- name: Excute Preparation if have pre.yml
block:
- name: Check if pre.yml exists
uri:
url: "https://github.com/Websoft9/StackHub/blob/main/apps/roles/{{app}}/tasks/pre.yml"
return_content: yes
register: pre_exists
failed_when: false
- name: Excute pre.yml
include_tasks: roles/{{app}}/tasks/pre.yml
when: pre_exists.status is defined and pre_exists.status == 200
2022-07-05 10:49:24 +08:00
- name: Docker compose up
shell: |
docker compose up -d
sleep 30
args:
2022-07-08 11:44:10 +08:00
chdir: "{{installpath}}/{{app}}"
2022-07-05 10:49:24 +08:00
2022-07-08 11:44:10 +08:00
- name: Recursively create directory for {{app}}
2022-07-05 10:49:24 +08:00
file:
path: "{{ item }}"
state: directory
recurse: yes
with_items:
2022-07-08 11:44:10 +08:00
- "{{installpath}}/{{app}}/data"
2022-07-05 10:49:24 +08:00
- name: Add softlink of all volumes for app root directory
block:
- name: Get volumes name
shell: docker compose config --volumes
register: volume_names
args:
2022-07-08 11:44:10 +08:00
chdir: "{{installpath}}/{{app}}"
2022-07-05 10:49:24 +08:00
- name: Create softlink of volumes
file:
2022-07-08 11:44:10 +08:00
src: "/var/lib/docker/volumes/{{app}}_{{item}}/_data"
dest: "{{installpath}}/{{app}}/data/{{item}}"
2022-07-05 10:49:24 +08:00
state: link
force: yes
loop: "{{volume_names.stdout_lines}}"
2022-07-15 15:09:20 +08:00
- name: Get all of docker container informations
shell: |
wget -O /tmp/containers_version.sh https://raw.githubusercontent.com/Websoft9/StackHub/main/scripts/containers_version.sh
docker ps --format \{\{'json .'\}\}| jq -s map\(\{containername:'.Names',image:'.Image'\}\)
register: dockerlist
- name: Recursively create directory for {{app}}
shell: bash /tmp/containers_version.sh {{item.containername}} {{item.image}}
loop:
- "{{dockerlist.stdout}}"