User story #10313
closed
Added by Hamlyn Mootoo over 7 years ago.
Updated over 5 years ago.
Description
I know this is not the intended use of configuration management, but I had unexpected behavior in a directive (the /tmp directory was unexpectedly renamed) and I needed to fix it.
I tried using the job scheduler with a priority of zero and thought that would do it but I couldn't seem to get it to work or didn't wait long enough since it only gives me two hourly boundaries. I ended up adding a rule for a cron job to do the rename, then deleting the rule after the job ran, then put in another rule to delete the cron job entry in the /etc/cron.d directory, then deleted that rule.
Depending on the goal of the command to execute, it is better to test the result directly, for example, in the technique editor:
- a method "Directory check exists" on
/wrong_tmp_dir
- a method "Command Execution" with a condition on the outcome of the previous method
You could always use a file as a flag if you cannot test if the command was executed:
- a method "File check exists" on for example
/var/rudder/flag_file
- a method "Command Execution" with a condition on the outcome of the previous method
- a method "File create" on
/var/rudder/flag_file
Does this answer your question?
Well I was just really looking for an existing directive that would just perform a one-off shell command that I could link to a rule which I could subsequently delete after the command completed. I tried using the job scheduler in this capacity, but I'm not sure how it's supposed to work, as I was unable to get it to execute the command I gave it.
- Target version changed from 4.1.0~rc1 to 4.1.0
- Category changed from Server components to Techniques
- Target version changed from 4.1.0 to 4.1.1
- Target version changed from 4.1.1 to 4.1.2
- Target version changed from 4.1.2 to 4.1.3
- Target version changed from 4.1.3 to 4.1.4
- Status changed from New to Discussion
The scheduler was made to run a command about once a day or once a week, at a predefined random time (like what we do for inventories).
This is not the best use case for Rudder, but if you want to do it anyway, you can create a technique the :
- Call the method: File create ("/tmp/a file")
- On condition: file_create__tmp_a_file_repaired
- Call Command execution("your command")
Please note that if the file if remove, the command may be re-executed again.
However it can do the trick for your problem.
- Target version changed from 4.1.4 to 4.1.5
- Target version changed from 4.1.5 to 4.1.6
- Target version changed from 4.1.6 to 4.1.7
- Target version changed from 4.1.7 to 4.1.8
- Target version changed from 4.1.8 to 4.1.9
- Target version changed from 4.1.9 to 4.1.10
- Tracker changed from Question to User story
- Target version changed from 4.1.10 to Ideas (not version specific)
Converting to a user story since this should be a feature in ncf (for example based on flags).
- Subject changed from Is there a way to run a command just once? to Run a command just once
- Status changed from Discussion to Rejected
- Is duplicate of User story #13667: Add condition_once and execute_once generic methods added
Also available in: Atom
PDF