websoft9/apps/roles/install/tasks/main.yml

45 lines
1.3 KiB
YAML
Raw Normal View History

2022-05-12 17:06:06 +08:00
- name: Check {{appname}} exists
stat:
path: /data/apps/{{appname}}
register: app_exists
2022-05-11 11:56:59 +08:00
2022-05-12 17:18:03 +08:00
- name: Clone {{appname}} in Websoft9 if pretask not do this
2022-05-11 12:01:49 +08:00
git:
repo: "https://github.com/Websoft9/docker-{{appname}}.git"
dest: /data/apps/{{appname}}
2022-05-12 17:04:01 +08:00
when: not app_exists.stat.exists
2022-05-11 12:01:49 +08:00
- name: Rename and Run docker-compose
shell: |
docker-compose up -d
sleep 30
args:
chdir: "/data/apps/{{appname}}"
- name: Recursively create directory for {{appname}}
file:
path: "{{ item }}"
state: directory
recurse: yes
with_items:
- "/data/apps/{{appname}}/volumes"
2022-05-12 15:49:18 +08:00
- name: Set softlink of all volumes
block:
- name: Get volumes name
2022-05-12 16:44:26 +08:00
shell: sed -n '/^volumes:/,/^network/{p}' /data/apps/"{{appname}}"/docker-compose.yml |head -n -2 | grep -v "volumes:"
2022-05-12 15:49:18 +08:00
register: volume_names
- name: Create softlink of volumes
file:
2022-05-12 16:26:01 +08:00
src: "/var/lib/docker/volumes/discuzq_{{item | replace(' ', '') | replace(':', '')}}/_data"
dest: "/data/apps/{{appname}}/volumes/{{item | replace(' ', '') | replace(':', '')}}"
2022-05-12 15:49:18 +08:00
state: link
force: yes
2022-05-12 16:45:01 +08:00
loop: "{{volume_names.stdout_lines}}"
2022-05-11 14:40:10 +08:00
2022-05-12 11:57:18 +08:00
- name: Check Docker Container Service
shell: docker ps
register: check_container_service
notify: check_container_service