I’m trying to capture the linux banner you see before you login to a Linux server - using Ansible. I don’t want to login to the server, just get the banner. I was hoping to use register to save it, then use part of it’s contents as a conditional for which tasks to run.
Is this possible?
I originally tried to just run a remote command and capture the output, but I only get the output of the command and not the banner so it’s a little more tricky to do than I first thought.
I.E: A standard banner:
WARNING : Unauthorized access to this system is forbidden and will be prosecuted by law. By accessing this system, you agree that your actions may be monitored if unauthorized usage is suspected. MANAGED by SYSTEM-A
So if I find “MANAGED by SYSTEM-A” in the banner, I run specific tasks and specific host variables. If it isn’t managed by system-a, I run the same tasks but use different host variables.
This would form part of a set of pre-tasks within Ansible before the main playbooks and roles are run.
What I’m seeing is the banner is probably discarded as rubbish by Ansible but there may be an output plugin I could use to save the contents?
Hopefully I’ve explained what I’m trying to do and someone has maybe done this previously.
Thanks for your help.