websoft9/apps/tasks/install.yml

93 lines
2.8 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-19 17:13:03 +08:00
- name: Git Clone app docker repository and change public IP
2022-07-08 16:22:36 +08:00
block:
2022-07-11 16:05:06 +08:00
- name: Delete {{app}} dir for Second installation
2022-10-22 09:27:21 +08:00
shell: rm -rf {{installpath}}/{{app}} {{installpath}}/library
2022-07-11 16:05:06 +08:00
2022-10-22 09:27:21 +08:00
- name: Clone docker-library in Websoft9
2023-04-17 14:56:21 +08:00
shell: |
wget -N https://websoft9.github.io/StackHub/scripts/githubclone.sh
bash githubclone.sh websoft9 docker-library
mv docker-library library
cp -r library "{{installpath}}"
cp -r "{{installpath}}/library/apps/{{app}}" "{{installpath}}"
2022-12-08 14:01:33 +08:00
2022-12-08 14:12:42 +08:00
- name: Check port file exists
stat:
path: /tmp/port.txt
register: port
- name: Input {{appname}} port
2022-12-08 14:01:33 +08:00
shell: |
cat "{{installpath}}/library/apps/{{appname}}/.env" |grep APP_HTTP_PORT >> /tmp/port.txt
sed -i "s/APP_HTTP_PORT=//g" /tmp/port.txt
2022-12-08 14:12:42 +08:00
when: port.stat.exists == False
2022-07-19 17:13:03 +08:00
2022-07-20 11:31:44 +08:00
- name: Check APP_URL_REPLACE exists
shell: |
cat "{{installpath}}/{{app}}/.env" |grep APP_URL_REPLACE=true
register: http_url_exists
failed_when: false
2022-07-19 17:13:03 +08:00
- name: Change Public IP for http_url if APP_URL_REPLACE=true
shell: |
2022-12-09 11:37:06 +08:00
public_ip=`bash /credentials/get_ip.sh`
2022-10-29 10:42:19 +08:00
urlstr=`grep "APP_URL=" /data/apps/{{app}}/.env |cut -d":" -f1`
2022-09-02 16:44:06 +08:00
sudo sed -i "s/$urlstr/APP_URL=$public_ip/g" /data/apps/{{app}}/.env
2022-07-20 11:31:44 +08:00
when: http_url_exists.stdout != ""
2022-07-08 16:22:36 +08:00
- name: Excute Preparation if have pre.yml
block:
- name: Check if pre.yml exists
2022-12-09 11:37:06 +08:00
stat:
path: ./roles/{{app}}/tasks/pre.yml
2022-07-08 16:22:36 +08:00
register: pre_exists
2022-12-09 11:37:06 +08:00
delegate_to: 127.0.0.1
2022-07-08 16:22:36 +08:00
- name: Excute pre.yml
include_tasks: roles/{{app}}/tasks/pre.yml
2022-12-09 11:37:06 +08:00
when: pre_exists.stat.exists == True
2022-12-08 11:54:36 +08:00
2022-12-09 11:37:06 +08:00
- name: Copy auto_addport.sh
copy: src=../scripts/auto_addport.sh dest=/tmp/auto_addport.sh
2022-12-08 11:54:36 +08:00
- name: If this port in use, add a new port for this app
shell: |
2022-12-09 11:37:06 +08:00
bash /tmp/auto_addport.sh "{{app}}"
2022-12-08 11:54:36 +08:00
when: app != appname
2022-08-01 10:56:14 +08:00
- block:
- name: Docker compose up
shell: |
docker compose up -d
sleep 30
2022-07-05 10:49:24 +08:00
args:
2022-07-08 11:44:10 +08:00
chdir: "{{installpath}}/{{app}}"
2022-08-01 10:56:14 +08:00
- name: Recursively create directory for {{app}}
2022-07-05 10:49:24 +08:00
file:
2022-08-01 10:56:14 +08:00
path: "{{ item }}"
state: directory
recurse: yes
with_items:
- "{{installpath}}/{{app}}/data"
- name: Add softlink of all volumes for app root directory
block:
- name: Get volumes name
shell: docker compose config --volumes
register: volume_names
args:
chdir: "{{installpath}}/{{app}}"
- name: Create softlink of volumes
file:
src: "/var/lib/docker/volumes/{{app}}_{{item}}/_data"
dest: "{{installpath}}/{{app}}/data/{{item}}"
state: link
force: yes
loop: "{{volume_names.stdout_lines}}"