1

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

Simon Hardman
  • 476
  • 4
  • 14

2 Answers2

1

The Augeasproviders project has a shellvar type for that:

shellvar { "bash_profile-${user}-${name}":
  ensure   => exported,
  target   => "/home/${user}/.bash_profile",
  variable => $variable_name,
  value    => $literal_value,
}

There are also options to manage quoting or array values.

raphink
  • 3,625
  • 1
  • 28
  • 39
0

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 ''",
      ],
  }
Simon Hardman
  • 476
  • 4
  • 14