zoukankan      html  css  js  c++  java
  • Saltstack module highstate_doc 详解

    highstate_doc.read_file

    output the contents of a file:
    
    this is a workaround if the cp.push module does not work.
    https://github.com/saltstack/salt/issues/37133
    
    help the master output the contents of a document
    that might be saved on the minions filesystem.
    
        #!/bin/python
        import os
        import salt.client
        s = salt.client.LocalClient()
        o = s.cmd('*', 'highstate_doc.read_file', ['/root/README.md'])
        for m in o:
            d = o.get(m)
            if d and not d.endswith('is not available.'):
                # mkdir m
                #directory = os.path.dirname(file_path)
                if not os.path.exists(m):
                    os.makedirs(m)
                with open(m + '/README.md','wb') as fin:
                    fin.write(d)
                print('ADDED: ' + m + '/README.md')
    

    highstate_doc.markdown_default_jinja_template

    Return text for a markdown jinja template that included a header
    
    This function can be used from the `highstate_doc.render` modules `jinja_template_function` option.
    

    highstate_doc.proccess_lowstates

    return proccessed lowstate data that was not blacklisted
    
    render_module_function is used to provide your own.
    defaults to from_lowstate
    

    highstate_doc.render

    Render highstate to a text format (default Markdown)
    
    if `jinja_template_text` is not set, `jinja_template_function` is used.
    
    jinja_template_text: jinja text that the render uses to create the document.
    jinja_template_function: a salt module call that returns template text.
        options:
            highstate_doc.markdown_basic_jinja_template
            highstate_doc.markdown_default_jinja_template
            highstate_doc.markdown_full_jinja_template
    

    highstate_doc.markdown_basic_jinja_template

    Return text for a simple markdown jinja template
    
    This function can be used from the `highstate_doc.render` modules `jinja_template_function` option.
    

    highstate_doc.markdown_full_jinja_template

    Return text for an advanced markdown jinja template
    
    This function can be used from the `highstate_doc.render` modules `jinja_template_function` option.
    

    highstate_doc.proccesser_markdown

    Takes low state data and returns a dict of proccessed data
    that is by default used in a jinja template when rendering a markdown highstate_doc.
    
    This `lowstate_item_markdown` given a lowstate item, returns a dict like:
    
        vars:       # the raw lowstate_item that was proccessed
        id:         # the 'id' of the state.
        id_full:    # combo of the state type and id "state: id"
        state:      # name of the salt state module
        function:   # name of the state function
        name:       # value of 'name:' passed to the salt state module
        state_function:    # the state name and function name
        markdown:          # text data to describe a state
            requisites:    # requisite like [watch_in, require_in]
            details:       # state name, parameters and other details like file contents
  • 相关阅读:
    python笔记---@classmethod @staticmethod
    python笔记--socket编程
    python笔记--异常处理
    WebStorm 配置
    ECS node 环境搭建
    spm + host
    Untuntu的apt 终端命令
    Ubuntu 添加至启动栏
    Ubuntu设置镜像源
    Ubuntu 设置中文语言环境
  • 原文地址:https://www.cnblogs.com/randomlee/p/Saltstack_module_highstate_doc.html
Copyright © 2011-2022 走看看