saltstack的探索-使用pillar来改进vim的部署
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
|
[root@svr200-21 srv]
# pwd
/srv
[root@svr200-21 srv]
# ls
pillar salt
[root@svr200-21 srv]
# cat pillar/
data.sls pkg/
top
.sls
users
/
[root@svr200-21 srv]
# cat pillar/pkg/init.sls
pkgs:
{%
if
grains[
'os_family'
] ==
'RedHat'
%}
vim: vim-enhanced
{%
elif
grains[
'os_family'
] ==
'Debian'
%}
vim: vim
{%
elif
grains[
'os'
] ==
'Arch'
%}
vim: vim
{% endif %}
[root@svr200-21 srv]
# cat pillar/top.sls
base:
'*'
:
- data
-
users
- pkg
[root@svr200-21 srv]
# cat salt/edit/vim.sls
vim:
pkg:
- installed
- name: {{ pillar[
'pkgs'
][
'vim'
] }}
/root/
.vimrc:
file
.managed:
-
source
: salt:
//edit/conf/vimrc
- mode: 644
- uesr: root
- group: root
- require:
- pkg: vim
执行:
[root@svr200-21 srv]
# salt 'svr205-2' state.sls edit.vim
svr205-2:
----------
ID: vim
Function: pkg.installed
Name: vim-enhanced
Result: True
Comment: Package vim-enhanced is already installed.
Started: 18:05:24.707048
Duration: 1808.3 ms
Changes:
----------
ID:
/root/
.vimrc
Function:
file
.managed
Result: True
Comment: File
/root/
.vimrc is
in
the correct state
Started: 18:05:26.515743
Duration: 153.787 ms
Changes:
Summary
------------
Succeeded: 2
Failed: 0
------------
Total states run: 2
|
本文转自 pcnk 51CTO博客,原文链接:http://blog.51cto.com/nosmoking/1619452,如需转载请自行联系原作者