0

As part of a salt state file I am installing nghttp2.

So far I have the following code in my .sls

install_nghttp2:
  cmd.run:
    - name: |
        cd /tmp
        wget https://github.com/nghttp2/nghttp2/releases/download/v1.16.0/nghttp2-1.16.0.tar.gz
        tar -xf nghttp2-1.16.0.tar.gz
        cd ./nghttp2-1.16.0
        ./configure
        make
        make install
    - shell: /bin/bash
    - require:
      - pkg: install_nghttp2_deps
    - unless: test -x /tmp/nghttp2-1.16.0

I'm a little wary of the - unless requisite and was wondering if anyone had a better way to check nghttp2 hasn't already been installed? I'd rather do something to check it hasn't been installed rather than just check whether it's been downloaded - unless (pun intended...kinda) anyone has a better suggestion?

grinferno
  • 524
  • 8
  • 23
  • When installed, will the path of `nghttp2-1.16.0` be appended in `$PATH` environment variable (or) any change you adding it yourself? – Inian Feb 22 '17 at 17:08
  • 3
    This is what package managers (`rpm`, `apt`, etc) are for. Build a package for `nghttp2` and install it via the package manager of your choice; then your `unless` test simply checks if the appropriate package is installed. – chepner Feb 22 '17 at 17:08

1 Answers1

0

Since you compile specific version and you do not install it with package manager, I think you are doing it right.

Maybe better option to check if the program is installed would be to use different command in unless requisite.

For example you can use nghttpd --version or with full path, where the binary is stored /usr/sbin/nghttpd --version.

Other good option is to use which nghttpd.

Lirt
  • 407
  • 5
  • 8