forked from drybjed/ansible-users
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotfiles.yml
58 lines (55 loc) · 3.05 KB
/
dotfiles.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
- name: Get users dotfiles from git repository
become_user: '{{ item.name }}'
git:
repo: '{{ item.dotfiles_repo | d(users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].repo) }}'
dest: '{{ item.dotfiles_dest | d(users__dotfiles_dest) }}'
update: '{{ (item.dotfiles_update | d(users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].update | d(users__dotfiles_update))) | bool }}'
with_flattened:
- '{{ users__root_accounts }}'
- '{{ users__default_accounts }}'
- '{{ users__admin_accounts }}'
- '{{ users__accounts }}'
- '{{ users__group_accounts }}'
- '{{ users__host_accounts }}'
when: (item.name|d() and item.state|d('present') != 'absent' and item.createhome|d(True) and
item.dotfiles_enabled | d(users__dotfiles_enabled) | bool)
no_log: '{{ users__no_log | bool }}'
- name: Configure users dotfiles
become_user: '{{ item.name }}'
command: '{{ item.dotfiles_command | d(users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].command) }}'
args:
chdir: '{{ item.dotfiles_dest | d(users__dotfiles_dest) }}'
creates: '{{ item.dotfiles_creates
if item.dotfiles_creates|d()
else (users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].creates
if users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].creates|d()
else omit) }}'
register: users__register_dotfiles_command
changed_when: users__register_dotfiles_command.stdout != '' and
not users__register_dotfiles_command.stdout.startswith('skipped, since ')
with_flattened:
- '{{ users__root_accounts }}'
- '{{ users__default_accounts }}'
- '{{ users__admin_accounts }}'
- '{{ users__accounts }}'
- '{{ users__group_accounts }}'
- '{{ users__host_accounts }}'
when: (item.name|d() and item.state|d('present') != 'absent' and item.createhome|d(True) and
item.dotfiles_enabled | d(users__dotfiles_enabled) | bool and
item.dotfiles_command | d(users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].command|d()))
no_log: '{{ users__no_log | bool }}'
- name: Configure users shell if specified
user:
name: '{{ item.name }}'
shell: '{{ item.shell | d(users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].shell if (item.dotfiles_enabled | d(users__dotfiles_enabled) | bool and users__dotfiles_combined_map[item.dotfiles_name | d(users__dotfiles_name)].shell|d()) else (users__default_shell if users__default_shell else omit)) }}'
with_flattened:
- '{{ users__root_accounts }}'
- '{{ users__default_accounts }}'
- '{{ users__admin_accounts }}'
- '{{ users__accounts }}'
- '{{ users__group_accounts }}'
- '{{ users__host_accounts }}'
when: (item.name|d() and item.state|d('present') != 'absent' and item.createhome|d(True) and
(item.dotfiles_enabled | d(users__dotfiles_enabled) | bool or item.shell|d() or users__default_shell))
no_log: '{{ users__no_log | bool }}'