unten unter Verwendung der i-Textbuch erstellt haben. Ich bekomme nicht die Möglichkeit, die Ausgabe des Shell-Befehls zu speichern und anzuzeigen und die gleiche Ausgabe an andere Spiele mit unterschiedlichen Hosts zu übergeben.Wie zu speichern und die Ausgabe des Shell-Befehl Lauf in Schleife anzuzeigen with_lines
---
- hosts: localhost
tasks:
- name: "check the connectivity with username for all the LLC servers from hosts.new file"
shell: ssh [email protected]{{ item }} "date"
register: result
with_lines: cat "/home/capio/ansible/pmossWipm/day2/logs/ipAddress.txt"
- debug: var=result
Nun, wie kann ich das Ergebnis der Registervariable "Ergebnis" anzeigen. Ich habe versucht mit dem Debug, aber es hat nicht funktioniert.
Unten finden Sie die Ausgabe von var =
TASK [debug] *******************************************************************
ok: [localhost] => {
"result": {
"changed": true,
"msg": "All items completed",
"results": [
{
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": true,
"cmd": "ssh [email protected] \"date\"",
"delta": "0:00:00.237866",
"end": "2017-05-09 08:59:13.918581",
"invocation": {
"module_args": {
"_raw_params": "ssh [email protected] \"date\"",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
},
"module_name": "command"
},
"item": "130.6.50.131",
"rc": 0,
"start": "2017-05-09 08:59:13.680715",
"stderr": " _________________________________________________________________\n\n This system is restricted to ABC authorized users for business\n purposes. Unauthorized access is a violation of the law. This\n service may be monitored for administrative and security reasons.\n By proceeding, you consent to this monitoring.\n _________________________________________________________________\n\n ,
"stdout": "Tue May 9 08:59:13 EDT 2017",
"stdout_lines": [
"Tue May 9 08:59:13 EDT 2017"
],
"warnings": []
},
{
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": true,
"cmd": "ssh [email protected] \"date\"",
"delta": "0:00:00.245660",
"end": "2017-05-09 08:59:14.430728",
"invocation": {
"module_args": {
"_raw_params": "ssh [email protected] \"date\"",
"_uses_shell": true,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
},
"module_name": "command"
},
"item": "130.6.50.132",
"rc": 0,
"start": "2017-05-09 08:59:14.185068",
"stderr": " _________________________________________________________________\n\n This system is restricted to ABC authorized users for business\n purposes. Unauthorized access is a violation of the law. This\n service may be monitored for administrative and security reasons.\n By proceeding, you consent to this monitoring.\n _________________________________________________________________\n\n [,
"stdout": "Tue May 9 08:59:14 EDT 2017",
"stdout_lines": [
"Tue May 9 08:59:14 EDT 2017"
],
"warnings": []
}
]
}
}
Bitte fügen Sie die Ausgabe von '- debug: var = Ergebnis ". –
Ich habe die Ausgabe von var = result in der obigen Frage aktualisiert. Bitte lassen Sie mich wissen, wenn Sie weitere Eingänge – nishant