Can I run a shell built-in command with Puppet?
Solution 1:
There's no point in re-source
ing a new .bashrc
within Puppet, because it'll run in a subshell and the changes won't propagate into your current shell (which is, I assume, what you're trying to do). You can't do what (I think) you want to do.
Solution 2:
Technically, you could use:
exec { "root_bashrc":
command => "bash -c 'source /root/.bashrc'",
subscribe => File["/root/.bashrc"],
refreshonly => true,
}
However, as @womble already pointed out, there's no point in sourcing .bashrc like that; it only affects the bash shell that's run in that command, not any currently running bash shells.
You could possibly set PROMPT_COMMAND="source /root/.bashrc"
to rerun the .bashrc every time a prompt is displayed in any currently running interactive shells, but that seems a bit resource intensive. I've never tried this, but I'd think it would work.