I would like to go to the location
/var/log/src/ap-kernelmodule-10.001-100
But looks like my code has to deal with ap-kernelmodule-10.002-100, ap-kernelmodule-10.003-101 etc. I would like to reach the location with a split string and execute my command. eg : /var/log/src/ap-kernelmodule-10./
This ruby script for a Linux machine, so I used Mixlib:: ShellOut.
begin
cmd = Mixlib::ShellOut.new("command run here" , :cwd =>
'/var/cache/acpchef/src/ap-kernelmodule-10xxx')
cmd.run_command
end
I am not quite get on what you really want to achieve. Question is rather ambiguous.
You know you would like to go to
/var/log/src/ap-kernelmodule-10.001-100
and run a command, the most obvious way is you could just use:But if you would like to run a command for each directory like you said in
ap-kernelmodule-10.002-100
,ap-kernelmodule-10.003-101
etc. with/var/log/src/ap-kernelmodule-10.*/
sequentially.Then you could do with:
Additionally, parallel resources execution is not possible natively in chef (AFAIK). So, the possible workaround is to use
bash
orruby_block
resource to construct commands to be executed inxargs
,parallel
or similar tools.Hope this helps.
You can't be in multiple
cwd
s simultaneously. To run the command for each directory that matches the pattern, you can useDir#glob
: