標籤:saltstack pillar
saltstack的探索-使用pillar來改進vim的部署
[[email protected] srv]# pwd/srv[[email protected] srv]# lspillar salt[[email protected] srv]# cat pillar/data.sls pkg/ top.sls users/ [[email protected] 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 %}[[email protected] srv]# cat pillar/top.sls base: ‘*‘: - data - users - pkg[[email protected] 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 執行:[[email protected] srv]# salt ‘svr205-2‘ state.sls edit.vimsvr205-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: 2Failed: 0------------Total states run: 2
saltstack的探索-使用pillar來改進vim的部署