Repository navigation
Expand file tree
/
Copy pathvim-basic.yml
More file actions
executable file
·69 lines (62 loc) · 1.7 KB
/
Copy pathvim-basic.yml
File metadata and controls
executable file
·69 lines (62 loc) · 1.7 KB
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
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env ansible-playbook
# Set up basic VIM configuration if user has not customized it already.
# Usage: ansible-playbook ./vim-basic.yml
---
- hosts: all
gather_facts: false
become: true
vars:
homedirs:
- /home/pi
- /root
# users:
# - pi
# - root
tasks:
# - getent:
# database: passwd
# - debug:
# msg: "{{ users
# | zip(users
# | map('extract', ansible_facts.getent_passwd)
# | map(attribute='4')) }}"
# - debug:
# msg: "{{ dict(users
# | zip(users
# | map('extract', ansible_facts.getent_passwd)
# | map(attribute='4')
# )
# ) | dict2items }}"
- name: Check for existing vim config
find:
paths: "{{ homedirs }}"
file_type: any
hidden: true
patterns:
- '.vim'
- '.vimrc'
register: find_results
- name: register directories needing config
set_fact:
target_dirs: "{{ find_results.files
| map(attribute='path')
| map('dirname')
| unique
| symmetric_difference(homedirs) }}"
- name: lookup dir owner
stat:
path: "{{ item }}"
get_attributes: false
get_checksum: false
get_mime: false
loop: "{{ target_dirs }}"
register: dirstats
- name: copy basic .vimrc
copy:
src: vimrc.basic
dest: "{{ item.path }}/.vimrc"
force: false
mode: 0644
owner: "{{ item.pw_name }}"
group: "{{ item.gr_name }}"
loop: "{{ dirstats.results | map(attribute='stat') }}"