美文网首页
SaltStack 2019.2.0 版本 test=True

SaltStack 2019.2.0 版本 test=True

作者: awker | 来源:发表于2019-10-07 23:47 被阅读0次

saltstack 升级到 2019.2.0 版本后,test=True 时,没有显示 diff 信息了

# salt --version
salt 2019.2.0 (Fluorine)

# salt -L 'sc01020' state.apply saltenv='prod' config.openresty.nginx-conf.nginx-config test=True
sc01020:
----------
          ID: openresty-config
    Function: file.managed
        Name: /usr/local/openresty/nginx/conf/nginx.conf
      Result: None
     Comment: The file /usr/local/openresty/nginx/conf/nginx.conf is set to be changed
     Started: 10:54:28.522078
    Duration: 30.291 ms
     Changes:   
----------
          ID: blockip-config
    Function: file.absent
        Name: /usr/local/openresty/nginx/conf/conf.d/blockip.conf
      Result: None
     Comment: File /usr/local/openresty/nginx/conf/conf.d/blockip.conf is set for removal
     Started: 10:54:28.552552
    Duration: 0.36 ms
     Changes:   
----------
          ID: openresty-service
    Function: service.running
        Name: openresty
      Result: True
     Comment: The service openresty is already running
     Started: 10:54:29.016679
    Duration: 41.258 ms
     Changes:   

Summary for sc01020
------------
Succeeded: 3 (unchanged=2)
Failed:    0
------------
Total states run:     3
Total run time:  71.909 ms

原因是 saltstack 2019.2.0 版本去掉了这个功能,详见 https://github.com/saltstack/salt/issues/51932

解决办法:
修改 saltstack 源码,加上这个功能(在246行)

# vim /usr/lib/python2.7/site-packages/salt/output/highstate.py
            else:
                schanged, ctext = _format_changes(ret['changes'])
                # Edited 2019-05-09, to fix regression
                # See: https://github.com/saltstack/salt/issues/51932#issuecomment-474213938
                if not ctext and 'pchanges' in ret:
                    _, ctext = _format_changes(ret['pchanges'])
                nchanges += 1 if schanged else 0

问题解决

# salt -L 'sc01020' state.apply saltenv='prod' config.openresty.nginx-conf.nginx-config test=True
sc01020:
----------
          ID: openresty-config
    Function: file.managed
        Name: /usr/local/openresty/nginx/conf/nginx.conf
      Result: None
     Comment: The file /usr/local/openresty/nginx/conf/nginx.conf is set to be changed
     Started: 10:59:47.567633
    Duration: 29.248 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -40,10 +40,14 @@
                   
                       gzip  on;
                   
                  +    gzip_comp_level 4;
                  +
                       client_max_body_size 20m;
                   
                       vhost_traffic_status_zone;
                   
                  +    limit_req_zone $binary_remote_addr zone=sflimit:10m rate=1000r/s;
                  +    
                       server_tokens off;
                   
                       include /usr/local/openresty/nginx/conf/conf.d/*.conf;
----------
          ID: blockip-config
    Function: file.absent
        Name: /usr/local/openresty/nginx/conf/conf.d/blockip.conf
      Result: None
     Comment: File /usr/local/openresty/nginx/conf/conf.d/blockip.conf is set for removal
     Started: 10:59:47.597076
    Duration: 0.356 ms
     Changes:   
              ----------
              removed:
                  /usr/local/openresty/nginx/conf/conf.d/blockip.conf
----------
          ID: openresty-service
    Function: service.running
        Name: openresty
      Result: True
     Comment: The service openresty is already running
     Started: 10:59:48.050654
    Duration: 38.768 ms
     Changes:   

Summary for sc01020
------------
Succeeded: 3 (unchanged=2)
Failed:    0
------------
Total states run:     3
Total run time:  68.372 ms

相关文章

网友评论

      本文标题:SaltStack 2019.2.0 版本 test=True

      本文链接:https://www.haomeiwen.com/subject/yeevpctx.html