Bash output to variable

This solution is workable but that mess of code is exactly why a Custom Resource or Helper method is recommended. Any sufficiently overly complicated ruby_block is a code smell.