自动化部署配置文件
/etc/resolv.conf
对所有/etc/resolv.conf进行部署,指定nameserver和search
angel01是DNS SERVER,angel02是客户端,我们做一个让angel01的resolv.conf中nameserver为127.0.0.1,其他nameserver ip是192.168.0.210
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
| #首先设置pillar需要区分的数据
vim /mnt/config/salt/pillar/top.sls
base:
'*':
- base.resolv
mkdir /mnt/config/salt/pillar/base/
vim /mnt/config/salt/pillar/base/resolv.sls
nameserver: ['192.168.0.210','202.96.209.133']
vim /mnt/config/salt/top.sls
base:
'*':
- base.resolv
mkdir -p /mnt/config/salt/base/
vim /mnt/config/salt/base/resolv.sls
/etc/resolv.conf: #文件路径
file.managed: #sls函数,修改添加文件
- source: salt://base/jinja/resolv.conf.jinja #jinja的文件位置
- user: root #用户属性
- group: root #用户组属性
- mode: 644 #用户权限
- backup: minion #minion客户端本地备份/var/cach/salt/
- template: jinja #使用jinja模板
vim /mnt/config/salt/base/jinja/resolv.conf.jinja
search i.fdmdns.com
nameserver
nameserver
#使用命令测试
[root@angel01 salt]# salt '*' pillar.item nameserver
angel01.i.fdmdns.com:
----------
nameserver:
- 127.0.0.1
- 202.96.209.133
angel02.i.fdmdns.com:
----------
nameserver:
- 192.168.0.210
- 202.96.209.133
#pillar已经有我们属性了,然后同步写入文件内容
[root@angel01 salt]# salt '*' state.highstate -v
Executing job with jid 20141010150603492444
-------------------------------------------
angel01.i.fdmdns.com:
----------
ID: /etc/resolv.conf
Function: file.managed
Result: True
Comment: File /etc/resolv.conf updated
Changes:
----------
diff:
New file
mode:
0644
Summary
------------
Succeeded: 1
Failed: 0
------------
Total: 1
angel02.i.fdmdns.com:
----------
ID: /etc/resolv.conf
Function: file.managed
Result: True
Comment: File /etc/resolv.conf updated
Changes:
----------
diff:
New file
mode:
0644
Summary
------------
Succeeded: 1
Failed: 0
------------
Total: 1
#查看文件,如果符合则完成
|
未完待续。。。。。