Skip to content

Commit f32af45

Browse files
tobiashusteNormo
andcommitted
Improve when condition
Co-authored-by: Norman Ziegner <[email protected]>
1 parent 78652f5 commit f32af45

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

roles/ssh_keys/tasks/main.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
name: "{{ ssh_user.name }}"
1010
state: "present"
1111
when:
12-
- "ssh_user.name is defined"
13-
- "ssh_user.name | length > 0"
12+
- "ssh_user.name | default('') | length > 0"
1413
- "ssh_user.create_user_account | default(false) | bool"
1514
loop: "{{ ssh_user_list }}"
1615
loop_control:
@@ -22,8 +21,7 @@
2221
key: "{{ ssh_user.authorized_keys | default([]) | join('\n') }}"
2322
exclusive: "{{ ssh_authorized_keys_exclusive }}"
2423
when:
25-
- "ssh_user.name is defined"
26-
- "ssh_user.name | length > 0"
24+
- "ssh_user.name | default('') | length > 0"
2725
loop: "{{ ssh_user_list }}"
2826
loop_control:
2927
loop_var: "ssh_user"

0 commit comments

Comments
 (0)