-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix directory not found in check mode
Merge branch 'weekendesk-fix-ansible-check-mode'
- Loading branch information
Showing
3 changed files
with
73 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
|
||
- name: "Adding user '{{ item.username }}' to the system" | ||
user: | ||
name: "{{ item.username }}" | ||
uid: "{{ item.uid | default(omit) }}" | ||
home: "{{ item.home | default(users_home ~ '/' ~ item.username ) }}" | ||
comment: "{{ item.name | default(omit) }}" | ||
system: "{{ item.system | default(omit) }}" | ||
generate_ssh_key: "{{ item.ssh_key_generate | default(omit) }}" | ||
group: "{{ | ||
omit if item.group is defined and item.group == item.username | ||
else (item.group if item.group is defined else (users_group if users_group else omit)) | ||
}}" | ||
groups: "{{ item.groups|join(',') if item.groups is defined else users_groups|join(',') }}" | ||
append: "{{ item.append | default(omit) }}" | ||
password: "{{ item.password | default(omit) }}" | ||
ssh_key_file: ".ssh/id_{{ item.ssh_key_type | default(users_ssh_key_type) }}" | ||
ssh_key_passphrase: "{{ item.ssh_key_password | default(omit) }}" | ||
ssh_key_bits: "{{ item.ssh_key_bits | default(users_ssh_key_bits) }}" | ||
createhome: "{{ item.home_create | default(omit) }}" | ||
shell: "{{ item.shell | default(omit) }}" | ||
update_password: "{{ item.update_password | default(omit) }}" | ||
|
||
- name: Configuring user's home | ||
import_tasks: manage_user_home.yml | ||
when: item.home_create is not defined or item.home_create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
|
||
- name: Setting user's home permission | ||
file: | ||
dest: "{{ item.home | default(users_home ~ '/' ~ item.username) }}" | ||
owner: "{{ item.username }}" | ||
group: "{{ item.group if item.group is defined else (users_group if users_group else item.username) }}" | ||
mode: "{{ item.home_mode if item.home_mode is defined else users_home_mode }}" | ||
when: not ansible_check_mode | ||
|
||
- name: Adding user's .ssh directory | ||
file: | ||
path: "{{ item.home | default(users_home ~ '/' ~ item.username) }}/.ssh" | ||
owner: "{{ item.username }}" | ||
group: "{{ item.group if item.group is defined else (users_group if users_group else item.username) }}" | ||
state: directory | ||
mode: '0700' | ||
|
||
- name: Adding user's private key | ||
template: | ||
src: home/user/ssh/private-key.j2 | ||
dest: "{{ item.home | default(users_home ~ '/' ~ item.username) }}/.ssh/id_{{ item.ssh_key_type | default('rsa') }}" | ||
owner: "{{ item.username }}" | ||
group: "{{ item.group if item.group is defined else (users_group if users_group else item.username) }}" | ||
mode: '0600' | ||
when: item.ssh_key is defined | ||
|
||
- name: Adding user's authorized keys | ||
authorized_key: | ||
key: "{{ item.authorized_keys | default([]) | join('\n') }}" | ||
user: "{{ item.username }}" | ||
exclusive: "{{ item.authorized_keys_exclusive | default(users_authorized_keys_exclusive) }}" | ||
when: not ansible_check_mode | ||
|
||
- name: Adding user's home files | ||
copy: | ||
src: "{{ home_file }}" | ||
dest: "{{ item.home | default(users_home ~ '/' ~ item.username) }}/{{ home_file | basename }}" | ||
owner: "{{ item.username }}" | ||
group: "{{ item.group if item.group is defined else (users_group if users_group else item.username) }}" | ||
with_items: "{{ item.home_files }}" | ||
loop_control: | ||
loop_var: home_file | ||
when: item.home_files is defined |