What’s the Ansible best practice for doing a typical source compile of multiple packages?
So, let’s say you have three source packages that all require the same
three steps: configure, make, and make install.
The three packages have all have been untar-ed into their own directories:
/var/tmp/pkg1
/var/tmp/pkg2
/var/tmp/pkg3
What’s the typical Ansible way to handle it?
command: chdir=/var/tmp/{{ item }} sudo .configure --prefix=/usr
command: chdir=/var/tmp/{{ item }} sudo make
command: chdir=/var/tmp/{{ item }} sudo make install
with_items:
I guess I’ll answer my own question. This seems to be the most common approach:
command: chdir=/var/tmp/ffmpeg-0.11 {{ item }}
with_items:
If you need env variables set for a specific step, you can add them on the
command line as I’ve done with the PATH above. The PATH is changed only for
the ‘sudo’ (e.g. root) environment.
J
Not a direct answer, but I can strongly recommend making your own packages
for this sort of situation. It's make those tasks idempotent and scales a lot
better if you can leverage your underlying package manager.
Building debs/rpms is a massive pain, I know - have a look at FPM
( https://github.com/jordansissel/fpm )
if you need something to make it really easy.
Yep, I’d designate one machine a build server and build packages there, then make a local apt or yum repository.
This is pretty easy either way you go.