cdM*_*nix 8 hash md5 web-services salt-stack
salt.states.file.managed需要source_hash作为参数来验证下载的文件.这阻止我使用file.managed我无法控制的在线服务器上的文件.该文件也会定期更改.我的配置看起来像这样.
download_stuff:
file.managed:
- name: localfile.tar.gz
- source: http://someserver.net/onlinefile.tar.gz
- source_hash: ???
Run Code Online (Sandbox Code Playgroud)
我不希望使用cmd.run具有Curl或wget因为这将始终下载该文件,甚至当它已经在本地机器上.
我想知道下面的选项之一是否可能/存在:
http://md5service.net?url={url-to-file}.source_hash某种方式遗漏?如果您无法控制其他服务器,请确保您可以信任它下载其内容.不使用哈希将阻止您检测部分或损坏的下载.也无法使用远程服务器上已更改的文件.
不过你可以使用这样的状态来规避哈希码.creates一旦下载文件,该部分将阻止第二次下载:
bootstrap:
cmd.run:
- name: curl -L https://bootstrap.saltstack.com -o /etc/salt/cloud.deploy.d/bootstrap-salt.sh
- creates: /etc/salt/cloud.deploy.d/bootstrap-salt.sh
Run Code Online (Sandbox Code Playgroud)