roles: update handlers/main.yaml and set_opencloud.yaml to optimize init check logic in roles
This commit is contained in:
@@ -83,7 +83,7 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
scope: "user"
|
scope: "user"
|
||||||
when: not (is_opencloud_init_run | default(false))
|
when: is_opencloud_init.stat.exists
|
||||||
changed_when: false
|
changed_when: false
|
||||||
listen: "notification_restart_opencloud"
|
listen: "notification_restart_opencloud"
|
||||||
ignore_errors: true # noqa: ignore-errors
|
ignore_errors: true # noqa: ignore-errors
|
||||||
|
|||||||
@@ -12,15 +12,13 @@
|
|||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Check data directory empty
|
- name: Check data directory empty
|
||||||
ansible.builtin.find:
|
ansible.builtin.stat:
|
||||||
paths: "{{ node['home_path'] }}/data/containers/opencloud/"
|
path: "{{ node['home_path'] }}/data/containers/opencloud/.init"
|
||||||
hidden: true
|
|
||||||
file_type: "any"
|
|
||||||
become: true
|
become: true
|
||||||
register: "is_data_dir_empty"
|
register: "is_opencloud_init"
|
||||||
|
|
||||||
- name: Initialize opencloud
|
- name: Initialize opencloud
|
||||||
when: is_data_dir_empty.matched == 0
|
when: not is_opencloud_init.stat.exists
|
||||||
block:
|
block:
|
||||||
- name: Execute init command (Including pulling image)
|
- name: Execute init command (Including pulling image)
|
||||||
containers.podman.podman_container:
|
containers.podman.podman_container:
|
||||||
@@ -39,9 +37,13 @@
|
|||||||
- "{{ node['home_path'] }}/data/containers/opencloud:/var/lib/opencloud:rw"
|
- "{{ node['home_path'] }}/data/containers/opencloud:/var/lib/opencloud:rw"
|
||||||
no_log: true
|
no_log: true
|
||||||
|
|
||||||
- name: Set is_opencloud_init_run
|
- name: Create .init file
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.file:
|
||||||
is_opencloud_init_run: true
|
path: "{{ node['home_path'] }}/data/containers/opencloud/.init"
|
||||||
|
state: "touch"
|
||||||
|
mode: "0644"
|
||||||
|
owner: "{{ ansible_user }}"
|
||||||
|
group: "svadmins"
|
||||||
|
|
||||||
- name: Deploy configuration files
|
- name: Deploy configuration files
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
|
|||||||
Reference in New Issue
Block a user