Search code examples
salt-project

How can I tell a Salt Master to download a file to make it available to minions that don't have access to the internet?


I have some minions that don't have access to the internet, but I need to get a package installed from a website. So I need to have the master download the file and then have the minion pull from the master. Ideally the master would download any new versions of the file for the minions to consume.


Solution

  • Depending on what you want to download, the "easiest" way for me to do it would be to do some kind of orchestration:

    • First you target the minion running on your master (I'm assuming you have one) with a recipe to download the internet file and to place it somewhere where minion will have access to it ( http server? salt file sharing? Network drive whatever)

    • Then a recipe for all minion to retrieve the file and use it

    the orchestration recipe would have to be located under /srv/salt/orch/file_download.sls for instance

    Master Download file:
      salt.state:
        - tgt: master-minion
        - failhard: True
        - sls:
          - recipe_to_download_file
    
    Minion use file:
      salt.state:
        - tgt: * # or anything suitable to taget your minions
        - failhard: True
        - sls:
          - install_file
    

    and launch it with salt-run state.orchestrate orch.file_download