Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions ansible/roles/dashmate/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@
register: dashmate_group_check
failed_when: false
changed_when: false
when: not (skip_dashmate_image_update | default(false))

- name: Check if dashmate user exists
ansible.builtin.command: "id {{ dashmate_user }}"
register: dashmate_user_check
failed_when: false
changed_when: false
when: not (skip_dashmate_image_update | default(false))

- name: Set user/group existence facts
ansible.builtin.set_fact:
dashmate_group_exists: "{{ (dashmate_group_check is defined and dashmate_group_check.rc is defined and dashmate_group_check.rc == 0) | default(true if skip_dashmate_image_update | default(false) else false) }}"

Check failure on line 70 in ansible/roles/dashmate/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Test package

yaml[line-length]

Line too long (214 > 160 characters)
dashmate_user_exists: "{{ (dashmate_user_check is defined and dashmate_user_check.rc is defined and dashmate_user_check.rc == 0) | default(true if skip_dashmate_image_update | default(false) else false) }}"

Check failure on line 71 in ansible/roles/dashmate/tasks/main.yml

View workflow job for this annotation

GitHub Actions / Test package

yaml[line-length]

Line too long (210 > 160 characters)

- name: Debug user/group check results
ansible.builtin.debug:
Expand All @@ -71,13 +78,16 @@
Group check msg: {{ dashmate_group_check.msg | default('no msg') }}
User check msg: {{ dashmate_user_check.msg | default('no msg') }}
skip_dashmate_image_update: {{ skip_dashmate_image_update | default('undefined') }}
dashmate_group_exists: {{ dashmate_group_exists }}
dashmate_user_exists: {{ dashmate_user_exists }}
when: not (skip_dashmate_image_update | default(false))

- name: Create dashmate group
ansible.builtin.group:
name: '{{ dashmate_group }}'
when:
- not (skip_dashmate_image_update | default(false))
- dashmate_group_check.rc != 0
- not dashmate_group_exists

- name: Create dashmate user
ansible.builtin.user:
Expand All @@ -90,7 +100,7 @@
umask: '0002'
when:
- not (skip_dashmate_image_update | default(false))
- dashmate_user_check.rc != 0
- not dashmate_user_exists

- name: Add dashmate user to docker group
ansible.builtin.user:
Expand All @@ -99,7 +109,7 @@
append: true
when:
- not (skip_dashmate_image_update | default(false))
- dashmate_user_check.rc != 0
- not dashmate_user_exists

# ============================================================================
# EARLY PERMISSION FIXES - Ensure all dashmate directories have correct ownership
Expand All @@ -120,13 +130,13 @@
- '{{ dashmate_logs_dir }}'
when:
- not (skip_dashmate_image_update | default(false))
- dashmate_user_check.rc == 0
- dashmate_user_exists

- name: Fix ownership of any existing files in dashmate directories
ansible.builtin.command: chown -R {{ dashmate_user }}:{{ dashmate_group }} {{ dashmate_home }}
when:
- not (skip_dashmate_image_update | default(false))
- dashmate_user_check.rc == 0
- dashmate_user_exists
changed_when: false

# ============================================================================
Expand Down Expand Up @@ -185,7 +195,7 @@
when:
- dash_conf_changed is defined
- dash_conf_changed is changed
- dashmate_user_check.rc == 0
- dashmate_user_exists

# ============================================================================
# PHASE 4: Logging setup (skip in fast mode)
Expand All @@ -201,7 +211,7 @@
when:
- not (skip_dashmate_image_update | default(false))
- not (logrotate_config_stat.stat.exists | default(false)) or force_logs_config | default(false)
- dashmate_user_check.rc == 0 # Only configure logs if user exists
- dashmate_user_exists # Only configure logs if user exists

# ============================================================================
# PHASE 5: Dashmate installation and configuration (always run)
Expand Down Expand Up @@ -302,7 +312,7 @@
mode: "0644"
register: template_result_fast
when:
- dashmate_user_check.rc == 0
- dashmate_user_exists
- skip_dashmate_image_update | default(false)

- name: Generate new config content for comparison (regular mode)
Expand Down Expand Up @@ -348,7 +358,7 @@
register: template_result_regular
when:
- not (skip_dashmate_image_update | default(false))
- dashmate_user_check.rc == 0
- dashmate_user_exists
- config_needs_update

- name: Clean up temp file (regular mode)
Expand Down
Loading