roles: update handlers/main.yaml and set_opencloud.yaml to optimize init check logic in roles

This commit is contained in:
2026-04-06 23:40:06 +09:00
parent 664cf2956d
commit 8a4ce488f1
2 changed files with 12 additions and 10 deletions

View File

@@ -83,7 +83,7 @@
enabled: true
daemon_reload: true
scope: "user"
when: not (is_opencloud_init_run | default(false))
when: is_opencloud_init.stat.exists
changed_when: false
listen: "notification_restart_opencloud"
ignore_errors: true # noqa: ignore-errors

View File

@@ -12,15 +12,13 @@
become: true
- name: Check data directory empty
ansible.builtin.find:
paths: "{{ node['home_path'] }}/data/containers/opencloud/"
hidden: true
file_type: "any"
ansible.builtin.stat:
path: "{{ node['home_path'] }}/data/containers/opencloud/.init"
become: true
register: "is_data_dir_empty"
register: "is_opencloud_init"
- name: Initialize opencloud
when: is_data_dir_empty.matched == 0
when: not is_opencloud_init.stat.exists
block:
- name: Execute init command (Including pulling image)
containers.podman.podman_container:
@@ -39,9 +37,13 @@
- "{{ node['home_path'] }}/data/containers/opencloud:/var/lib/opencloud:rw"
no_log: true
- name: Set is_opencloud_init_run
ansible.builtin.set_fact:
is_opencloud_init_run: true
- name: Create .init file
ansible.builtin.file:
path: "{{ node['home_path'] }}/data/containers/opencloud/.init"
state: "touch"
mode: "0644"
owner: "{{ ansible_user }}"
group: "svadmins"
- name: Deploy configuration files
ansible.builtin.template: