Extract range from config file matching pattern

I have config file like this:

server_name xx opt1 opt2 opt3
    suboptions1
    #suboptions - disabled
    suboptions2 pattern
    suboptions3
server_name yy opt1 opt2 opt3
    suboptions1 pattern
    #suboptions - disabled
    suboptions2

So basically I want to extract the server name together with just options/pattern like i.e. suboptions2 but just in range from server to server section like sed '/start/,/end/' file.cfg but just for suboptions which doesn't match some pattern and also exlucde servernames for those. Thank you.

Try something like:

awk '/^[^ \t]/{print x}1' config_file | awk '/suboptions2 pattern/' RS=

or:

awk -v s="suboptions2 pattern" '/^[^ \t]/{if(p~s) print p; p=$0; next}{p=p RS $0} END{if(p~s) print p}' config_file