Score:0

How to Pre-seed Salt Minion's Archives

tr flag

So I am creating a state file to install MatterMost on a minion. So far it looks like this:


mattermost-usergroup:
  user.present:
    - name: mattermost
    - shell: /bin/sh
    - createhome: False
    - usergroup: True
    - system: True
    - require:
      # From postgresql-formula:
      # https://github.com/saltstack-formulas/postgres-formula/blob/master/postgres/server/init.sls#L278
      - service: postgresql-running

mattermost-opt:
  archive.extracted:
    - name: /opt
    - source: https://releases.mattermost.com/{{ pillar['mattermost'].version }}/mattermost-{{ pillar['mattermost'].version }}-linux-amd64.tar.gz
    - source_hash: a194fd3d2bebed8e6b5721261621030e573f4500c54fb251cfd8ff6f32fe714e
    - user: mattermost
    - group: mattermost
    - require:
      - user: mattermost-usergroup

My problem is: Prior to creating this SLS, MatterMost has been installed (exact same version as the one specified in the pillar) by downloading the tarball to an admin's home, then extracting the tarball manually to opt. If I run state.highstate with this, I fear it will redownload the tarball, then because the tarball is 'new' (from the Minion's POV), it will be extracted over the existing installation in /opt

How do I "pre-seed" the Minion's "archive cache" so the Minion can see the file is already downloaded, and will not (re)download+overwrite?

Score:0
cn flag

I just tested (bit modified sls, no pillar so hard coded the version for testing in a throw away nspawn container). I downloaded first the tarball using the /opt destination, and then copied the downloaded directory to /mnt.

mattermost-opt:
  archive.extracted:
    - name: /mnt
    - source: https://releases.mattermost.com/desktop/5.0.4/mattermost-desktop-5.0.4-linux-x64.tar.gz
    - source_hash: sha256=cbd2981ce282eecfea1167c500d900cdd31bd041b0861025743b7d58e4cb9229
    - user: mattermost
    - group: mattermost
    - require:
      - mattermost-usergroup

It's working properly. No additional downloads. In fact, the archive state is slim enough to not redownload the archive if it's cached in /var/cache/salt/minion/extrn_files/{{saltenv}}, it will verify the hash and unpack stuff in the destination directory in case a file is missing.

So here it does nothing, everything is in place:

    # salt-call state.apply mattermost 
    local:
    ----------
              ID: mattermost-usergroup
        Function: user.present
            Name: mattermost
          Result: True
         Comment: User mattermost is present and up to date
         Started: 21:09:26.078971
        Duration: 12.33 ms
         Changes:   
    ----------
              ID: mattermost-opt
        Function: archive.extracted
            Name: /mnt
          Result: True
         Comment: All files in archive are already present
         Started: 21:09:26.091829
        Duration: 1030.216 ms
         Changes:   
    
    Summary for local
    ------------
    Succeeded: 2
    Failed:    0
    ------------
    Total states run:     2
    Total run time:   1.043 s

Let's remove one file from the untarred archive and retry it:

# rm /mnt/mattermost-desktop-5.0.4-linux-x64/vk_swiftshader_icd.json                 # salt-call state.apply mattermost 

  local:
----------
          ID: mattermost-usergroup
    Function: user.present
        Name: mattermost
      Result: True
     Comment: User mattermost is present and up to date
     Started: 21:09:45.753688
    Duration: 11.511 ms
     Changes:   
----------
          ID: mattermost-opt
    Function: archive.extracted
        Name: /mnt
      Result: True
     Comment: https://releases.mattermost.com/desktop/5.0.4/mattermost-desktop-5.0.4-linux-x64.tar.gz extracted to /mnt/, due to absence of one or more files/dirs. Output was trimmed to False number of lines
     Started: 21:09:45.765712
    Duration: 2165.587 ms
     Changes:   
              ----------
              extracted_files:
              {{ trimmed output }}
                  - mattermost-desktop-5.0.4-linux-x64/vk_swiftshader_icd.json
              updated ownership:
                  True

Summary for local
------------
Succeeded: 2 (changed=1)
Failed:    0
------------
Total states run:     2
Total run time:   2.177 s
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.