zoukankan      html  css  js  c++  java
  • SaltStack 配置SLS过程

    file.managed模块的使用示例:

    1.在/etc/salt/master中编辑

    file_roots:
      base:
        - /srv/salt
      dev:
        - /srv/salt/dev
      test:
        - /srv/salt/test
      prod:
        - /srv/salt/prod

    2.在/srv/salt下面新建目录mkdir dev test prod init

    3.在init目录下新建需要管理的文件dns.sls

    /etc/resolv.conf:
      file.managed:
        - source: salt://init/files/resolv.conf
        - user: root
        - group: root
        - mode: 644

    4.在init目录下新建files目录,拷贝/etc/resolv.conf到/srv/salt/init/files下面,并且修改resolv.conf文件为

    nameserver 144.144.144.144
    nameserver 8.8.8.8

    5.在/srv/salt下面新建top.sls文件,并且重启master服务/etc/init.d/salt-master restart

    base:
      '*':
        - init.dns

    6.执行salt '*' state.highstate

    ndsfront12:
    ----------
    ID: /etc/resolv.conf
    Function: file.managed
    Result: True
    Comment: File /etc/resolv.conf updated
    Started: 17:35:39.931232
    Duration: 31.683 ms
    Changes:
    ----------
    diff:
    ---
    +++
    @@ -1,1 +1,2 @@
    -search localdomain
    +nameserver 144.144.144.144
    +nameserver 8.8.8.8

    Summary for ndsfront12
    ------------
    Succeeded: 1 (changed=1)
    Failed: 0
    ------------
    Total states run: 1
    ndsfront21:
    ----------
    ID: /etc/resolv.conf
    Function: file.managed
    Result: True
    Comment: File /etc/resolv.conf updated
    Started: 17:58:34.277503
    Duration: 108.209 ms
    Changes:
    ----------
    diff:
    ---
    +++
    @@ -1,0 +1,2 @@
    +nameserver 144.144.144.144
    +nameserver 8.8.8.8

    Summary for ndsfront21
    ------------
    Succeeded: 1 (changed=1)
    Failed: 0
    ------------
    Total states run: 1

  • 相关阅读:
    使用Skaffold一键将项目发布到Kubernetes
    线性代数回头看——线性方程组
    Python 函数 初学者笔记
    Python 用户输入&while循环 初学者笔记
    Python If&字典 初学者笔记
    Python 变量&列表 初学者笔记
    SQL 常见优化指南
    垃圾回收机制
    MySQL 前缀索引
    MySQL 常用优化
  • 原文地址:https://www.cnblogs.com/python-study/p/5482649.html
Copyright © 2011-2022 走看看