Search code examples
puppetaugeas

How to add export statements to bash_profile with Augeas and Puppet


I have Puppet + Augeas working to assign variable values in a bash_profile, however I have not found a way to export the variables from the file.

  augeas { "bash_profile-${user}-${name}":
    incl    => "/home/${user}/.bash_profile",
    lens    => 'Shellvars.lns',
    changes => "set ${variable_name} '\"${literal_value}\"'",
  }

Results in:

# .bash_profile 
variable="value"

But what i need is:

# .bash_profile 
export variable="value"
# or
variable="value"
export variable

This Puppet ticket seems like it should point in the right direction, but I can't make out how to write the export statements


Solution

  • This seems to do the trick:

      augeas { "bash_profile-${user}-${name}":
        incl    => "/home/${user}/.bash_profile",
        lens    => 'Shellvars.lns',
        changes => [
          "set ${variable_name} '\"${literal_value}\"'",
          "set ${variable_name}/export ''",
          ],
      }