websoft9/apps/roles/role_init/tasks/main.yml
2022-07-11 15:11:22 +08:00

40 lines
1.0 KiB
YAML

- block:
- name: Create credentials Folder
file:
path: /credentials
state: directory
- name: Create a PHP symbolic link
file:
src: "{{installpath}}/{{item}}/.env"
dest: "/credentials/{{item}}_password.txt"
state: link
loop: "{{applist.stdout_lines}}"
- name: Copy Init Script
template:
src: init.sh.jinja2
dest: /credentials/init.sh
mode: 0750
- name: Upload init-apps.service
template:
src: init-apps.service.jinja2
dest: /lib/systemd/system/init-apps.service
- name: Enable service
service:
name: init-apps
enabled: yes
- block:
- name: Check init, if /credentials/* file not exist or no content, stop and exit Ansible
shell: |
[ -s /credentials/password.txt ] && [ -s /credentials/init.sh ] && init_initpasswd=true || init_initpasswd=false
echo $init_initpasswd
register: init_check
- name: Output error when init.sh fail
fail: msg="init role is not done,exit!"
when: init_check.stdout == "false"