File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change 4
4
become : true
5
5
become_method : ansible.builtin.sudo
6
6
tasks :
7
- - name : Copy /etc/resolv.conf to /tmp
7
+ - name : >-
8
+ Grab the current owner, group, and mode for the existing
9
+ /etc/resolv.conf
10
+ ansible.builtin.stat:
11
+ follow: true
12
+ path: /etc/resolv.conf
13
+ register: resolv_conf
14
+ - name : Copy /etc/resolv.conf to /tmp, preserving owner, group, and mode
8
15
ansible.builtin.copy :
9
16
dest : /tmp/resolv.conf
10
- group : root
11
- mode : u=rw,g=r,o=r
12
- owner : root
17
+ group : " {{ resolv_conf.stat.gid }} "
18
+ mode : " {{ resolv_conf.stat.mode }} "
19
+ owner : " {{ resolv_conf.stat.uid }} "
13
20
remote_src : true
14
21
src : /etc/resolv.conf
15
22
- name : Unmount /etc/resolv.conf
16
23
ansible.posix.mount :
17
24
path : /etc/resolv.conf
18
25
state : unmounted
19
- - name : Copy /tmp/resolv.conf to /etc
26
+ - name : Copy /tmp/resolv.conf to /etc, preserving owner, group, and mode
20
27
ansible.builtin.copy :
21
28
dest : /etc/resolv.conf
22
- group : root
23
- mode : u=rw,g=r,o=r
24
- owner : root
29
+ group : " {{ resolv_conf.stat.gid }} "
30
+ mode : " {{ resolv_conf.stat.mode }} "
31
+ owner : " {{ resolv_conf.stat.uid }} "
25
32
remote_src : true
26
33
src : /tmp/resolv.conf
You can’t perform that action at this time.
0 commit comments