zoukankan      html  css  js  c++  java
  • state配置语言实战

    修改配置文件:(base用来放初始化环境、prod用来放生产配置环境)

     [root@super65 ~]# vim /etc/salt/master 

     

    [root@super65 ~]# mkdir -p /srv/salt/{base,prod}
    [root@super65 ~]# mkdir -p /srv/pillar/{base,prod}
    [root@super65 ~]# /etc/init.d/salt-master restart
    Stopping salt-master daemon: [ OK ]
    Starting salt-master daemon: [ OK ]

    初始化:(批量配置dns文件和历史记录加上执行时间)

    编写states文件:

     

    [root@super65 base]# pwd
    /srv/salt/base
    [root@super65 base]# cat top.sls
    base:
      '*':
        - init.env_init
    [root@super65 base]# cat init/env_init.sls
    include:
      - init.dns
      - init.history

    [root@super65 base]# cat init/dns.sls
    /etc/resolve.conf:
      file.managed:
        - source: salt://init/files/resolv.conf
        - user: root
        - group: root
        - mode: 644

    [root@super65 base]# cat init/history.sls
    /etc/profile:
      file.append:
        - text:
        - export HISTTIMEFORMAT="%F %T `whoami` "

    测试执行:

     [root@super65 ~]# salt '*' state.highstate test=True

    正式执行:

     [root@super65 ~]# salt '*' state.highstate 

  • 相关阅读:
    51nod——T1267 4个数和为0
    cf220B莫队
    cf220b
    poj1436水平可见线
    poj2528贴海报,,
    poj3468
    hdu1698
    ural1989 单点更新+字符串hash
    cf Queries on a String
    hdu4605
  • 原文地址:https://www.cnblogs.com/fanxuanhui-linux/p/5878819.html
Copyright © 2011-2022 走看看