細細.魚 发表于 2018-8-1 10:15:43

saltstack学习记录

  安装
  pip 安装 注意依赖到zeromq3
  minion过一段时间去请求master
  salt-api可以访问salt去远程执行
  ruby
  puppet   DSL配置   erb文件模块加载模板支持最差
  chef   定义直接是ruby代码   erb模板系统   原生支持
  python
  saltstack   yaml配置文件    python程序模板   模板支持很好
  python写模块
  ipc 进程间通信
  都使用key认证    安全
  salt-key-L
  salt-key -a centos
  master不需要在root
  minion需要在root
  autosign_file: /etc/salt/autosign.conf自动签名    自动接收   大批量部署
  state_top: top.sls   最基础的配置文件   site.pp
  jinja   模板系统   控制一个文件怎么输出
  环境的区分   dev       开发      还不统一开发自己做
  product    生产
  dev    stage   pre-product(灰度发布)    product
  QA测试
  合并分支    merge
  base环境读top.sls
  fileserver_backend:
  - git
  - roots
  salt命令指定哪个机器去运行
  test模块   ping命令
  salt '*'cmd.run"/etc/init.d/httpd restart"
  *定位到机器   glob相关
  cat /etc/salt/minion_id
  正则表达式    邮箱的正则匹配
  一、target模式
  salt -E 'test0.pythoner.cn'   cmd.run"/etc/init.d/httpd restart"
  Grains   取机器信息
  salt 'test01.pythoner.cn' grains.itemsip_interfaces:eth1
  salt -G 'os:CentOS'test.ping
  salt -S 192.168.40.20test.ping
  联合方式   Compound matchers
  salt -C 'G@roles:web' or 'G@city:beijing' cmd.run 'echo fuck gfw'
  salt -C 'G@roles:web' and 'G@city:beijing' cmd.run 'echo fuck gfw'
  salt -C 'G@roles:web' or 'S@city:beijing' cmd.run 'echo fuck gfw'
  master
  nodegroups:
  group1:'L@test01.pythoner.cn'
  group2:'L@test01.pythoner.cn' or ''
  salt -N group1 test.ping
  top.sls
  base:
  - match:compound
  'group1'
  - match:nodegroup
  - apache
  修改node配置,master必须重启
  notopfile报错
  在top.sls不要用nodegroup命令模式
  二、安装软件,配置文件
  httpd:
  service:
  - running
  - enable: true

  ->  - watch:
  - file: /etc/httpd/conf/httpd.conf
  - pkg: mod_python
  pkg:
  - installed
  /etc/httpd/conf/httpd.conf:
  file:
  - managed
  - source: salt://apache/files/httpd.conf
  - user:root
  - group:root
  - chmod 644
  recurse同步目录
  salt '*' state.highstate
  salt.iptables
  top.sls    template直接使用jinja
  ifelse
  第一要素   filepkg
  配置管理最常用功能
  安装软件   pkg
  copy文件    file.resu
  管理进程   services
  cron
  iptables
  sysconf   swappiness=0/1   oom占用最大内存的进程kill
  network    别名   ip漂移   一块网卡绑多个IP
  repo文件   file文件管理
页: [1]
查看完整版本: saltstack学习记录