Put common functions in separate files

so we can import the ones that we want. (This makes reuse in other projects cleaner).
Incidentally this fixes generate_haproxy.cfg.bash that had got unadvertently broken (yeah the scripts aren't really tested)