SaltStack之state.sls
环境:
OS: CentOS6.5 x64
Master:
salt-master.example.com
Minion:
salt-minion1.example.com
salt-minion2.example.com
参考文档:
1.安装vim并分发vimrc
mkdir -p /srv/salt/edit
cat >/srv/salt/edit/vimrc <<HERE
set nu
set hlsearch
set flash
set backspace=2
set autoindent
set smartindent
set ruler
set showmode
set showmatch
set history=400
set magic
HERE
cat >/srv/salt/vim.sls <<HERE
vim:
/etc/vimrc:
HERE
salt '*' state.sls vim
2.分发文件(/etc/issue)
mkdir -p /srv/salt/etc
cp -a /etc/issue
/srv/salt/etc
cat >/srv/salt/issue.sls
<<HERE
/etc/issue:
HERE
salt '*' state.sls
issue
salt '*' cp.get_file
salt://etc/issue /etc/issue gzip=5
makedirs=True
3.分发目录(代码发布)
mkdir -p /srv/salt/code
echo 'Test' >/srv/salt/code/index.html
cat >/srv/salt/www.sls
<<HERE
code_deploy:
HERE
salt '*' cp.get_dir
salt://html /var/www gzip=5 makedirs=True