There's a simple way in bolt to run commands from a file Show archive.org snapshot without caring about BASH escaping:
# /home/user/foo.sh
echo "$(hostname -f): $(uptime)"
echo "${USER}"
echo "${SERVERLIST}" | bolt command run @foo.sh --run-as root --targets -
Use
script run
Show archive.org snapshot
to run a ruby script:
#!/usr/bin/env ruby
# /home/user/bar.rb
puts 'Hello, world!'
echo "${SERVERLIST}" | bolt script run ./bar.rb --targets -