ansible-cisco IOS和“重新加载”命令 [英] ansible - cisco IOS and "reload" command

查看:2697
本文介绍了ansible-cisco IOS和“重新加载”命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要发送命令reload in到Cisco IOS,但是具体命令需要确认如下:

  #reload in 30 
由admin在vty0(192.168.253.15)上重新加载计划在30分钟内
继续重新加载? [确认]

它像ios_command模块不处理这种情况。
我的配置:

  tasks:
- name:在catting off b $ b ios_command:
命令:reload in 30
命令:y
provider:{{cli}}

从playbook回应:

  TASK [ cat off off] ************************************** 
任务路径:/ etc / ansible / test1.yml:14
< 192.168.0.33>为用户建立本地连接:root
< 192.168.0.33> EXEC / bin / sh -c'(umask 77&& mkdir -p`echo $ HOME / .ansible / tmp / ansible-tmp-1476454008.17-103724241654271`&&&&&&&&&&&&&  =`echo $ HOME / .ansible / tmp / ansible-tmp-1476454008.17-103724241654271`)&&& sleep 0'
< 192.168.0.33> PUT / tmp / tmpAJiZR2 TO /root/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271/ios_command
< 192.168.0.33> EXEC / bin / sh -c'LANG = pl_PL.UTF-8 LC_ALL = pl_PL.UTF-8 LC_MESSAGES = pl_PL.UTF-8 / usr / bin / python /root/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271 / ios_command; rm -rf/root/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271/> / dev / null 2>& 1&&& sleep 0'
fatal:[192.168.0.33]:FAILED! => {auth_pass:null,authorize:false,commands:[false:false, y],host:192.168.0.33,interval:1,password:VALUE_SPECIFIED_IN_NO_LOG_PARAMETER,port:22,provider:{'username':'admin' host':'192.168.0.33','password':'********'},retries:10,ssh_keyfile:null,timeout:10,username:admin ,waitfor:null},module_name:ios_command},msg:匹配错误响应:y\r\\\
^ \r\\\
% marker.\r\\\
\r\\\
sw7.test.lab#}

如何处理此问题?



$ b

更新:

我尝试在YAML文件中使用expect模块,如下所示:

 名称:一些测试
hosts:sw-test
gather_facts:False
#connection:local

tasks:
- name:在catting off的情况下重新加载$ ​​b $ b expect:
命令:reload in 30
响应:
'管理员在30分钟内重新加载vty0(192.168.253.20)\\\
Proceed with reload? \ [confirm\]':y
echo:yes

连接问题:

  oot @ Kali:/ etc / ansible#ansible-playbook test3 -u admin -k -vvvv 
使用/etc/ansible/ansible.cfg作为配置文件
SSH密码:
加载回调默认类型stdout,v2.0

PLAYBOOK:test3 **** **************************************************** **********
1次在test3

PLAY [一些测试] ***************** *******************************************

TASK [在catting off的情况下重新加载] *********************************** *
任务路径:/ etc / ansible / test3:9
< 192.168.0.33>为用户建立SSH连接:admin
< 192.168.0.33> SSH:EXEC sshpass -d12 ssh -C -vvv -o ControlMaster = auto -o ControlPersist = 60s -o StrictHostKeyChecking = no -o User = admin -o ConnectTimeout = 10 -o ControlPath = / root / .ansible / cp / ansible- ssh-%h-%p-%r 192.168.0.33'/ bin / sh -c'''(umask 77&&mkdir -p`echo $ HOME / .ansible / tmp / ansible-tmp- 1476882070.37-92402455055985`&&&&&&&&&&&&&&&&&&&&           sleep 0'''
< 192.168.0.33> PUT / tmp / tmp30wGsF TO`echo $ HOME / .ansible / tmp / ansible-tmp-1476882070.37-92402455055985`)&& sleep 0'/ expect
< 192.168.0.33> SSH:EXEC sshpass -d12 sftp -o BatchMode = no -b - -C -vvv -o ControlMaster = auto -o ControlPersist = 60s -o StrictHostKeyChecking = no -o User = admin -o ConnectTimeout = 10 -o ControlPath = / root / .ansible / cp / ansible-ssh-%h-%p-%r'[1​​92.168.0.33]'
fatal:[192.168 .0.33]:UNREACHABLE!=> {changed:false,msg:SSH错误:数据无法发送到远程主机。确保可以通过ssh,unreachable访问此主机:true}
重试,使用:--limit @ / etc / ansible / test3.retry

播放录音** **************************************************** *****************
192.168.0.33:ok = 0 changed = 0 unreachable = 1 failed = 0


root @Kali:/ etc / ansible#ansible-playbook test3 -u admin -k -vvvv -c ssh
使用/etc/ansible/ansible.cfg作为配置文件
SSH密码:
加载回调默认类型stdout,v2.0

PLAYBOOK:test3 ****************************** **********************************
1在test3中播放

PLAY [一些测试] ******************************************* *****************

TASK [在catting off情况下重新载入] ************* *************************
任务路径:/ etc / ansible / test3:9
< 192.168.0.33> ;为用户建立SSH连接:admin
< 192.168.0.33> SSH:EXEC sshpass -d12 ssh -C -vvv -o ControlMaster = auto -o ControlPersist = 60s -o StrictHostKeyChecking = no -o User = admin -o ConnectTimeout = 10 -o ControlPath = / root / .ansible / cp / ansible-ssh-%h-%p-%r 192.168.0.33'/ bin / sh -c'''(umask 77& ; mkdir -p`echo $ HOME / .ansible / tmp / ansible-tmp-1476882145.78-139203779538157`&&& echo ansible-tmp-1476882145.78-139203779538157 =`echo $ HOME / .ansible / tmp / ansible-tmp-1476882145.78-139203779538157`)&& sleep 0'''
< 192.168.0.33> PUT / tmp / tmpY5qqyW TO`echo $ HOME / .ansible / tmp / ansible-tmp-1476882145.78-139203779538157`)&&& sleep 0'/ expect
< 192.168.0.33> SSH:EXEC sshpass -d12 sftp -o BatchMode = no -b - -C -vvv -o

ControlMaster = o ControlPersist = 60s -o StrictHostKeyChecking = no -o User = admin -o ConnectTimeout = 10 -o ControlPath = / root / .ansible / cp / ansible-ssh-%h-%p-%r'[1​​92.168.0.33]
fatal:[192.168.0.33]:UNREACHABLE!=> {changed:false,msg:SSH错误:无法将数据发送到远程主机。确保可以通过ssh,unreachable访问此主机:true}
重试,使用:--limit @ / etc / ansible / test3.retry

播放录音** **************************************************** *****************
192.168.0.33:ok = 0 changed = 0 unreachable = 1 failed = 0

root @ Kali:/ etc / ansible#ansible-playbook test3 -u admin -k -vvvv -c local
使用/etc/ansible/ansible.cfg作为配置文件
SSH密码:
加载回调默认类型stdout,v2.0

PLAYBOOK:test3 ********************************** ******************************
在test3中播放1次

PLAY [一些测试] ************************************************* *************

TASK [在catting off的情况下重新载入] *************** *********************
任务路径:/ etc / ansible / test3:9
< 192.168.0.33>建立本地连接FOR USER:root
< 192.168.0.33> EXEC / bin / sh -c'(umask 77&& mkdir -p`echo $ HOME / .ansible / tmp / ansible-tmp-1476882426.62- 172601217553809`&&& echo ansible-tmp-1476882426.62-172601217553809 =`echo $ HOME / .ansible / tmp / ansible-tmp-1476882426.62-172601217553809`)&& sleep 0'
< 192.168.0.33> PUT / tmp / tmpdq1pYy TO /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect
< 192.168.0.33> EXEC / bin / sh -c'chmod u + x /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/ /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect&& sleep 0'
< 192.168.0.33> EXEC / bin / sh -c'LANG = pl_PL.UTF-8 LC_ALL = pl_PL.UTF-8 LC_MESSAGES = pl_PL.UTF-8 / usr / bin / python /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809 /期望; rm -rf/root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/> / dev / null 2>& 1&&& sleep 0'
fatal:[192.168.0.33]:FAILED! => {changed:false,failed:true,invocation:{module_args:{chdir:null,command:reload in 30,creates:null,echo:true ,removed:null,responses:{管理员在30分钟内重新加载vty0(192.168.253.20)\\\\
通过重新加载?\\ [confirm\\]:y },timeout:30},module_name:expect},msg:命令未找到或不可执行:reload。}

**************************************************** ***********
重试,使用:--limit @ / etc / ansible / test3.retry

播放录音******** **************************************************** ***********
192.168.0.33:ok = 0 changed = 0 unreachable = 0 failed = 1






UPDATED



我安装了ansible 2.3并尝试如下:

  tasks:
- name:在catting off的情况下重新加载$ ​​b $ b ios_command:
命令:
- reload in 30
- y
wait_for:
- result [0]包含继续重载
provider:{{cli}}

但是,我得到一个错误。我认为这是因为ios模块总是等待promt作为响应。并且重新加载命令的额外确认没有按y之后的Enter,因此这可能是另一个问题。

  $ sudo ansible-playbook test1.yml -vvvv 
使用/etc/ansible/ansible.cfg作为配置文件
加载回调插件默认类型stdout,v2.0从/usr/local/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc

PLAYBOOK: test1.yml *********************************************** *************
1在test1.yml中播放

PLAY [testowe dzialania] ************** *****************************************

TASK [在catting off的情况下重新加载] **************************************
任务路径:/home/user1/test1.yml:13
使用模块文件/usr/local/lib/python2.7/dist-packages/ansible/modules/core/network/ios/ios_command。 py
< 192.168.0.33>为用户建立本地连接:root
< 192.168.0.33> EXEC / bin / sh -c'(umask 77&&mkdir -p`echo $ HOME / .ansible / tmp / ansible-tmp-1477557527.56-157304653717324`&&&&&&&&&&&&&& =`echo $ HOME / .ansible / tmp / ansible-tmp-1477557527.56-157304653717324`)&&& sleep 0'
< 192.168.0.33> PUT / tmp / tmphf8EWO TO /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ios_command.py
< 192.168.0.33> EXEC / bin / sh -c'chmod u + x /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ios_command。 py&& sleep 0'
< 192.168.0.33> EXEC / bin / sh -c'/ usr / bin / python /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ios_command.py; rm -rf/home/user1/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/> / dev / null 2>& 1&&& sleep 0'
fatal:[192.168.0.33]:FAILED! => {
changed:false,
failed:true,
invocation:{
module_args:{
auth_pass:null,
authorize:false,
commands:[
重新载入30,
y
],
host 192.168.0.33,
interval:1,
match:all,
password:VALUE_SPECIFIED_IN_NO_LOG_PARAMETER,
port:null,
provider:{
host:192.168.0.33,
password:VALUE_SPECIFIED_IN_NO_LOG_PARAMETER,
username:admin
} ,
retries:10,
ssh_keyfile:null,
timeout:10,
transport:null,
use_ssl:true ,
username:admin,
validate_certs:true,
wait_for:[
result [0] contains \Proceed with reload\
]
},
module_name:ios_command
},
msg:timeout尝试发送命令:reload in 30\ r
}
重试,使用:--limit @ / home / user1 / test1.retry

播放录音************ **************************************************** *******
192.168.0.33:ok = 0 changed = 0 unreachable = 0 failed = 1


b $ b

任何人都可以有任何想法如何解决ansible或maby的问题,唯一的方法是使用纯python脚本或写自己的ansible模块?

解决方案

您可以使用:

   -  name:reload device 
ios_command:
命令:
- reload in 1 \\\
y
provider:{{cli}}

这将在1分钟后重新加载设备,重新加载提示被接受。它的工作原理很好,因为默认提示ios会回来(重新加载在1分钟内触发)。



注意,
Simon


I would like to send command "reload in " to Cisco IOS, but that specific command needs to be confirmed like below:

#reload in 30
Reload scheduled in 30 minutes by admin on vty0 (192.168.253.15)
Proceed with reload? [confirm]

It semms like ios_command module doesn't handle such case. My configuration:

 tasks:
   - name: do reload in case of "catting off"
     ios_command:
      commands: reload in 30
      commands: y
      provider: "{{ cli }}"

And response from playbook:

TASK [do reload in case of "catting off"] **************************************
    task path: /etc/ansible/test1.yml:14
    <192.168.0.33> ESTABLISH LOCAL CONNECTION FOR USER: root
    <192.168.0.33> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271 `" && echo ansible-tmp-1476454008.17-103724241654271="` echo $HOME/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271 `" ) && sleep 0'
    <192.168.0.33> PUT /tmp/tmpAJiZR2 TO /root/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271/ios_command
    <192.168.0.33> EXEC /bin/sh -c 'LANG=pl_PL.UTF-8 LC_ALL=pl_PL.UTF-8 LC_MESSAGES=pl_PL.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271/ios_command; rm -rf "/root/.ansible/tmp/ansible-tmp-1476454008.17-103724241654271/" > /dev/null 2>&1 && sleep 0'
    fatal: [192.168.0.33]: FAILED! => {"changed": false, "commands": ["y"], "failed": true, "invocation": {"module_args": {"auth_pass": null, "authorize": false, "commands": ["y"], "host": "192.168.0.33", "interval": 1, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "port": 22, "provider": "{'username': 'admin', 'host': '192.168.0.33', 'password': '********'}", "retries": 10, "ssh_keyfile": null, "timeout": 10, "username": "admin", "waitfor": null}, "module_name": "ios_command"}, "msg": "matched error in response: y\r\n                   ^\r\n% Invalid input detected at '^' marker.\r\n\r\nsw7.test.lab#"}

How can I handle this?


updated:

If I try to use expect module in YAML file like this:

 name: some tests
  hosts: sw-test
  gather_facts: False
#  connection: local

  tasks:
  - name: do reload in case of "catting off"
    expect:
     command: reload in 30
     responses:
      'Reload scheduled in 30 minutes by admin on vty0 (192.168.253.20)\nProceed with reload? \[confirm\]' : y
     echo: yes

But there is a problem with connection:

oot@Kali:/etc/ansible# ansible-playbook test3 -u admin -k -vvvv 
Using /etc/ansible/ansible.cfg as config file
SSH password: 
Loaded callback default of type stdout, v2.0

PLAYBOOK: test3 ****************************************************************
1 plays in test3

PLAY [some tests] **************************************************************

TASK [do reload in case of "catting off"] **************************************
task path: /etc/ansible/test3:9
<192.168.0.33> ESTABLISH SSH CONNECTION FOR USER: admin
<192.168.0.33> SSH: EXEC sshpass -d12 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.0.33 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476882070.37-92402455055985 `" && echo ansible-tmp-1476882070.37-92402455055985="` echo $HOME/.ansible/tmp/ansible-tmp-1476882070.37-92402455055985 `" ) && sleep 0'"'"''
<192.168.0.33> PUT /tmp/tmp30wGsF TO "` echo $HOME/.ansible/tmp/ansible-tmp-1476882070.37-92402455055985 `" ) && sleep 0'"/expect
<192.168.0.33> SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.0.33]'
fatal: [192.168.0.33]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
    to retry, use: --limit @/etc/ansible/test3.retry

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


root@Kali:/etc/ansible# ansible-playbook test3 -u admin -k -vvvv -c ssh
Using /etc/ansible/ansible.cfg as config file
SSH password: 
Loaded callback default of type stdout, v2.0

PLAYBOOK: test3 ****************************************************************
1 plays in test3

PLAY [some tests] **************************************************************

TASK [do reload in case of "catting off"] **************************************
task path: /etc/ansible/test3:9
<192.168.0.33> ESTABLISH SSH CONNECTION FOR USER: admin
<192.168.0.33> SSH: EXEC sshpass -d12 ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 192.168.0.33 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476882145.78-139203779538157 `" && echo ansible-tmp-1476882145.78-139203779538157="` echo $HOME/.ansible/tmp/ansible-tmp-1476882145.78-139203779538157 `" ) && sleep 0'"'"''
<192.168.0.33> PUT /tmp/tmpY5qqyW TO "` echo $HOME/.ansible/tmp/ansible-tmp-1476882145.78-139203779538157 `" ) && sleep 0'"/expect
<192.168.0.33> SSH: EXEC sshpass -d12 sftp -o BatchMode=no -b - -C -vvv -o 

ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o User=admin -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[192.168.0.33]'
    fatal: [192.168.0.33]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh", "unreachable": true}
        to retry, use: --limit @/etc/ansible/test3.retry

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

root@Kali:/etc/ansible# ansible-playbook test3 -u admin -k -vvvv -c local
Using /etc/ansible/ansible.cfg as config file
SSH password: 
Loaded callback default of type stdout, v2.0

PLAYBOOK: test3 ****************************************************************
1 plays in test3

PLAY [some tests] **************************************************************

TASK [do reload in case of "catting off"] **************************************
task path: /etc/ansible/test3:9
<192.168.0.33> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.0.33> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809 `" && echo ansible-tmp-1476882426.62-172601217553809="` echo $HOME/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809 `" ) && sleep 0'
<192.168.0.33> PUT /tmp/tmpdq1pYy TO /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect
<192.168.0.33> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/ /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect && sleep 0'
<192.168.0.33> EXEC /bin/sh -c 'LANG=pl_PL.UTF-8 LC_ALL=pl_PL.UTF-8 LC_MESSAGES=pl_PL.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/expect; rm -rf "/root/.ansible/tmp/ansible-tmp-1476882426.62-172601217553809/" > /dev/null 2>&1 && sleep 0'
fatal: [192.168.0.33]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"chdir": null, "command": "reload in 30", "creates": null, "echo": true, "removes": null, "responses": {"Reload scheduled in 30 minutes by admin on vty0 (192.168.253.20)\\nProceed with reload? \\[confirm\\]": "y"}, "timeout": 30}, "module_name": "expect"}, "msg": "The command was not found or was not executable: reload."}

NO MORE HOSTS LEFT *************************************************************
    to retry, use: --limit @/etc/ansible/test3.retry

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


UPDATED

I've installed ansible 2.3 and tried as follows:

  tasks:
    - name: do reload in case of "catting off"
      ios_command:
       commands:
        - reload in 30
        - y
       wait_for:
       - result[0] contains "Proceed with reload"
       provider: "{{ cli }}"

But still, I get an error. I think that this is because ios module always wait for a promt as a response. And additionaly confirmation of reload command is without "Enter" after pressing "y" so this could be another problem.

  $ sudo  ansible-playbook test1.yml -vvvv
    Using /etc/ansible/ansible.cfg as config file
    Loading callback plugin default of type stdout, v2.0 from /usr/local/lib/python2.7/dist-packages/ansible/plugins/callback/__init__.pyc

    PLAYBOOK: test1.yml ************************************************************
    1 plays in test1.yml

    PLAY [testowe dzialania] *******************************************************

    TASK [do reload in case of "catting off"] **************************************
    task path: /home/user1/test1.yml:13
    Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/core/network/ios/ios_command.py
    <192.168.0.33> ESTABLISH LOCAL CONNECTION FOR USER: root
    <192.168.0.33> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324 `" && echo ansible-tmp-1477557527.56-157304653717324="` echo $HOME/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324 `" ) && sleep 0'
    <192.168.0.33> PUT /tmp/tmphf8EWO TO /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ios_command.py
    <192.168.0.33> EXEC /bin/sh -c 'chmod u+x /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ios_command.py && sleep 0'
    <192.168.0.33> EXEC /bin/sh -c '/usr/bin/python /home/mszczesniak/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/ios_command.py; rm -rf "/home/user1/.ansible/tmp/ansible-tmp-1477557527.56-157304653717324/" > /dev/null 2>&1 && sleep 0'
    fatal: [192.168.0.33]: FAILED! => {
        "changed": false,
        "failed": true,
        "invocation": {
            "module_args": {
                "auth_pass": null,
                "authorize": false,
                "commands": [
                    "reload in 30",
                    "y"
                ],
                "host": "192.168.0.33",
                "interval": 1,
                "match": "all",
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                "port": null,
                "provider": {
                    "host": "192.168.0.33",
                    "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                    "username": "admin"
                },
                "retries": 10,
                "ssh_keyfile": null,
                "timeout": 10,
                "transport": null,
                "use_ssl": true,
                "username": "admin",
                "validate_certs": true,
                "wait_for": [
                    "result[0] contains \"Proceed with reload\""
                ]
            },
            "module_name": "ios_command"
        },
        "msg": "timeout trying to send command: reload in 30\r"
    }
            to retry, use: --limit @/home/user1/test1.retry

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

Can anyone have any idea how to resolve that problem in ansible or maby the only way is to use pure python script or write own ansible module?

解决方案

You can use:

- name: reload device
  ios_command:
    commands:
      - "reload in 1\ny"
    provider: "{{ cli }}"

This will reload the device in 1 minute and the reload prompt gets accepted. It works well for ansible because the default prompt of ios will come back (reload gets triggered in 1 minute).

Regards, Simon

这篇关于ansible-cisco IOS和“重新加载”命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