Ansible erwartet nicht für mehrere Eingabeaufforderungswerte

5024
Rajkumar .E

Ich muss nginx agent für openam mit ansible installieren.

während der Installation des nginx_agent mehrere Fragen stellen, während das Skript ausgeführt wird ,

 ************************************************************************ Welcome to the OpenSSO Policy Agent for NGINX ************************************************************************  Enter the URL where the OpenAM server is running. Please include the deployment URI also as shown below: (http://opensso.sample.com:58080/opensso) **OpenSSO server URL: sss** Enter the Agent profile name **Agent Profile Name: sss** Enter the password to be used for identifying the Agent. *THIS IS NOT PASSWORD FILE* **Agent Password:**  ----------------------------------------------- SUMMARY OF YOUR RESPONSES ----------------------------------------------- OpenSSO server URL : sss Agent Profile name : sss Agent Password: sss **Continue with Installation? [y/N]: y** 

Also, ich habe erwartet erwarten Modul in Ansible:

- expect: command: sh /opt/nginx_agent/bin/agentadmin.sh responses: OpenSSO server URL: "http://openam.test.mobi:8080/openam" Agent Profile Name: "nginx" Agent Password: "test.mobi2" (^Con[^\n]*\n+[^\n]*)+: "y"  

Aber es geht weiter mit der Installation? [J / N]:

nimmt, OpenSSO Server URL: Wert siehe,

Referenz:

 "stdout_lines": [ "************************************************************************",  "Welcome to the OpenSSO Policy Agent for NGINX",  "************************************************************************",  "",  "Enter the URL where the OpenAM server is running.",  "Please include the deployment URI also as shown below:",  "(http://opensso.sample.com:58080/opensso)",  "OpenSSO server URL: Enter the Agent profile name",  "Agent Profile Name: Enter the password to be used for identifying the Agent.",  "*THIS IS NOT PASSWORD FILE*",  "Agent Password: ",  "-----------------------------------------------",  "SUMMARY OF YOUR RESPONSES",  "-----------------------------------------------",  "OpenSSO server URL : http://openam.test.mobi:8080/openam",  "Agent Profile name : nginx",  "Agent Password: test.mobi2",  "Continue with Installation?",  "[y/N]: http://openam.test.mobi:8080/openam",  "test.mobi2" ] 

Schlagen Sie mir vor, was ich in dieser Konfiguration vermisse. Wie kann ich das beheben?

0

1 Antwort auf die Frage

0
glebaron

Ich würde versuchen, das zu ignorieren Continue with Installation?und einfach auf die [y/N]Linie zu passen .

ersetzen (^Con[^\n]*\n+[^\n]*)+: "y"durch'y/N' : 'y'

Ansible verwendet das pexpect-Modul, das nicht immer das tut, was Sie erwarten würden. Zum Beispiel ist EOL '\r\n'nicht '\n'.

Hier finden Sie die Dokumente .

Hier ist ein kurzer Test:

/root/junk.sh echo 'Enter the Agent profile name' read -p "Agent Profile Name: " AGENT_PROFILE_NAME echo $AGENT_PROFILE_NAME > junk.dat echo "Continue with installation" read -p "[y/N] : " CONFIRM echo $CONFIRM >> junk.dat  play: - expect: command: sh /root/junk.sh responses: 'Profile Name' : "oook" 'y/N' : 'y' 

Hier ist eine einfachere Möglichkeit, dies ohne zu erwarten zu tun.

Wenn Sie sich das Skript agentadmin.sh ansehen, werden Sie sehen, dass Antworten auf alle Fragen in Umgebungsvariablen gespeichert werden, z

while [ -z $ ]; do 

Wenn Sie alle im Umgebungsbereich Ihres Playbooks vordefinieren, sollte das Skript ohne Eingreifen des Benutzers ausgeführt werden. Keine Notwendigkeit zu erwarten.

So etwas wie:

environment: OPENAM_URL: whatever_1 AGENT_PROFILE_NAME: whatever_2 AGENT_PASSWORD: whatever_3 CONFIRM: y  - shell: /opt/nginx_agent/bin/agentadmin.sh 
Ich habe es versucht, aber ich habe immer noch dasselbe Problem Rajkumar .E vor 7 Jahren 0
Versuchen Sie es mit ansible-playbook -vvv playbook.yml auszuführen. glebaron vor 7 Jahren 0