2

I've noticed that the expect module will always time out and cause an rc=1 code. It's doing everything that I want it to, I just want to move to another module.

How can I end the expect module and move to the next one?

  tasks:
    - name: Disk Unassignment
      expect:
        echo: yes
        timeout: 180
        command: telnet '{{ terms }}' '{{ termp }}'
        responses:
          Escape character is:  "echo"
          Error: "boot_diags"
          Continue with boot?: "yes"
          root logged: "disk remove_ownership all"
          Do you: "yes"
          Volumes: "yes"
    - meta: end_play

TASK [Disk Unassignment] *************************************************************************************************************************************************************************** task path: /home/sansible/ansible/disk-unassign.yaml:13 fatal: [localhost]: FAILED! => {"changed": true, "cmd": "telnet '10.233.82.7' '2045'", "delta": "0:05:07.775726", "end": "2018-03-22 12:30:52.315879", "msg": "non-zero return code", "rc": 1, "start": "2018-03-22 12:25:44.540153", "stdout": "Trying 10.233.82.7...\r\r\nConnected to 10.233.82.7.\r\r\nEscape character is '^]'.\r\r\necho\r\nConnected to port 45. \r\necho\r\nInvalid command: \"echo\"\r\nAvailable commands: version, update_flash, netboot, boot_diags, boot_backup, boot_primary, boot_ontap, sp, flash, bye, set, lsmod, autoboot, go, boot, load, ndp, ping, arp, ifconfig, show, savenv, saveenv, unsetenv, set-defaults, setenv, printenv, help\r\n\r\nError (errcode=-1)\r\nLOADER-A> boot_diags\r\nLoading X86_64/freebsd/image1/kernel:0x200000/10377184 0xbe57e0/6364864 Entry at 0x80294c20\r\nLoading X86_64/freebsd/image1/platform.ko:0x11f8000/2512792 0x145e798/393448 0x14be880/541680 \r\nStarting program at 0x80294c20\r\nNetApp Data ONTAP 9.1RC2X9\r\nInvalid config, overriding as ignore_chassis_config is set \r\n\r\nTrying to mount root from msdosfs:/dev/da0s1 [ro]...\r\nmd0 attached to /X86_64/freebsd/image1/rootfs.img\r\nTrying to mount root from ufs:/env/md0.uzip []...\r\nmountroot: waiting for device /env/md0.uzip ...\r\nCopyright (C) 1992-2016 NetApp.\r\nAll rights reserved.\r\nWriting loader environment to the boot device.\r\nLoader environment has been saved to the boot device.\r\n*******************************\r\n* \r\n Press Ctrl-C for Boot Menu. \r\n *\r\n******************************* \t\r\nNo SVM keys found.\r\nFirewall rules loaded.\r\nIpspace \"ACP\" created\r\nWAFL CPLEDGER is enabled. Checklist = 0x7ff841ff\r\nadd host 127.0.10.1: gateway 127.0.20.1\r\n5\r\n\r\n\tNOTE: You have chosen to boot the diagnostics kernel.\r\n\tUse the 'sldiag' command in order to run diagnostics on the system.\r\n\r\n\r\n\tYou have selected the maintenance boot option:\r\n\tthe system has booted in maintenance mode allowing the\r\n\tfollowing operations to be performed:\r\n\r\n\t? \tacorn \r\n\tacpadmin \taggr \r\n\tcna_flash \tdisk \r\n\tdisk_latency \tdisk_list \r\n\tdisk_mung \tdisk_shelf \r\n\tdiskcopy \tdisktest \r\n\tdumpblock \tenvironment \r\n\tfcadmin \tfcstat \r\n\tfctest \tfru_led \r\n\tha-config \thalt \r\n\thelp \tifconfig \r\n\tkey_manager \tled_off \r\n\tled_on \tnicadmin \r\n\tnv8 \traid_config \r\n\tsasadmin \tsasstat \r\n\tscsi \tsesdiag \r\n\tsldiag \tstorage \r\n\tstsb \tsysconfig \r\n\tsystemshell \tucadmin \r\n\tversion \tvmservices \r\n\tvol \tvol_db \r\n\tvsa \txortest \r\n\r\n\tType \"help \" for more details.\r\n\r\n\r\n\tIn a High Availablity configuration, you MUST ensure that the \r\n\tpartner node is (and remains) down, or that takeover is manually \r\n\tdisabled on the partner node, because High Availability \r\n\tsoftware is not started or fully enabled in Maintenance mode.\r\n\r\n\tFAILURE TO DO SO CAN RESULT IN YOUR FILESYSTEMS BEING DESTROYED\r\n\r\n\tNOTE: It is okay to use 'show/status' sub-commands such as\r\n\t'disk show or aggr status' in Maintenance mode while the partner is up\r\nContinue with boot? yes\r\nyes\r\n\r\n\r\nMar 22 12:24:22 [rtpsb-f6280-01-01:acp.need.firmware.update:info]: ACP module (NA) needs a firmware upgrade, (disk shelf serial number: SHJ0000000152A6). \r\n\rMar 22 12:24:22 [rtpsb-f6280-01-01:acp.need.firmware.update:info]: ACP module (NA) needs a firmware upgrade, (disk shelf serial number: SHJ0000000152A6). \r\n\r\r\nThu Mar 22 12:24:49 EDT 2018\r\n*> Mar 22 12:24:49 [rtpsb-f6280-01-01:kern.syslog.msg:notice]: root logged in from SP\r\n \r\n\rdisk remove_ownership all\r\nAll disks will have their ownership information removed.\r\nFor high availability (HA) configurations, the partner node must be down.\r\nDo you wish to continue? yes\r\nVolumes must be taken offline. Are all impacted volumes offline(y/n)?? yes\r\n*> ", "stdout_lines": ["Trying 10.233.82.7...", "", "Connected to 10.233.82.7.", "", "Escape character is '^]'.", "", "echo", "Connected to port 45. ", "echo", "Invalid command: \"echo\"", "Available commands: version, update_flash, netboot, boot_diags, boot_backup, boot_primary, boot_ontap, sp, flash, bye, set, lsmod, autoboot, go, boot, load, ndp, ping, arp, ifconfig, show, savenv, saveenv, unsetenv, set-defaults, setenv, printenv, help", "", "Error (errcode=-1)", "LOADER-A> boot_diags", "Loading X86_64/freebsd/image1/kernel:0x200000/10377184 0xbe57e0/6364864 Entry at 0x80294c20", "Loading X86_64/freebsd/image1/platform.ko:0x11f8000/2512792 0x145e798/393448 0x14be880/541680 ", "Starting program at 0x80294c20", "NetApp Data ONTAP 9.1RC2X9", "Invalid config, overriding as ignore_chassis_config is set ", "", "Trying to mount root from msdosfs:/dev/da0s1 [ro]...", "md0 attached to /X86_64/freebsd/image1/rootfs.img", "Trying to mount root from ufs:/env/md0.uzip []...", "mountroot: waiting for device /env/md0.uzip ...", "Copyright (C) 1992-2016 NetApp.", "All rights reserved.", "Writing loader environment to the boot device.", "Loader environment has been saved to the boot device.", "*******************************", "* ", " Press Ctrl-C for Boot Menu. ", " *", "******************************* \t", "No SVM keys found.", "Firewall rules loaded.", "Ipspace \"ACP\" created", "WAFL CPLEDGER is enabled. Checklist = 0x7ff841ff", "add host 127.0.10.1: gateway 127.0.20.1", "5", "", "\tNOTE: You have chosen to boot the diagnostics kernel.", "\tUse the 'sldiag' command in order to run diagnostics on the system.", "", "", "\tYou have selected the maintenance boot option:", "\tthe system has booted in maintenance mode allowing the", "\tfollowing operations to be performed:", "", "\t? \tacorn ", "\tacpadmin \taggr ", "\tcna_flash \tdisk ", "\tdisk_latency \tdisk_list ", "\tdisk_mung \tdisk_shelf ", "\tdiskcopy \tdisktest ", "\tdumpblock \tenvironment ", "\tfcadmin \tfcstat ", "\tfctest \tfru_led ", "\tha-config \thalt ", "\thelp \tifconfig ", "\tkey_manager \tled_off ", "\tled_on \tnicadmin ", "\tnv8 \traid_config ", "\tsasadmin \tsasstat ", "\tscsi \tsesdiag ", "\tsldiag \tstorage ", "\tstsb \tsysconfig ", "\tsystemshell \tucadmin ", "\tversion \tvmservices ", "\tvol \tvol_db ", "\tvsa \txortest ", "", "\tType \"help \" for more details.", "", "", "\tIn a High Availablity configuration, you MUST ensure that the ", "\tpartner node is (and remains) down, or that takeover is manually ", "\tdisabled on the partner node, because High Availability ", "\tsoftware is not started or fully enabled in Maintenance mode.", "", "\tFAILURE TO DO SO CAN RESULT IN YOUR FILESYSTEMS BEING DESTROYED", "", "\tNOTE: It is okay to use 'show/status' sub-commands such as", "\t'disk show or aggr status' in Maintenance mode while the partner is up", "Continue with boot? yes", "yes", "", "", "Mar 22 12:24:22 [rtpsb-f6280-01-01:acp.need.firmware.update:info]: ACP module (NA) needs a firmware upgrade, (disk shelf serial number: SHJ0000000152A6). ", "", "Mar 22 12:24:22 [rtpsb-f6280-01-01:acp.need.firmware.update:info]: ACP module (NA) needs a firmware upgrade, (disk shelf serial number: SHJ0000000152A6). ", "", "", "Thu Mar 22 12:24:49 EDT 2018", "> Mar 22 12:24:49 [rtpsb-f6280-01-01:kern.syslog.msg:notice]: root logged in from SP", " ", "", "disk remove_ownership all", "All disks will have their ownership information removed.", "For high availability (HA) configurations, the partner node must be down.", "Do you wish to continue? yes", "Volumes must be taken offline. Are all impacted volumes offline(y/n)?? yes", "> "]} to retry, use: --limit @/home/sansible/ansible/disk-unassign.retry

