I'm using ansible expect to create a user for my nessus (by using the nessuscli). the expect should answer few question as below (I added the numbers 1-5). My expect get stuck at number 5. the last letters of number 5 is the "(the user can have an empty rules set)" and then the next line (carriage return). This makes the issue as I dont know how to tell expect that there is a phrase that is followed by a next line. I tried \r \n and none of them worked! any healp is appreciated.
Also, you can see my ansible code below.
Thanks
you can see the screenshot of the nessus cli propmt here: screenshot of nessucli propmpt
============ Nessuscli adduser Prompt(s) ==========
1- Login:
2- Login password:
3- Login password (again):
4- Do you want this user to be a Nessus 'system administrator' user (can upload plugins, etc.)? (y/n) [n]: y
5- User rules
nessusd has a rules system which allows you to restrict the hosts that test has the right to test. For instance, you may want him to be able to scan his own host only.
Please see the Nessus Command Line Reference for the rules syntax
Enter the rules for this user, and enter a BLANK LINE once you are done : (the user can have an empty rules set)
===================================================
My Ansible Code:
name: create nessus user
expect:
command: /opt/nessus/sbin/nessuscli adduser
responses:
'Login: ': "{{nessus_username}}" # answer number 1
'Login password: ': "{{nessus_pass}}" # answer number 2
'Login password \(again\): ': "{{nessus_pass}}" # answer number 3
'\[n\]: ': 'y' # answer number 4
'set\)\\n ': "\n" # answer number 5 which doesnt work
'\[n\]: ': 'y' # answer the next propmpt (not in question and works)