I was looking at a puppet manifest and saw this
exec { "my_command":
command => "do some command",
path => "$::path",
}
I don't see the variable path being set anywhere though in the manifest file. Is "$::path" a special variable in puppet?
When I tried an example command of grep with no path, it couldn't be found, but when I had "$::path" it worked just ifne.
Yes, it's a special variable. More precisely, it's a fact. You can always refer to facts like top-scope variables ($::name).
More info here:
https://docs.puppetlabs.com/learning/variables.html#facts
If you want to see the facts about a system. You can type "facter" in your terminal where you have installed puppet. It will give you the entire facts about a the said system. You can check out particular fact by typing the following in the terminal
facter path
This fact can be referenced as variables in puppet manifest by using
$::path
Related
I need puppet to execute a script that is inside an installed app. In addition I need to run only if it detects an older version of the and is not on a certain server and then install the new version
I have tried a bunch of stuff and I am losing track. First I tried to use a cd to go to the where the script and then tried running the script directly but I keep getting the same error.
install.pp
# Install required packages
class tripwire::install {
exec { 'uninstall_tripwire':
command => './usr/local/tripwire/te/agent/bin/uninstall.sh',
cwd => '/usr/local/tripwire/te/agent/bin',
path => '/usr/bin/sh',
onlyif => [
"${::fqdn} != 'server.com'",
'/usr/bin/test -f
/usr/local/tripwire/te/agent/bin/uninstall.sh',
"grep -c '8.6.0' /usr/local/tripwire/te/agent/data/version",
],
notify => Exec['install_tripwire'],
I would think this would it would execute the script but all I get is:
Error: /Stage[main]/Tripwire::Install/Exec[uninstall_tripwire]: Could not evaluate: Could not find command 'server.com'
I need puppet to execute a script that is inside an installed app. In
addition I need to run only if it detects an older version of the and
is not on a certain server and then install the new version
The particular task you seem to be trying to perform with your Exec duplicates standard behavior of the Package resource. You really, really ought to manage software via packages, even if you have to do some packaging yourself and maintain a local package repository. The time spent on packaging is easily offset by the time saved managing software, even with Puppet in the mix.
Additionally, as far as controlling which machines to operate upon goes, you ought to be treating that as a matter of classification. If that class should not be applied to machine server.com then it should not be declared into that machine's catalog. If it should be applied differently to that machine than to others, then it should be appropriately parameterized, and those parameters used (at classification time, maybe with the help of Hiera) to select the appropriate behavior for each target machine.
Nevertheless, with respect to the code actually presented, the error message
Could not evaluate: Could not find command 'server.com'
reflects that this element of your onlyif array ...
"${::fqdn} != 'server.com'",
... is not a command. onlyif requires a command or an array of them that can be executed on the target system, so maybe this, instead:
"test ${::fqdn} != server.com",
Additionally, this looks wrong:
command => './usr/local/tripwire/te/agent/bin/uninstall.sh',
Remove the leading ., unless you really intend to resolve that path against the working directory. And if you do intend to resolve it as a relative path then I urge you to instead expand it to an absolute one.
Furthermore, this probably doesn't do what you intend:
path => '/usr/bin/sh',
The path attribute names a binary search path, like the PATH environment variable. You may indeed want to specify one, such as maybe '/bin:/usr/bin:/sbin:/usr/sbin', but if the intention of what you did put was for the commmand to be executed via a shell, then you were looking for
provider => 'shell',
This question already has answers here:
Linux wrong path exported. How to recover ~./bashrc file
(2 answers)
Closed 4 years ago.
First of all, i was installing CUDA with cuDNN, the thing is that i put some new paths on the ~/.bashrc after that all the commands like ls, sudo, etc. doesn't work, it shows this message
The command could not be located because '/usr/bin' is not included in the PATH environment variable.
sudo: command not found
Do anyone knows what is the issue?
You need to include the /usr/bin path in your PATH environment variable because this is where the ls, cd & all others built-in commands are located.
The easiest way is to update your PATH environment variable with the export method :
export PATH="$PATH:/usr/bin"
If the export method doesn't work for you, you can edit your .bashrc file (nano ~/.bashrc) and update the PATH variable by adding the /usr/bin path in it.
Good luck
I am trying to run the Swift compiler under Ubuntu. I followed this tutorial: https://itsfoss.com/use-swift-linux/ and everything seemed to work fine. I was able to run swift under Ubuntu.
However, when I closed the terminal, I was not able to run Swift anymore. The program was not found until I installed it again. I could not find any answers to this question as there aren't many people running Swift under Ubuntu.
It's not uninstalled, you just don't have the environment variables set up anymore, so Bash can't find the path to Swift. You can change that by exporting the appropriate environment variables in your .bashrc file.
When you followed the tutorial, you ran the following command:
export PATH=path_to_swift_usr_bin:$PATH
This command adds the path to the swift binary to your PATH environment variable. The PATH variable holds a list of places where Ubuntu will look for programs to run from the command-line. So if the Swift executable is not in one of the places listed in the PATH, your terminal will never find it.
There is a file in your home folder (the folder ~, which is an abbreviation for /home/username, where username is your username) named .bashrc, which runs whenever you open a new terminal window. If you need an environment variable to be available whenever you open the terminal, you should add the export line for that variable to your .bashrc.
In this case, your .basrhc should contain the same line above.
The important thing to remember is that your environment variables are not preserved between command-line sessions, so if you want to have an environment variable available every time you use the command-line, it needs to be defined in your .bashrc.
The google app engine cli commands cannot be found in the python sdk. I've already checked the google_appengine file. The shell commands are there, and I already added the app engine file path to the PATH variable. I echo the PATH variable and the directory to the app_engine file shows up, but still shows not found when I try to use a command that's inside the file. If I reference the command directly by using its whole path, the command works, but otherwise it won't. Is there anything else that needs to be done to reference a command in shell?
More error info please,
If I reference the command directly by using its whole path, the command works
I think your python path maybe wrong, Python 2.6 is not supported.
so are you have mulit-version python?
Thank you for your contributions everyone. It turns out the path I was using was wrong. Instead of /home/Programs/Apps/google_appengine it should have been /home/Programs/google_appengine. I guess the shell doesn't check to see if the path you add to the PATH variable actually exists. Who knew? Not me
Until I run into another problem stack overflow--which may be soon
See ya
everyone.
I had a basic question want to consult, about the environment variable setting.
After closed my one existed terminal which could execute compile(make) and do customed(mksdboot) command, i can't do mksdboot command anymore(I had execute a predefined setting environment variable shell script i.e. $ . ./arndale_envsetup.sh again) in the new terminal.
Cause i am a beginner in Linux, i am not very clearly about the environment variable setting rules.
i had tried to 'su' or 'sudo' to execute mksdboot, but no luck:(
ps. I had another project needs to compile in my PC(i didn't export PATH to .bashrc, only execute export PATH when i open a new terminal every time), may it efforts the original project's environment variable?
thanks.
[UPDATED]
i tried using $source ./arndale_envsetup.sh, relative commands worked finally.
but i still did't figure out the reason between work or not work. >"<
The command
history
will list what your previous commands where.
This might give you a pointer what set the path in the way you needed it.
You could also try to see where you command is via
locate mksdboot