saltstack的探索-使用pillar来改进vim的部署
saltstack的探索-使用pillar来改进vim的部署
[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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。