Read more

Don't use puppet `exec` type without `cwd` and `user` parameter

Kim Klotz
April 05, 2016Software engineer at makandra GmbH
  1. Don't use exec without user parameter

    If you use exec without user parameter, the command will get executed as root. You mostly don't want this.

  2. There is a difference in the env variables of the exec if you run puppet manually or if the daemon runs.

  3. Never ever use exec without cwd parameter

    If you use exec without cwd parameter, the command get executed in the cwd of your puppet run. This can cause problems if you run the puppet agent manually.

    Example:

    # exec resource:
    exec { "update_rubygems_${user}_${version}":
      command => "${home}/.rbenv/shims/gem update --system ${version}",
      unless  => "${home}/.rbenv/shims/gem -v | /bin/grep ${version}",
    }
    

    This does execute rbenv commands. If puppet runs in a cwd without .rbenv-version it's no problem it uses the default ruby version. If you are in a cwd with a .ruby-version it uses the ruby version from this file for all rbenv commands. You will probably get some errors.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot
Posted by Kim Klotz to makandra Operations (2016-04-05 16:33)