PLAY RECAP ***************************************************************************************************************************************************************************************** localhost : ok=0 changed=0 unreachable=0 failed=1

8
  • 1
    Try to run your telnet command without ansible and verify it's expecting exactly those 6 responses .. seems that expect is still awaiting for one of those inputs to be rendered until timeout.
    – storm
    Commented Mar 21, 2018 at 13:23
  • 1
    Also run your play in debug mode -vv and add this task output to the question so we can see what happened there.
    – storm
    Commented Mar 21, 2018 at 13:25
  • 1
    You're starting a telnet command... which won't end by itself unless you tell the remote system you're ending up the communication... Obviously, the session waits for another command and the module stop it once the time is out for it to run. You should add something like >: "exit"in your steps...
    – Tensibai
    Commented Mar 22, 2018 at 13:18
  • I've watched the console output and all of the response/answers have been matched. I'm not sure how to end the playbook successfully or move on to another module. Commented Mar 22, 2018 at 13:19
  • 1
    You have to answer the last prompt with 'exit' or something like that.
    – Tensibai
    Commented Mar 22, 2018 at 14:10

1 Answer 1

4

Tensibai was correct, the telnet session in the expect module had to end.

Holding down the key combination Ctrl+] to exit wasn't going to work, so an optional escape character was chosen in the telnet command like so:

telnet -e ! 10.224.223.10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.