Search code examples
salt-project

Saltstack for "configure make install"


I'm getting my feet wet with SaltStack. I've made my first state (a Vim installer with a static configuration) and I'm working on my second one.

Unfortunately, there isn't an Ubuntu package for the application I'd like my state to install. I will have to build the application myself. Is there a "best practice" for doing "configure-make-install" type installations with Salt? Or should I just use cmd?

In particular, if I was doing it by hand, I would do something along the lines of:

wget -c http://example.com/foo-3.4.3.tar.gz
tar xzf foo-3.4.3.tar.gz
cd foo-3.4.3
./configure --prefix=$PREFIX && make && make install

Solution

  • Let's assume foo-3.4.3.tar.gz is checked into GitHub. Here is an approach that you might pursue in your state file:

    git:
      pkg.installed
    
    https://github.com/nomen/foo.git:
      git.latest:
        - rev: master
        - target: /tmp/foo
        - user: nomen
        - require:
          - pkg: git
    
    foo_deployed:
      cmd.run:
        - cwd: /tmp/foo
        - user: nomen
        - name: |
            ./configure --prefix=/usr/local
            make
            make install
        - require:
          - git: https://github.com/nomen/foo.git
    

    Your configuration prefix location could be passed as a salt pillar. If the build process is more complicated, you may consider writing a custom state.