Code Monkey home page Code Monkey logo

cloudengine-ansible's People

Contributors

gaoliangchuan avatar jackygao2016 avatar justbiaoliu avatar mgysi avatar niochlas avatar panqijun2006 avatar qijunpan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloudengine-ansible's Issues

follow the example,but failed

[root@172e38e211e79 ~]# ansible -m ce_command -a "commands='display vlan summary' transport='cli' host=172.18.215.4 port=22 username=ironic password=agr&4CBG#76" localhost --connection local
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: string indices must be integers, not str
localhost | FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n File "/tmp/ansible_oniuZU/ansible_module_ce_command.py", line 269, in \n main()\n File "/tmp/ansible_oniuZU/ansible_module_ce_command.py", line 204, in main\n supports_check_mode=True)\n File "/tmp/ansible_oniuZU/ansible_modlib.zip/ansible/module_utils/network.py", line 134, in init\n File "/tmp/ansible_oniuZU/ansible_modlib.zip/ansible/module_utils/network.py", line 170, in connect\n File "/tmp/ansible_oniuZU/ansible_modlib.zip/ansible/module_utils/cloudengine.py", line 221, in connect\n File "/tmp/ansible_oniuZU/ansible_modlib.zip/ansible/module_utils/shell.py", line 157, in send\nTypeError: string indices must be integers, not str\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}

ce_facts gather_subset: interfaces id failing on undefined LLDP Neighbor Device nema

On a switch:

<swt1-rlab>dis lldp neigh brief
Local Interface         Exptime(s) Neighbor Interface      Neighbor Device
-------------------------------------------------------------------------------
10GE1/0/1                     110  10GE1/0/9               sw1
10GE1/0/3                     109  14a0-f89b-1f31

Ansible -vvvv:

"module_stderr": "Traceback (most recent call last):
  File "/tmp/ansible_VRO_qt/ansible_module_ce_facts.py", line 403, in <module>
    main()
  File "/tmp/ansible_VRO_qt/ansible_module_ce_facts.py", line 388, in main
    inst.populate()
  File "/tmp/ansible_VRO_qt/ansible_module_ce_facts.py", line 319, in populate
    neighbors_dict[tmp_item[0]] = tmp_item[3]
IndexError: list index out of range",

in modules/network/cloudengine/ce_facts.py 319:

                neighbors_dict[tmp_item[0]] = tmp_item[3]

tmp_item[3] is '' for neighbor device on '10GE1/0/3' and should be handled.
simple patch would be:

diff /usr/local/lib/python2.7/dist-packages/ansible/modules/network/cloudengine/ce_facts.py /usr/local/lib/python2.7/dist-packages/ansible/modules/network/cloudengine/ce_facts.orig.py
319,322c319
<                 if len(tmp_item) > 3:
<                     neighbors_dict[tmp_item[0]] = tmp_item[3]
<                 else:
<                     neighbors_dict[tmp_item[0]] = ''
---
>                 neighbors_dict[tmp_item[0]] = tmp_item[3]

OT: it would be nice to have not only neighbour device in facts, but also o neighbor interface :)

socket.timeout

image

when I use "ansible -m ce_command -a 'host=129.9.80.30 port=22 username=ansible password=Admin@123 commands="display version"' localhost --connection local -vvvv" , error occur

配置模块显示Authentication timeout.

交换机使用的是华为CE6851HI V100R005C10SPC200
python 2.7
ansible 2.7.8

交换机配置了snetconf server enable
现在使用ce_command模块正常,但是使用配置类模块就有问题,报错Authentication timeout,报错如下:

➜ Huawei-ce ansible -m ce_command -a "commands='display vlan summary' transport='cli' host=183.x.x.x port=xx username=xxxx password=xxxx" localhost --connection local
[DEPRECATION WARNING]: Param 'username' is deprecated. See the module docs for more information. This feature will be
removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Param 'password' is deprecated. See the module docs for more information. This feature will be
removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Param 'host' is deprecated. See the module docs for more information. This feature will be
removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Param 'transport' is deprecated. See the module docs for more information. This feature will
be removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: Param 'port' is deprecated. See the module docs for more information. This feature will be
removed in version 2.9. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
localhost | SUCCESS => {
"changed": false,
"stdout": [
"Number of static VLAN: 7\nVLAN ID: 1 100 1000 4000 to 4003 \n\nNumber of dynamic VLAN: 0\nVLAN ID: \n\nNumber of service VLAN: 31\nVLAN ID: 4064 to 4094"
],
"stdout_lines": [
[
"Number of static VLAN: 7",
"VLAN ID: 1 100 1000 4000 to 4003 ",
"",
"Number of dynamic VLAN: 0",
"VLAN ID: ",
"",
"Number of service VLAN: 31",
"VLAN ID: 4064 to 4094"
]
]
}
➜ Huawei-ce ansible -m ce_vlan -a "vlan_id=19 state=present transport='cli' host=183.x.x.x.x port=xx username=xxx password=xxxx" localhost --connection local
localhost | FAILED! => {
"msg": "AuthenticationException('Authentication timeout.',)"
}

➜ Huawei-ce ansible -m ce_vlan -a "vlan_id=19 state=present transport='cli' host=183.240.14.161 port=22 username=wangxc password=Zhzhdwy1234^" localhost --connection local -vvvv

ansible 2.7.8
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/Users/one/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Python/2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.10 (default, Oct 6 2017, 22:29:07) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading callback plugin minimal of type stdout, v2.0 from /Library/Python/2.7/site-packages/ansible/plugins/callback/minimal.pyc
META: ran handlers
<127.0.0.1> connection transport is cli
<183.> using connection plugin netconf (was local)
<183.> starting connection from persistent connection plugin
<183.> local domain socket does not exist, starting it
<183.> control socket path is /Users/one/.ansible/pc/0558f6143b
<183.>
The full traceback is:
Traceback (most recent call last):
File "/usr/local/bin/ansible-connection", line 106, in start
self.connection._connect()
File "/Library/Python/2.7/site-packages/ansible/plugins/connection/netconf.py", line 299, in _connect
ssh_config=ssh_config
File "/Library/Python/2.7/site-packages/ncclient/manager.py", line 163, in connect
return connect_ssh(*args, **kwds)
File "/Library/Python/2.7/site-packages/ncclient/manager.py", line 128, in connect_ssh
session.connect(*args, **kwds)
File "/Library/Python/2.7/site-packages/ncclient/transport/ssh.py", line 460, in connect
self._auth(username, password, key_filenames, allow_agent, look_for_keys)
File "/Library/Python/2.7/site-packages/ncclient/transport/ssh.py", line 559, in _auth
raise AuthenticationError(repr(saved_exception))
AuthenticationError: AuthenticationException('Authentication timeout.',)

localhost | FAILED! => {
"msg": "AuthenticationException('Authentication timeout.',)"
}

望解答,谢谢

Cant use these modules to configure switch

Hi!

I have set up a specific account to use for configuration from ansible. But I fail to login using the module.

When I do a ssh connection manually it works just fine. But when I try with any of your modules it fails with:
"msg": "unable to open shell. Please see: https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell"

And the switch logs says:
%%01SSH/5/SSH_USER_LOGIN_FAIL(s):CID=0x80932722;The SSH user failed to login. (ServiceType=**, FailedReason=TCP disconnect from client, UserName=Could not extract user name, IPAddress=172.18.10.10, VPNInstanceName=MGMT.)

执行测试命令报unable to open shell

[root@10-57-22-79 ansible]# cat ~/ansible.log
2017-12-20 22:24:30,086 p=15733 u=root | 15733 1513826670.08578: starting run
2017-12-20 22:24:30,214 p=15733 u=root | No config file found; using defaults
2017-12-20 22:24:30,216 p=15733 u=root | 15733 1513826670.21614: Loading CacheModule 'memory' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/cache/memory.py
2017-12-20 22:24:30,261 p=15733 u=root | 15733 1513826670.26117: Loading CallbackModule 'minimal' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/minimal.py
2017-12-20 22:24:30,261 p=15733 u=root | Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/init.pyc
2017-12-20 22:24:30,262 p=15733 u=root | 15733 1513826670.26265: Loading CallbackModule 'actionable' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/actionable.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,263 p=15733 u=root | 15733 1513826670.26296: Loading CallbackModule 'context_demo' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/context_demo.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,263 p=15733 u=root | 15733 1513826670.26330: Loading CallbackModule 'debug' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/debug.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,263 p=15733 u=root | 15733 1513826670.26365: Loading CallbackModule 'default' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/default.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,264 p=15733 u=root | 15733 1513826670.26405: Loading CallbackModule 'dense' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/dense.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,264 p=15733 u=root | 15733 1513826670.26448: Loading CallbackModule 'foreman' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/foreman.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,268 p=15733 u=root | 15733 1513826670.26839: Loading CallbackModule 'hipchat' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/hipchat.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,268 p=15733 u=root | 15733 1513826670.26886: Loading CallbackModule 'jabber' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/jabber.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,269 p=15733 u=root | 15733 1513826670.26917: Loading CallbackModule 'json' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/json.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,269 p=15733 u=root | 15733 1513826670.26959: Loading CallbackModule 'junit' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/junit.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,269 p=15733 u=root | 15733 1513826670.26993: Loading CallbackModule 'log_plays' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/log_plays.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,270 p=15733 u=root | 15733 1513826670.27044: Loading CallbackModule 'logentries' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/logentries.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,270 p=15733 u=root | 15733 1513826670.27087: Loading CallbackModule 'logstash' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/logstash.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,274 p=15733 u=root | 15733 1513826670.27460: Loading CallbackModule 'mail' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/mail.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,274 p=15733 u=root | 15733 1513826670.27481: Loading CallbackModule 'minimal' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/minimal.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,275 p=15733 u=root | 15733 1513826670.27509: Loading CallbackModule 'oneline' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/oneline.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,275 p=15733 u=root | 15733 1513826670.27554: Loading CallbackModule 'osx_say' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/osx_say.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,275 p=15733 u=root | 15733 1513826670.27586: Loading CallbackModule 'profile_tasks' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/profile_tasks.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,276 p=15733 u=root | 15733 1513826670.27623: Loading CallbackModule 'selective' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/selective.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,276 p=15733 u=root | 15733 1513826670.27646: Loading CallbackModule 'skippy' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/skippy.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,276 p=15733 u=root | 15733 1513826670.27687: Loading CallbackModule 'slack' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/slack.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,277 p=15733 u=root | 15733 1513826670.27786: Loading CallbackModule 'syslog_json' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/syslog_json.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,278 p=15733 u=root | 15733 1513826670.27810: Loading CallbackModule 'timer' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/timer.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,278 p=15733 u=root | 15733 1513826670.27841: Loading CallbackModule 'tree' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/callback/tree.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,278 p=15733 u=root | 15733 1513826670.27853: in VariableManager get_vars()
2017-12-20 22:24:30,296 p=15733 u=root | 15733 1513826670.29684: Loading FilterModule 'core' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/core.py
2017-12-20 22:24:30,297 p=15733 u=root | 15733 1513826670.29745: Loading FilterModule 'ipaddr' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/ipaddr.py
2017-12-20 22:24:30,299 p=15733 u=root | 15733 1513826670.29980: Loading FilterModule 'json_query' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/json_query.py
2017-12-20 22:24:30,300 p=15733 u=root | 15733 1513826670.30014: Loading FilterModule 'mathstuff' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/mathstuff.py
2017-12-20 22:24:30,302 p=15733 u=root | 15733 1513826670.30197: Loading TestModule 'core' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/test/core.py
2017-12-20 22:24:30,302 p=15733 u=root | 15733 1513826670.30222: Loading TestModule 'files' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/test/files.py
2017-12-20 22:24:30,302 p=15733 u=root | 15733 1513826670.30243: Loading TestModule 'mathstuff' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/test/mathstuff.py
2017-12-20 22:24:30,305 p=15733 u=root | 15733 1513826670.30531: done with get_vars()
2017-12-20 22:24:30,330 p=15733 u=root | 15733 1513826670.33000: Loading StrategyModule 'linear' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/strategy/linear.py
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33197: getting the remaining hosts for this loop
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33217: done getting the remaining hosts for this loop
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33229: building list of next tasks for hosts
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33238: getting the next task for host localhost
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33249: done getting next task for host localhost
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33261: ^ task is: TASK: meta (flush_handlers)
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33277: ^ state is: HOST STATE: block=1, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
2017-12-20 22:24:30,332 p=15733 u=root | 15733 1513826670.33291: done building task lists
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33303: counting tasks in each state of execution
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33312: done counting tasks in each state of execution:
num_setups: 0
num_tasks: 1
num_rescue: 0
num_always: 0
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33325: advancing hosts in ITERATING_TASKS
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33332: starting to advance hosts
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33340: getting the next task for host localhost
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33349: done getting next task for host localhost
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33357: ^ task is: TASK: meta (flush_handlers)
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33371: ^ state is: HOST STATE: block=1, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
2017-12-20 22:24:30,333 p=15733 u=root | 15733 1513826670.33383: done advancing hosts to next task
2017-12-20 22:24:30,338 p=15733 u=root | META: ran handlers
2017-12-20 22:24:30,338 p=15733 u=root | 15733 1513826670.33854: done queuing things up, now waiting for results queue to drain
2017-12-20 22:24:30,338 p=15733 u=root | 15733 1513826670.33865: results queue empty
2017-12-20 22:24:30,338 p=15733 u=root | 15733 1513826670.33876: checking for any_errors_fatal
2017-12-20 22:24:30,338 p=15733 u=root | 15733 1513826670.33885: done checking for any_errors_fatal
2017-12-20 22:24:30,338 p=15733 u=root | 15733 1513826670.33893: checking for max_fail_percentage
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33902: done checking for max_fail_percentage
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33911: checking to see if all hosts have failed and the running result is not ok
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33919: done checking to see if all hosts have failed
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33927: getting the remaining hosts for this loop
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33935: done getting the remaining hosts for this loop
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33945: building list of next tasks for hosts
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33953: getting the next task for host localhost
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33963: done getting next task for host localhost
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33974: ^ task is: TASK: ce_command
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33983: ^ state is: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
2017-12-20 22:24:30,339 p=15733 u=root | 15733 1513826670.33992: done building task lists
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34000: counting tasks in each state of execution
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34008: done counting tasks in each state of execution:
num_setups: 0
num_tasks: 1
num_rescue: 0
num_always: 0
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34018: advancing hosts in ITERATING_TASKS
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34026: starting to advance hosts
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34034: getting the next task for host localhost
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34043: done getting next task for host localhost
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34052: ^ task is: TASK: ce_command
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34061: ^ state is: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34077: done advancing hosts to next task
2017-12-20 22:24:30,340 p=15733 u=root | 15733 1513826670.34091: getting variables
2017-12-20 22:24:30,341 p=15733 u=root | 15733 1513826670.34101: in VariableManager get_vars()
2017-12-20 22:24:30,341 p=15733 u=root | 15733 1513826670.34150: Loading FilterModule 'core' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/core.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,341 p=15733 u=root | 15733 1513826670.34161: Loading FilterModule 'ipaddr' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/ipaddr.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,341 p=15733 u=root | 15733 1513826670.34172: Loading FilterModule 'json_query' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/json_query.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,341 p=15733 u=root | 15733 1513826670.34184: Loading FilterModule 'mathstuff' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/filter/mathstuff.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,342 p=15733 u=root | 15733 1513826670.34212: Loading TestModule 'core' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/test/core.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,342 p=15733 u=root | 15733 1513826670.34224: Loading TestModule 'files' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/test/files.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,342 p=15733 u=root | 15733 1513826670.34233: Loading TestModule 'mathstuff' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/test/mathstuff.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,343 p=15733 u=root | 15733 1513826670.34332: done with get_vars()
2017-12-20 22:24:30,343 p=15733 u=root | 15733 1513826670.34352: done getting variables
2017-12-20 22:24:30,343 p=15733 u=root | 15733 1513826670.34365: sending task start callback, copying the task so we can template it temporarily
2017-12-20 22:24:30,343 p=15733 u=root | 15733 1513826670.34380: done copying, going to template now
2017-12-20 22:24:30,343 p=15733 u=root | 15733 1513826670.34393: done templating
2017-12-20 22:24:30,344 p=15733 u=root | 15733 1513826670.34401: here goes the callback...
2017-12-20 22:24:30,344 p=15733 u=root | 15733 1513826670.34414: sending task start callback
2017-12-20 22:24:30,344 p=15733 u=root | 15733 1513826670.34423: entering _queue_task() for localhost/ce_command
2017-12-20 22:24:30,344 p=15733 u=root | 15733 1513826670.34432: Creating lock for ce_command
2017-12-20 22:24:30,346 p=15733 u=root | 15733 1513826670.34575: worker is 1 (out of 1 available)
2017-12-20 22:24:30,346 p=15733 u=root | 15733 1513826670.34652: exiting _queue_task() for localhost/ce_command
2017-12-20 22:24:30,346 p=15733 u=root | 15733 1513826670.34678: done queuing things up, now waiting for results queue to drain
2017-12-20 22:24:30,346 p=15733 u=root | 15733 1513826670.34690: waiting for pending results...
2017-12-20 22:24:30,350 p=15733 u=root | 15741 1513826670.35018: running TaskExecutor() for localhost/TASK: ce_command
2017-12-20 22:24:30,350 p=15733 u=root | 15741 1513826670.35089: in run() - task fa11b077-a300-741b-a405-000000000006
2017-12-20 22:24:30,351 p=15733 u=root | 15741 1513826670.35137: calling self._execute()
2017-12-20 22:24:30,356 p=15733 u=root | 15741 1513826670.35642: Loading Connection 'local' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/connection/local.py
2017-12-20 22:24:30,357 p=15733 u=root | 15741 1513826670.35704: Loading ShellModule 'csh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/csh.py
2017-12-20 22:24:30,357 p=15733 u=root | 15741 1513826670.35745: Loading ShellModule 'fish' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/fish.py
2017-12-20 22:24:30,358 p=15733 u=root | 15741 1513826670.35810: Loading ShellModule 'powershell' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/powershell.py
2017-12-20 22:24:30,358 p=15733 u=root | 15741 1513826670.35847: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py
2017-12-20 22:24:30,359 p=15733 u=root | 15741 1513826670.35891: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,402 p=15733 u=root | 15741 1513826670.40263: Loading ActionModule 'ce' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/action/ce.py
2017-12-20 22:24:30,402 p=15733 u=root | 15741 1513826670.40294: starting attempt loop
2017-12-20 22:24:30,403 p=15733 u=root | 15741 1513826670.40306: running the handler
2017-12-20 22:24:30,404 p=15733 u=root | 15741 1513826670.40428: Loading Connection 'persistent' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/connection/persistent.py
2017-12-20 22:24:30,404 p=15733 u=root | 15741 1513826670.40459: Loading ShellModule 'csh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/csh.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,404 p=15733 u=root | 15741 1513826670.40475: Loading ShellModule 'fish' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/fish.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,404 p=15733 u=root | 15741 1513826670.40490: Loading ShellModule 'powershell' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/powershell.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,405 p=15733 u=root | 15741 1513826670.40506: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,405 p=15733 u=root | 15741 1513826670.40521: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,405 p=15733 u=root | 15741 1513826670.40585: Loading Connection 'ssh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/connection/ssh.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,605 p=15742 u=root | 15742 1513826670.60514: Loading Connection 'ssh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/connection/ssh.py (found_in_cache=False, class_only=True)
2017-12-20 22:24:30,608 p=15742 u=root | creating new control socket for host 172.16.200.6:22 as user shanfu.wu
2017-12-20 22:24:30,608 p=15742 u=root | control socket path is /root/.ansible/pc/0ebb0f6ca7
2017-12-20 22:24:30,609 p=15742 u=root | current working directory is /etc/ansible
2017-12-20 22:24:30,609 p=15742 u=root | using connection plugin network_cli
15748 1513826670.63937: Loading Connection 'network_cli' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/connection/network_cli.py
2017-12-20 22:24:30,639 p=15742 u=root | 15748 1513826670.63937: Loading Connection 'network_cli' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/connection/network_cli.py
15748 1513826670.64084: Loading ShellModule 'csh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/csh.py
2017-12-20 22:24:30,640 p=15742 u=root | 15748 1513826670.64084: Loading ShellModule 'csh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/csh.py
15748 1513826670.64123: Loading ShellModule 'fish' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/fish.py
2017-12-20 22:24:30,641 p=15742 u=root | 15748 1513826670.64123: Loading ShellModule 'fish' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/fish.py
15748 1513826670.64182: Loading ShellModule 'powershell' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/powershell.py
2017-12-20 22:24:30,641 p=15742 u=root | 15748 1513826670.64182: Loading ShellModule 'powershell' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/powershell.py
15748 1513826670.64206: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py
2017-12-20 22:24:30,642 p=15742 u=root | 15748 1513826670.64206: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py
15748 1513826670.64235: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,642 p=15742 u=root | 15748 1513826670.64235: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
2017-12-20 22:24:30,796 paramiko.transport starting thread (client mode): 0x19cb7d0L
2017-12-20 22:24:30,797 paramiko.transport Local version/idstring: SSH-2.0-paramiko_2.1.1
2017-12-20 22:24:31,002 paramiko.transport Remote version/idstring: SSH-2.0--
2017-12-20 22:24:31,003 paramiko.transport Connected (version 2.0, client -)
2017-12-20 22:24:31,006 paramiko.transport kex algos:[u'diffie-hellman-group1-sha1', u'ecdh-sha2-nistp521', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp256', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group-exchange-sha1', u'sm2kep-sha2-nistp256'] server key:[u'ssh-dss', u'ssh-rsa', u'ecdsa-sha2-nistp521'] client encrypt:[u'aes256-ctr', u'aes128-ctr', u'aes256-cbc', u'aes128-cbc', u'blowfish-cbc', u'3des-cbc'] server encrypt:[u'aes256-ctr', u'aes128-ctr', u'aes256-cbc', u'aes128-cbc', u'blowfish-cbc', u'3des-cbc'] client mac:[u'hmac-sha2-256', u'hmac-sha2-256-96', u'hmac-sha1', u'hmac-sha1-96'] server mac:[u'hmac-sha2-256', u'hmac-sha2-256-96', u'hmac-sha1', u'hmac-sha1-96'] client compress:[u'none', u'zlib'] server compress:[u'none', u'zlib'] client lang:[u''] server lang:[u''] kex follows?False
2017-12-20 22:24:31,006 paramiko.transport Kex agreed: diffie-hellman-group1-sha1
2017-12-20 22:24:31,006 paramiko.transport Cipher agreed: aes128-ctr
2017-12-20 22:24:31,007 paramiko.transport MAC agreed: hmac-sha2-256
2017-12-20 22:24:31,007 paramiko.transport Compression agreed: none
2017-12-20 22:24:31,293 paramiko.transport kex engine KexGroup1 specified hash_algo
2017-12-20 22:24:31,293 paramiko.transport Switch to new keys ...
2017-12-20 22:24:31,298 p=15742 u=root | connecting to host 172.16.200.6 returned an error
2017-12-20 22:24:31,298 p=15742 u=root | (14, 'Bad address')
2017-12-20 22:24:31,394 paramiko.transport EOF in transport thread
2017-12-20 22:25:00,637 p=15742 u=root | number of connection attempts exceeded, unable to connect to control socket
2017-12-20 22:25:00,637 p=15742 u=root | persistent_connect_interval=1, persistent_connect_retries=30
2017-12-20 22:25:00,653 p=15733 u=root | open_shell() returned 255 15742 1513826670.60514: Loading Connection 'ssh' from /usr/lib/python2.7/site-packages/ansible-2.3.3.0-py2.7.egg/ansible/plugins/connection/ssh.py (found_in_cache=False, class_only=True)
failed to connect to control socket
2017-12-20 22:25:00,654 p=15733 u=root | 15741 1513826700.65419: handler run complete
2017-12-20 22:25:00,654 p=15733 u=root | 15741 1513826700.65438: attempt loop complete, returning result
2017-12-20 22:25:00,654 p=15733 u=root | 15741 1513826700.65450: _execute() done
2017-12-20 22:25:00,654 p=15733 u=root | 15741 1513826700.65461: dumping result to json
2017-12-20 22:25:00,654 p=15733 u=root | 15741 1513826700.65476: done dumping result, returning
2017-12-20 22:25:00,655 p=15733 u=root | 15741 1513826700.65497: done running TaskExecutor() for localhost/TASK: ce_command [fa11b077-a300-741b-a405-000000000006]
2017-12-20 22:25:00,655 p=15733 u=root | 15741 1513826700.65516: sending task result for task fa11b077-a300-741b-a405-000000000006
2017-12-20 22:25:00,656 p=15733 u=root | 15741 1513826700.65569: done sending task result for task fa11b077-a300-741b-a405-000000000006
2017-12-20 22:25:00,656 p=15733 u=root | 15741 1513826700.65612: WORKER PROCESS EXITING
2017-12-20 22:25:00,657 p=15733 u=root | 15733 1513826700.65747: marking localhost as failed
2017-12-20 22:25:00,657 p=15733 u=root | 15733 1513826700.65780: marking host localhost failed, current state: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
2017-12-20 22:25:00,658 p=15733 u=root | 15733 1513826700.65795: ^ failed state is now: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_COMPLETE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
2017-12-20 22:25:00,658 p=15733 u=root | 15733 1513826700.65807: getting the next task for host localhost
2017-12-20 22:25:00,658 p=15733 u=root | 15733 1513826700.65820: host localhost is done iterating, returning
2017-12-20 22:25:00,658 p=15733 u=root | localhost | FAILED! => {
"changed": false,
"failed": true,
"msg": "unable to open shell. Please see: https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell",
"rc": 255
}
2017-12-20 22:25:00,658 p=15733 u=root | 15733 1513826700.65861: no more pending results, returning what we have
2017-12-20 22:25:00,658 p=15733 u=root | 15733 1513826700.65879: results queue empty
2017-12-20 22:25:00,658 p=15733 u=root | 15733 1513826700.65892: checking for any_errors_fatal
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65901: done checking for any_errors_fatal
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65912: checking for max_fail_percentage
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65919: done checking for max_fail_percentage
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65928: checking to see if all hosts have failed and the running result is not ok
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65936: done checking to see if all hosts have failed
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65945: getting the remaining hosts for this loop
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65958: done getting the remaining hosts for this loop
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65970: building list of next tasks for hosts
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65981: getting the next task for host localhost
2017-12-20 22:25:00,659 p=15733 u=root | 15733 1513826700.65990: host localhost is done iterating, returning
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.65998: done building task lists
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66005: counting tasks in each state of execution
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66013: done counting tasks in each state of execution:
num_setups: 0
num_tasks: 0
num_rescue: 0
num_always: 0
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66021: all hosts are done, so returning None's for all hosts
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66029: done queuing things up, now waiting for results queue to drain
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66037: results queue empty
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66047: checking for any_errors_fatal
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66056: done checking for any_errors_fatal
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66064: checking for max_fail_percentage
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66075: done checking for max_fail_percentage
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66085: checking to see if all hosts have failed and the running result is not ok
2017-12-20 22:25:00,660 p=15733 u=root | 15733 1513826700.66093: done checking to see if all hosts have failed
2017-12-20 22:25:00,661 p=15733 u=root | 15733 1513826700.66103: getting the next task for host localhost
2017-12-20 22:25:00,661 p=15733 u=root | 15733 1513826700.66111: host localhost is done iterating, returning
2017-12-20 22:25:00,661 p=15733 u=root | 15733 1513826700.66119: running handlers
2017-12-20 22:25:00,661 p=15733 u=root | 15733 1513826700.66191: RUNNING CLEANUP

Can not connect to CloudEngine switch

Hello,
This is a test environment so please disregard 'running as root' stuff...

Here are the basic facts:
(ansible) root@debian871:~/Envs/ansible/project# cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"

(ansible) root@debian871:~# pip freeze
ansible==2.2.1.0
appdirs==1.4.0
cffi==1.9.1
cryptography==1.7.2
enum34==1.1.6
idna==2.2
ipaddress==1.0.18
Jinja2==2.8.1
lxml==3.7.2
MarkupSafe==0.23
ncclient==0.5.3
packaging==16.8
paramiko==2.1.1
pyasn1==0.1.9
pycparser==2.17
pycrypto==2.6.1
pyparsing==2.1.10
PyYAML==3.12
six==1.10.0

(ansible) root@debian871:~/Envs/ansible/project# cat ansible.cfg
[defaults]
remote_user = ansible
private_key_file=/root/.ssh/id_rsa
host_key_checking=False

This is my test.yml

  • hosts: all
    gather_facts: False
    tasks:
    • name: Get VLANs
      ce_command: command='display vlan brief' transport='cli'

Using module file /root/Envs/ansible/local/lib/python2.7/site-packages/ansible/modules/extras/network/huawei/ce_command.py
<10.197.255.41> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.197.255.41> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.197.255.41 '/bin/sh -c '"'"'( umask 77 && mkdir -p "echo ~/.ansible/tmp/ansible-tmp-1487018853.48-126438048573282" && echo ansible-tmp-1487018853.48-126438048573282="echo ~/.ansible/tmp/ansible-tmp-1487018853.48-126438048573282" ) && sleep 0'"'"''
fatal: [10.197.255.41]: UNREACHABLE! => {

ssh works manually but if I omit the '/bin/sh...' part:

So this works:
ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o 'IdentityFile="/root/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r 10.197.255.41

Any help appreciated.

关于安装ansible的疑问

您好,麻烦问一下,现在下载安装最新版本的ansible,是否还需要别的配置 ?是不是可以直接调用ce模块,看新版本里面有ce模块呢

Authorization Failure using "ce_interface" Module

  1. The following Ansible code did not work,
#  - name: Set Something 2
#    ce_interface:
#     interface: "25GE1/1/15"
#     desscription: "Testing"
#     provider: "{{ cli }}"
#     transport: cli
  1. Error thrown from the above code,
The full traceback is:
Traceback (most recent call last):
  File "/bin/ansible-connection", line 104, in start
    self.connection._connect()
  File "/usr/lib/python2.7/site-packages/ansible/plugins/connection/netconf.py", line 322, in _connect
    ssh_config=ssh_config
  File "/usr/lib/python2.7/site-packages/ncclient/manager.py", line 177, in connect
    return connect_ssh(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/ncclient/manager.py", line 143, in connect_ssh
    session.connect(*args, **kwds)
  File "/usr/lib/python2.7/site-packages/ncclient/transport/ssh.py", line 491, in connect
    self._auth(username, password, key_filenames, allow_agent, look_for_keys)
  File "/usr/lib/python2.7/site-packages/ncclient/transport/ssh.py", line 590, in _auth
    raise AuthenticationError(repr(saved_exception))
AuthenticationError: AuthenticationException('Authentication failed.',)

fatal: [localhost]: FAILED! => {
    "msg": "AuthenticationException('Authentication failed.',)"
}
  1. Appreciate any thoughts. Thanks!

提示错误但没有任何报错

Huawei-ce one$ ansible -m ce_command -a "commands='display startup' transport='cli' host=xxx port=22 username=xxx password=xxx" localhost --connection local
以下是输出,没有错误信息

localhost | FAILED! => {
"msg": ""
}

Failure when trying to configure BGP EVPN Neighbor in ce_bgp_neighbor_af.py

When trying to configure a BGP peer with address-family evpn.

- name: "Configure BGP peer(s) on EVPN address-family"
  ce_bgp_neighbor_af:
    state: present
    remote_address: "192.168.1.2"
    af_type: "evpn"
    vrf_name: _public_
    provider: "{{ cli }}"

I get the following error

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: UnboundLocalError: local variable 'cmd' referenced before assignment
failed: [x.x.x.x] (item={'value': {u'local_if_name': u'100GE1/0/3', u'remote_as': 65001}, 'key': u'192.168.1.2'}) => {"changed": false, "item": {"key": "192.168.1.2", "value": {"local_if_name": "100GE1/0/3", "remote_as": 65001}}, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_UVozq5/ansible_module_ce_bgp_neighbor_af.py\", line 2584, in <module>\n    main()\n  File \"/tmp/ansible_UVozq5/ansible_module_ce_bgp_neighbor_af.py\", line 2528, in main\n    cmd = ce_bgp_peer_af_obj.merge_bgp_peer_af(module=module)\n  File \"/tmp/ansible_UVozq5/ansible_module_ce_bgp_neighbor_af.py\", line 1784, in merge_bgp_peer_af\n    cmds.append(cmd)\nUnboundLocalError: local variable 'cmd' referenced before assignment\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 245}

It looks like there is a missing statement for the EVPN address family, in ce_bgp_neighbor_af.py

        cmds = []
        if af_type == "ipv4uni":
            cmd = "ipv4-family unicast"
        elif af_type == "ipv4multi":
            cmd = "ipv4-family multicast"
        elif af_type == "ipv6uni":
            cmd = "ipv6-family unicast"
        cmds.append(cmd)
        cmd = "peer %s" % remote_address
        cmds.append(cmd)

ce_mtu fails with "Error: Interface does not exist."

When trying to configure interface mtu using ce_mtu it fails with the error:

Error: Interface does not exist.

I am using this configuration:

- name: "Configure jumbo frames and MTU on interface"
  ce_mtu:
    interface: 100GE1/0/1
    jumbo_max: 9216
    jumbo_min: 1518
    mtu: 9000
    provider: "{{ cli }}"

Fail when use ce_bgp.py to create a new process on CE switch

when I try to create a new bgp process on CE switch use ce_bgp.py , error occur:

=======================================================
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_Cn1iX4/ansible_module_ce_bgp.py", line 2356, in
main()
File "/tmp/ansible_Cn1iX4/ansible_module_ce_bgp.py", line 2172, in main
asnumber_exist = bgp_enable_exist[0][0]
IndexError: list index out of range
fatal: [129.9.80.30]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File "/tmp/ansible_Cn1iX4/ansible_module_ce_bgp.py", line 2356, in \n main()\n File "/tmp/ansible_Cn1iX4/ansible_module_ce_bgp.py", line 2172, in main\n asnumber_exist = bgp_enable_exist[0][0]\nIndexError: list index out of range\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 245
}
to retry, use: --limit @/usr/huawei_ansible/set_leaf.retry

the error seems about bgp_enable_exist[0][0] list index out of range in ce_bgp.py line 2172:

image

about get_bgp_enable function:
image

seems not correct

the netconf result is:
image

ssh keys are not used with netconf connections

I'm using ssh keys to manage huawei CE switches. However module ce_startup is failing because the netconf module is not configured to use ssh connection.
I trace the bug to: module_utils/network/cloudengine/ce.py (ansible 2.5), and to patch this:

<     'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE'])),
334,337c333,334
<                                       allow_agent=True,
<                                       look_for_keys=True,
<                                       ssh_config=True,
<                                       key_filename='/path/to/private/key/defined/in/variable/ansible_private_key_file/in/ansible/hosts',
---
>                                       allow_agent=False,
>                                       look_for_keys=False,

key_filename should be defined by variable ansible_private_key_file from ansible modules, however i do not know the correct way to populate the value, so I leave it to you ;).

Error "unable to set terminal parameters" with RSA-auth

ansible.cfg

host_key_checking = False
private_key_file = /huawei_priv_rsa
remote_user = userrsa

/playbooks/huawei2.yml

- name: CloudEngine command test
  hosts: test
  connection: local
  gather_facts: no
  vars:
    cli:
      host: "{{ inventory_hostname }}"
      port: "22"
#      username: "{{ username }}"
#      password: "{{ password }}"
      transport: cli

  tasks:
  - name: "Run display version on remote devices"
    ce_command:
      commands:
        - display version
      provider: "{{ cli }}"
    register: diver
  - name: Debug registered var
    debug: var=diver.stdout_lines

关于登录方式的疑问

请问模块支持通过telnet登录吗?
似乎没有模块支持reset saved-configuration,如果使用command的话没办法支持交互啊

ce_facts failed : start tag expected, '<' not found, line 1, column 1 (line 1).

OS version: Redhat 7.4
Ansible Version: 2.7.5
Python Version: 2.7.5
ansible huawei -m ce_facts -a "gather_subset=config"

1.1.1.1 | FAILED! => {
"changed": false,
"msg": "Command: display version, start tag expected, '<' not found, line 1, column 1 (line 1)."

cfg_file in ce_startup have the same problem. Other modules, ce_vlan, works fine.

"msg": "Error: Could not open connection, possibly due to unacceptable SSH subsystem name."

use ce_command module is success, but use other module is failed!
`ansible -m ce_command -a "commands='display vlan summary' transport='cli' host=10.x.x.x port=22 username=admintest password=Huawei@123" localhost --connection local

localhost | SUCCESS => {
"changed": false,
"stdout": [
"Number of static VLAN: 4\nVLAN ID: 1 101 201 to 202 \n\nNumber of dynamic VLAN: 0\nVLAN ID: \n\nNumber of service VLAN: 42\nVLAN ID: 4000 to 4010 4064 to 4094"
],
"stdout_lines": [
[
"Number of static VLAN: 4",
"VLAN ID: 1 101 201 to 202 ",
"",
"Number of dynamic VLAN: 0",
"VLAN ID: ",
"",
"Number of service VLAN: 42",
"VLAN ID: 4000 to 4010 4064 to 4094"
]
]
}`

`ansible -m ce_vlan -a "vlan_id='203' transport='cli' host=10.x.x.x port=22 username=admintest password=Huawei@123" localhost --connection local

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SSHError: Could not open connection, possibly due to unacceptable SSH subsystem name.
localhost | FAILED! => {
"changed": false,
"msg": "Error: Could not open connection, possibly due to unacceptable SSH subsystem name."
}`

错误“”没有可用的身份验证方法“”

报错信息如下:
2017-11-14 15:48:37,935 p=31923 u=root | task path: /root/switch/acl.yml:13
2017-11-14 15:48:38,819 p=31935 u=root | creating new control socket for host 192.168.30.239:22 as user root
2017-11-14 15:48:38,820 p=31935 u=root | control socket path is /root/.ansible/pc/6b4bcad4f6
2017-11-14 15:48:38,820 p=31935 u=root | current working directory is /root/switch
2017-11-14 15:48:38,820 p=31935 u=root | using connection plugin network_cli
2017-11-14 15:48:42,075 p=31935 u=root | connecting to host 192.168.30.239 returned an error
2017-11-14 15:48:42,075 p=31935 u=root | Authentication failed.

我的yml文件是这样定义的

  • name: CloudEngine acl test
    hosts: leaf
    connection: local
    gather_facts: no
    vars:
    cli:
    host: "{{ inventory_hostname }}"
    port: "{{ ansible_ssh_port }}"
    username: "{{ username }}"
    transport: cli
    用密码去验证定义一个password。
    我可以定义用密码去验证,但是我的交换机都配置了公钥。可以通过秘钥去验证
    通过秘钥去验证的话,用什么命令写在文件里
    而且管理机下known_hosts里有交换机的公钥了

执行ce_command的时候没有问题了,调用其它模块还是不行

[root@localhost bao]# ansible -m ce_vlan -a "commands='vlan_id=19 state=present' transport='cli' host=192.168.30.239 port=22 username=lingjingwei password=asd123... " localhost --connection local
/usr/lib64/python2.6/site-packages/cryptography/init.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. The next version of cryptography will drop support for Python 2.6
DeprecationWarning
localhost | FAILED! => {
"changed": false,
"failed": true,
"msg": "Unsupported parameters for (ce_vlan) module: commands. Supported parameters include: description,host,name,password,port,provider,state,timeout,transport,use_ssl,username,validate_certs,vlan_id,vlan_range"
}

Socket error

Hi,

following this guide install is ok:
CloudEngine-Huawei
when trying to execute command as follows: (Using default command in example)

ssh to switch granted and tested through radius user

root@localhost:~# ansible -m ce_command -a "commands='display vlan summary' transport='cli' host=10.100.1.29 port=22 username=blabla password=blabla" localhost --connection local

adaroma@nnoc:~/CloudEngine-Ansible$ ansible -m ce_command -a "commands='display vlan summary' transport='cli' host=10.100.1.29 port=22 username=blabla password=blabla" localhost --connection local -vvv
Using /etc/ansible/ansible.cfg as config file
 [WARNING]: provided hosts list is empty, only localhost is available

META: ran handlers
Using module file /home/adaroma/CloudEngine-Ansible/library/ce_command.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: adaroma
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1497529426.59-123144021550665 `" && echo ansible-tmp-1497529426.59-123144021550665="` echo $HOME/.ansible/tmp/ansible-tmp-1497529426.59-123144021550665 `" ) && sleep 0'
<127.0.0.1> PUT /tmp/tmp3WuXWv TO /home/adaroma/.ansible/tmp/ansible-tmp-1497529426.59-123144021550665/ce_command.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/adaroma/.ansible/tmp/ansible-tmp-1497529426.59-123144021550665/ /home/adaroma/.ansible/tmp/ansible-tmp-1497529426.59-123144021550665/ce_command.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '/usr/bin/python /home/adaroma/.ansible/tmp/ansible-tmp-1497529426.59-123144021550665/ce_command.py; rm -rf "/home/adaroma/.ansible/tmp/ansible-tmp-1497529426.59-123144021550665/" > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_6kOfzf/ansible_module_ce_command.py", line 264, in <module>
    main()
  File "/tmp/ansible_6kOfzf/ansible_module_ce_command.py", line 235, in main
    responses = run_commands(module, commands)
  File "/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/ce.py", line 232, in run_commands
  File "/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/ce.py", line 149, in run_commands
  File "/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/ce.py", line 116, in exec_command
  File "/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/connection.py", line 60, in exec_command
  *File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
TypeError: argument must be string or read-only character buffer, not None*

localhost | FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_6kOfzf/ansible_module_ce_command.py\", line 264, in <module>\n    main()\n  File \"/tmp/ansible_6kOfzf/ansible_module_ce_command.py\", line 235, in main\n    responses = run_commands(module, commands)\n  File \"/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/ce.py\", line 232, in run_commands\n  File \"/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/ce.py\", line 149, in run_commands\n  File \"/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/ce.py\", line 116, in exec_command\n  File \"/tmp/ansible_6kOfzf/ansible_modlib.zip/ansible/module_utils/connection.py\", line 60, in exec_command\n  File \"/usr/lib/python2.7/socket.py\", line 224, in meth\n    return getattr(self._sock,name)(*args)\nTypeError: argument must be string or read-only character buffer, not None\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE", 
    "rc": 0
}

FYI:

ansible --version
ansible 2.3.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/usr/local/lib/python2.7/dist-packages/ansible/modules/']
  python version = 2.7.3 (default, Jun 21 2016, 18:38:19) [GCC 4.7.2]

unable to open shell when using ce_command

您好,我有三种不同的交换机,分别是S5700 V200R003C00SPC300,CE5855EI V100R005C10SPC200以及CE6855HI V200R002C20SPC016T。
我尝试使用ce_command去控制这三台交换机,结果只有s5700这个交换机能被控制其他两台设备都是报了无法打开shell的错误。
在运行ansible之前我已按照《通过Ansible和CE系列交换机实现网络自动化部署.pdf》里所述对交换机进行配置。
详细报错信息如下:
9046 1532594026.04660: starting run
9046 1532594026.16299: Loading CacheModule 'memory' from /usr/lib/python2.7/site-packages/ansible/plugins/cache/memory.py
9046 1532594026.21835: Loading CallbackModule 'minimal' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/minimal.py
9046 1532594026.21957: Loading CallbackModule 'actionable' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/actionable.py (found_in_cache=False, class_only=True)
9046 1532594026.21975: Loading CallbackModule 'context_demo' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/context_demo.py (found_in_cache=False, class_only=True)
9046 1532594026.21991: Loading CallbackModule 'debug' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/debug.py (found_in_cache=False, class_only=True)
9046 1532594026.22018: Loading CallbackModule 'default' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.py (found_in_cache=False, class_only=True)
9046 1532594026.22051: Loading CallbackModule 'dense' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/dense.py (found_in_cache=False, class_only=True)
9046 1532594026.22082: Loading CallbackModule 'foreman' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/foreman.py (found_in_cache=False, class_only=True)
9046 1532594026.22554: Loading CallbackModule 'hipchat' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/hipchat.py (found_in_cache=False, class_only=True)
9046 1532594026.22579: Loading CallbackModule 'jabber' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/jabber.py (found_in_cache=False, class_only=True)
9046 1532594026.22598: Loading CallbackModule 'json' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/json.py (found_in_cache=False, class_only=True)
9046 1532594026.22630: Loading CallbackModule 'junit' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/junit.py (found_in_cache=False, class_only=True)
9046 1532594026.22649: Loading CallbackModule 'log_plays' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/log_plays.py (found_in_cache=False, class_only=True)
9046 1532594026.22686: Loading CallbackModule 'logentries' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/logentries.py (found_in_cache=False, class_only=True)
9046 1532594026.22719: Loading CallbackModule 'logstash' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/logstash.py (found_in_cache=False, class_only=True)
9046 1532594026.23097: Loading CallbackModule 'mail' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/mail.py (found_in_cache=False, class_only=True)
9046 1532594026.23105: Loading CallbackModule 'minimal' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/minimal.py (found_in_cache=False, class_only=True)
9046 1532594026.23123: Loading CallbackModule 'oneline' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/oneline.py (found_in_cache=False, class_only=True)
9046 1532594026.23154: Loading CallbackModule 'osx_say' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/osx_say.py (found_in_cache=False, class_only=True)
9046 1532594026.23178: Loading CallbackModule 'profile_tasks' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/profile_tasks.py (found_in_cache=False, class_only=True)
9046 1532594026.23202: Loading CallbackModule 'selective' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/selective.py (found_in_cache=False, class_only=True)
9046 1532594026.23219: Loading CallbackModule 'skippy' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/skippy.py (found_in_cache=False, class_only=True)
9046 1532594026.23251: Loading CallbackModule 'slack' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/slack.py (found_in_cache=False, class_only=True)
9046 1532594026.23333: Loading CallbackModule 'syslog_json' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/syslog_json.py (found_in_cache=False, class_only=True)
9046 1532594026.23352: Loading CallbackModule 'timer' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/timer.py (found_in_cache=False, class_only=True)
9046 1532594026.23371: Loading CallbackModule 'tree' from /usr/lib/python2.7/site-packages/ansible/plugins/callback/tree.py (found_in_cache=False, class_only=True)
9046 1532594026.23376: in VariableManager get_vars()
9046 1532594026.23390: done with get_vars()
9046 1532594026.27108: Loading StrategyModule 'linear' from /usr/lib/python2.7/site-packages/ansible/plugins/strategy/linear.py
9046 1532594026.27313: getting the remaining hosts for this loop
9046 1532594026.27319: done getting the remaining hosts for this loop
9046 1532594026.27325: building list of next tasks for hosts
9046 1532594026.27329: getting the next task for host localhost
9046 1532594026.27335: done getting next task for host localhost
9046 1532594026.27339: ^ task is: TASK: meta (flush_handlers)
9046 1532594026.27343: ^ state is: HOST STATE: block=1, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
9046 1532594026.27346: done building task lists
9046 1532594026.27349: counting tasks in each state of execution
9046 1532594026.27352: done counting tasks in each state of execution:
num_setups: 0
num_tasks: 1
num_rescue: 0
num_always: 0
9046 1532594026.27356: advancing hosts in ITERATING_TASKS
9046 1532594026.27358: starting to advance hosts
9046 1532594026.27361: getting the next task for host localhost
9046 1532594026.27365: done getting next task for host localhost
9046 1532594026.27371: ^ task is: TASK: meta (flush_handlers)
9046 1532594026.27377: ^ state is: HOST STATE: block=1, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
9046 1532594026.27383: done advancing hosts to next task
9046 1532594026.28117: done queuing things up, now waiting for results queue to drain
9046 1532594026.28127: results queue empty
9046 1532594026.28134: checking for any_errors_fatal
9046 1532594026.28141: done checking for any_errors_fatal
9046 1532594026.28147: checking for max_fail_percentage
9046 1532594026.28154: done checking for max_fail_percentage
9046 1532594026.28160: checking to see if all hosts have failed and the running result is not ok
9046 1532594026.28166: done checking to see if all hosts have failed
9046 1532594026.28171: getting the remaining hosts for this loop
9046 1532594026.28178: done getting the remaining hosts for this loop
9046 1532594026.28188: building list of next tasks for hosts
9046 1532594026.28194: getting the next task for host localhost
9046 1532594026.28209: done getting next task for host localhost
9046 1532594026.28215: ^ task is: TASK: ce_command
9046 1532594026.28219: ^ state is: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
9046 1532594026.28222: done building task lists
9046 1532594026.28225: counting tasks in each state of execution
9046 1532594026.28228: done counting tasks in each state of execution:
num_setups: 0
num_tasks: 1
num_rescue: 0
num_always: 0
9046 1532594026.28232: advancing hosts in ITERATING_TASKS
9046 1532594026.28235: starting to advance hosts
9046 1532594026.28238: getting the next task for host localhost
9046 1532594026.28242: done getting next task for host localhost
9046 1532594026.28246: ^ task is: TASK: ce_command
9046 1532594026.28250: ^ state is: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
9046 1532594026.28253: done advancing hosts to next task
9046 1532594026.28259: getting variables
9046 1532594026.28263: in VariableManager get_vars()
9046 1532594026.28291: done with get_vars()
9046 1532594026.28302: done getting variables
9046 1532594026.28307: sending task start callback, copying the task so we can template it temporarily
9046 1532594026.28309: done copying, going to template now
9046 1532594026.28313: done templating
9046 1532594026.28315: here goes the callback...
9046 1532594026.28320: sending task start callback
9046 1532594026.28323: entering _queue_task() for localhost/ce_command
9046 1532594026.28326: Creating lock for ce_command
9046 1532594026.28421: worker is 1 (out of 1 available)
9046 1532594026.28464: exiting _queue_task() for localhost/ce_command
9046 1532594026.28482: done queuing things up, now waiting for results queue to drain
9046 1532594026.28489: waiting for pending results...
9054 1532594026.28772: running TaskExecutor() for localhost/TASK: ce_command
9054 1532594026.28825: in run()
9054 1532594026.28880: calling self._execute()
9054 1532594026.29479: Loading Connection 'local' from /usr/lib/python2.7/site-packages/ansible/plugins/connection/local.py
9054 1532594026.29541: Loading ShellModule 'csh' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/csh.py
9054 1532594026.29576: Loading ShellModule 'fish' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/fish.py
9054 1532594026.29612: Loading ShellModule 'powershell' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.py
9054 1532594026.29631: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/sh.py
9054 1532594026.29653: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
9054 1532594026.29667: in VariableManager get_vars()
9054 1532594026.29702: done with get_vars()
9054 1532594026.33584: Loading ActionModule 'ce' from /usr/lib/python2.7/site-packages/ansible/plugins/action/ce.py
9054 1532594026.33599: starting attempt loop
9054 1532594026.33604: running the handler
9054 1532594026.33687: Loading Connection 'persistent' from /usr/lib/python2.7/site-packages/ansible/plugins/connection/persistent.py
9054 1532594026.33709: Loading ShellModule 'csh' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/csh.py (found_in_cache=True, class_only=False)
9054 1532594026.33716: Loading ShellModule 'fish' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/fish.py (found_in_cache=True, class_only=False)
9054 1532594026.33720: Loading ShellModule 'powershell' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/powershell.py (found_in_cache=True, class_only=False)
9054 1532594026.33726: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
9054 1532594026.33732: Loading ShellModule 'sh' from /usr/lib/python2.7/site-packages/ansible/plugins/shell/sh.py (found_in_cache=True, class_only=False)
9054 1532594026.33792: Loading Connection 'ssh' from /usr/lib/python2.7/site-packages/ansible/plugins/connection/ssh.py (found_in_cache=False, class_only=True)
9054 1532594056.56313: handler run complete
9054 1532594056.56332: attempt loop complete, returning result
9054 1532594056.56340: _execute() done
9054 1532594056.56344: dumping result to json
9054 1532594056.56350: done dumping result, returning
9054 1532594056.56360: done running TaskExecutor() for localhost/TASK: ce_command
9054 1532594056.56370: sending task result
9054 1532594056.56444: done sending task result
9054 1532594056.56471: WORKER PROCESS EXITING
9046 1532594056.56519: marking localhost as failed
9046 1532594056.56534: marking host localhost failed, current state: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_TASKS, fail_state=FAILED_NONE, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
9046 1532594056.56544: ^ failed state is now: HOST STATE: block=2, task=1, rescue=0, always=0, run_state=ITERATING_COMPLETE, fail_state=FAILED_TASKS, pending_setup=False, tasks child state? (None), rescue child state? (None), always child state? (None), did rescue? False, did start at task? False
9046 1532594056.56550: getting the next task for host localhost
9046 1532594056.56554: host localhost is done iterating, returning
localhost | FAILED! => {
"changed": false,
"failed": true,
"msg": "unable to open shell. Please see: https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell",
"rc": 255
}
9046 1532594056.56579: no more pending results, returning what we have
9046 1532594056.56584: results queue empty
9046 1532594056.56587: checking for any_errors_fatal
9046 1532594056.56589: done checking for any_errors_fatal
9046 1532594056.56592: checking for max_fail_percentage
9046 1532594056.56594: done checking for max_fail_percentage
9046 1532594056.56598: checking to see if all hosts have failed and the running result is not ok
9046 1532594056.56600: done checking to see if all hosts have failed
9046 1532594056.56603: getting the remaining hosts for this loop
9046 1532594056.56606: done getting the remaining hosts for this loop
9046 1532594056.56611: building list of next tasks for hosts
9046 1532594056.56616: getting the next task for host localhost
9046 1532594056.56621: host localhost is done iterating, returning
9046 1532594056.56624: done building task lists
9046 1532594056.56626: counting tasks in each state of execution
9046 1532594056.56629: done counting tasks in each state of execution:
num_setups: 0
num_tasks: 0
num_rescue: 0
num_always: 0
9046 1532594056.56632: all hosts are done, so returning None's for all hosts
9046 1532594056.56635: done queuing things up, now waiting for results queue to drain
9046 1532594056.56639: results queue empty
9046 1532594056.56642: checking for any_errors_fatal
9046 1532594056.56644: done checking for any_errors_fatal
9046 1532594056.56647: checking for max_fail_percentage
9046 1532594056.56649: done checking for max_fail_percentage
9046 1532594056.56651: checking to see if all hosts have failed and the running result is not ok
9046 1532594056.56653: done checking to see if all hosts have failed
9046 1532594056.56657: getting the next task for host localhost
9046 1532594056.56660: host localhost is done iterating, returning
9046 1532594056.56664: running handlers
9046 1532594056.56716: RUNNING CLEANUP

ansible升级后无法执行

The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_Dm9NQB/ansible_module_ce_command.py", line 269, in
main()
File "/tmp/ansible_Dm9NQB/ansible_module_ce_command.py", line 204, in main
supports_check_mode=True)
File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/network.py", line 134, in init
File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/network.py", line 170, in connect
File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/cloudengine.py", line 221, in connect
File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/shell.py", line 157, in send
TypeError: string indices must be integers, not str

localhost | FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n File "/tmp/ansible_Dm9NQB/ansible_module_ce_command.py", line 269, in \n main()\n File "/tmp/ansible_Dm9NQB/ansible_module_ce_command.py", line 204, in main\n supports_check_mode=True)\n File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/network.py", line 134, in init\n File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/network.py", line 170, in connect\n File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/cloudengine.py", line 221, in connect\n File "/tmp/ansible_Dm9NQB/ansible_modlib.zip/ansible/module_utils/shell.py", line 157, in send\nTypeError: string indices must be integers, not str\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}

2.9.3 ansbile 使用ce模块重复操作(比如反复创建vlan10)log 中change仍然为TRUE,update为空。不知道是什么原因

2.9.3 ansbile 使用ce模块重复操作(比如反复创建vlan10)log 中change仍然为TRUE,update为空。不知道是什么原因
我在测试test_ce_vxlan_gateway.yml

TASK [set dfs source ip vpn, again] *********************************************************************************************
task path: /home/tdops/CloudEngine-Ansible/test/test-ce_vxlan_gateway.yml:86
<10.57.66.199> using connection plugin network_cli (was local)
<10.57.66.199> ESTABLISH LOCAL CONNECTION FOR USER: tdops
<10.57.66.199> EXEC /bin/sh -c 'echo ~tdops && sleep 0'
<10.57.66.199> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /home/tdops/.ansible/tmp/ansible-tmp-1582785699.88-239091264236788" && echo ansible-tmp-1582785699.88-239091264236788="echo /home/tdops/.ansible/tmp/ansible-tmp-1582785699.88-239091264236788" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/network/cloudengine/ce_vxlan_gateway.py-bk
<10.57.66.199> PUT /home/tdops/.ansible/tmp/ansible-local-25922676vod/tmpYYNkKz TO /home/tdops/.ansible/tmp/ansible-tmp-1582785699.88-239091264236788/AnsiballZ_ce_vxlan_gateway.py-bk
<10.57.66.199> EXEC /bin/sh -c 'chmod u+x /home/tdops/.ansible/tmp/ansible-tmp-1582785699.88-239091264236788/ /home/tdops/.ansible/tmp/ansible-tmp-1582785699.88-239091264236788/AnsiballZ_ce_vxlan_gateway.py-bk && sleep 0'
<10.57.66.199> EXEC /bin/sh -c '/usr/bin/python /home/tdops/.ansible/tmp/ansible-tmp-1582785699.88-239091264236788/AnsiballZ_ce_vxlan_gateway.py-bk && sleep 0'
<10.57.66.199> EXEC /bin/sh -c 'rm -f -r /home/tdops/.ansible/tmp/ansible-tmp-1582785699.88-239091264236788/ > /dev/null 2>&1 && sleep 0'
changed: [10.57.66.199] => {
"changed": true,
"end_state": {},
"existing": {},
"invocation": {
"module_args": {
"arp_direct_route": null,
"arp_distribute_gateway": null,
"dfs_all_active": null,
"dfs_id": "1",
"dfs_peer_ip": null,
"dfs_peer_vpn": null,
"dfs_source_ip": "1.2.3.4",
"dfs_source_vpn": "vxlan_gw_vpn1",
"dfs_udp_port": null,
"host": "10.57.66.199",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 22,
"provider": {
"host": "10.57.66.199",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 22,
"ssh_keyfile": null,
"timeout": null,
"transport": "cli",
"use_ssl": null,
"username": "neo",
"validate_certs": null
},
"ssh_keyfile": null,
"state": "present",
"timeout": null,
"transport": "cli",
"use_ssl": null,
"username": "neo",
"validate_certs": null,
"vbdif_bind_vpn": null,
"vbdif_mac": null,
"vbdif_name": null,
"vpn_instance": null,
"vpn_vni": null
}
},
"proposed": {
"dfs_all_active": null,
"dfs_id": "1",
"dfs_peer_ip": null,
"dfs_peer_vpn": null,
"dfs_source_ip": "1.2.3.4",
"dfs_source_vpn": "vxlan_gw_vpn1",
"dfs_udp_port": null,
"state": "present"
},
"updates": [
"dfs-group 1",
"source ip 1.2.3.4 vpn-instance vxlan_gw_vpn1"
]
}

我的环境如下:
Package Version


aniso8601 8.0.0
ansible 2.9.3
Babel 0.9.6
backports.ssl-match-hostname 3.5.0.1
bcrypt 3.1.7
cffi 1.14.0
chardet 2.2.1
Click 7.0
colorama 0.4.3
configobj 4.7.2
cryptography 2.8
decorator 3.4.0
enum34 1.1.6
Flask 1.1.1
Flask-RESTful 0.3.8
futures 3.1.1
httplib2 0.9.2
idna 2.4
iniparse 0.4
iotop 0.6
ipaddress 1.0.23
IPy 0.75
isc 2.0
itsdangerous 1.1.0
Jinja2 2.11.1
jmespath 0.9.0
kitchen 1.1.1
libvirt-python 4.5.0
lxml 4.5.0
MarkupSafe 1.1.1
msgpack-python 0.5.6
ncclient 0.5.3
network-cli 0.1
paramiko 2.7.1
passlib 1.7.1
perf 0.1
pip 20.0.2
ply 3.4
policycoreutils-default-encoding 0.1
psutil 2.2.1
pyasn1 0.1.9
pycparser 2.19
pycrypto 2.6.1
pycurl 7.19.0
pygobject 3.22.0
pygpgme 0.3
pyliblzma 0.5.3
PyNaCl 1.3.0
python-linux-procfs 0.4.9
pytz 2019.3
pyudev 0.15
pyxattr 0.5.1
PyYAML 3.11
pyzmq 15.3.0
requests 2.6.0
salt 2016.11.6
schedutils 0.4
scp 0.13.2
selectors2 2.0.1
seobject 0.1
sepolicy 1.1
setuptools 44.0.0
sh 1.12.14
six 1.9.0
slip 0.4.0
slip.dbus 0.4.0
tornado 4.2.1
urlgrabber 3.10
urllib3 1.10.2
Werkzeug 1.0.0
yum-metadata-parser 1.1.4

系统环境为centos7
安装方式为yum install ansible

ce_bfd_global shows changes even though nothing has changed

I am trying to use the ce_bfd_global module, to enable bfd globally.
However, each time I run the playbook, ansible shows the task as having performed a change, even though nothing has changed on the switch (bfd was already enabled globally).

Here is the task:

- name: Enable BFD globally
  ce_bfd_global:
    bfd_enable: enable
    provider: '{{ cli }}'

Each time it is run, it shows:

TASK [common : Enable BFD globally] ******************************************************************************************************************************************
changed: [hostname]

Syntax error playbook ce_command

Hi CloudEngine-Ansible Team

I am having some problems running playbooks with the ce_command module, I am able to run the documentation example:
ansible -m ce_command -a "commands='display vlan summary' transport='cli' host=10.254.254.1 port=22 username=admin password=admin" localhost --connection local

But I am not sure what is the correct syntax to include cli variable in my playbook:

vars:
  cli:
    host: 10.254.254.1
    username: admin
    password: admin
    transport: cli

- name: run display version on remote devices
  ce_command:
    commands: display version
    provider: "{{ cli }}"

ce_ntp module failure when trying to delete non-existing peer

Module ce_ntp called with non-existent peer and proposed "absent" state should report "no change", but obsereved behaviour is "module failure" and netconf error message: "The unicast peer does not exist". Steps to reproduce - run:

      ce_ntp:
        peer: 1.1.1.1
        state: absent
        provider: "{{ cli }}"

ce_static_route state:absent does not work

ce_static_route state:present works but state:absent does not work

playbook:

  • name: config static route
    ce_static_route:
    prefix: 2.2.2.2
    mask: 32
    next_hop: 5.5.5.5
    aftype: v4
    #description: "Ansible"
    state: present

after run:
PLAY [static route] ****************************************************************************************************************************************************

TASK [config static route] *********************************************************************************************************************************************
[DEPRECATION WARNING]: Param 'transport' is deprecated. See the module docs for more information. This feature will be removed in version 2.9. Deprecation warnings can
be disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [1.1.1.1]

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

in switch, display:
disp curr | in 2.2.2.2
ip route-static 2.2.2.2 255.255.255.255 5.5.5.5


After change present to absent, playbook:
playbook:

  • name: config static route
    ce_static_route:
    prefix: 2.2.2.2
    mask: 32
    next_hop: 5.5.5.5
    aftype: v4
    #description: "Ansible"
    state: absent

after run:
PLAY [static route] ****************************************************************************************************************************************************

TASK [config static route] *********************************************************************************************************************************************
[DEPRECATION WARNING]: Param 'transport' is deprecated. See the module docs for more information. This feature will be removed in version 2.9. Deprecation warnings can
be disabled by setting deprecation_warnings=False in ansible.cfg.
ok: [1.1.1.1]

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

in switch, display:
disp curr | in 2.2.2.2
ip route-static 2.2.2.2 255.255.255.255 5.5.5.5

还在报错,请帮忙看看什么原因,谢谢

执行如下
ansible -m ce_command -a 'host=10.4.248.6 port=22 username=sankuai password=Netadmin00@mt commands="display device"' localhost --connection local
/usr/lib/python2.6/site-packages/cryptography-2.0.3-py2.6-linux-x86_64.egg/cryptography/init.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
Using /etc/ansible/ansible.cfg as config file
[WARNING]: provided hosts list is empty, only localhost is available

ERROR! Unexpected Exception: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'

The ncclient library is required

作者:袁健
特别感谢杨亭姐和刘彪哥提供的帮助,故事很长,话很啰嗦,见谅。

两周前测试发现ansible执行单条命令时可以正常执行,但执行playbook时会报错:The ncclient library is required。

最开始,从报错语义上看,觉得这无疑是执行playbook的时候没有调到ncclient,可能ncclient没安装。

首先检查了设备,设备上查看的确没安装ncclient,窃喜。

直接安装ncclient,不行。

将之前可以执行playbook的机子上的ncclient压缩包拷贝过去安装,也不行。

换个目录安装,还是不行。

后来没办法,从报错信息出处找原因吧,该句错误来自于我们开发插件所依赖的ne.py插件:

if not HAS_NCCLIENT:

        self._module.fail_json(msg='Error: The ncclient library is required.')

即如果没有HAS_NCCLIENT,就会报错,而前面唯一用到HAS_NCCLIENT的地方是:

try:

from ncclient import manager, xml_

from ncclient.operations.rpc import RPCError

from ncclient.transport.errors import AuthenticationError

from ncclient.operations.errors import TimeoutExpiredError

HAS_NCCLIENT = True

except ImportError:

HAS_NCCLIENT = False

即有ncclient 就是True,就不报错,没有ncclient就报错。和最初的想法如出一辙,可是我明明安装了ncclient啊。

试着把安装的ncclient删掉,单条命令行和playbook都报错,装上ncclient,命令行好了,playbook仍然报错,什么鬼!

再然后,排查设备。

换了台设备重装python,pip,ansible,ncclient,,还是报这个错误。

百思不得其解,求助求助,找各路大神帮忙,混贴吧论坛,度娘都度不出来这条难题,毕竟这个问题太奇葩,此前大家都没遇到过。怀疑是ansible版本问题,反复安装,不行;怀疑是python版本问题,反复安装,不行;组合安装,不行;到网站上重新下ncclient,不行;因为ansible.module_utils下的其他模块都没报错,于是把ncclient放进去,果然 不会报ncclient找不到了,但是ncclient本身也不好用了,各种找不到模块,那就把ncclient下面的引用都加上ansible.module_utils,最后还是不行,甚至怀疑是linux系统问题了……就这样迷茫了一个星期,整个人都不好了。

直到今天,新年新气象。

无意间一个念头闪过,既然playbook ncclient找不到,那其他模块是怎么找到的呢???于是把其他模块都打印出来,奇迹出现:

执行命令行和执行playbook时调到的不是一个python!!!

一个是2.6,一个是2.7。2.7是我安装的,那这个2.6是怎么来的?细看报错信息,不难发现:2.7是在usr/local/lib下;2.6在usr/lib下,百度一波了解到带local的是用户安装的,不带local的是系统自带的。但这对解决问题并没有什么帮助。

试过,在usr/lib下的python2.6中加入ncclient安装后的包,不报ncclient找不到了,美滋滋,但包six找不到;对比发现python2.6和python2.7差别甚广,这样子一个个手动加进去得何时是尽头?遂换种思路,既然usr/local/lib下的2.7可以,那干脆把他拷到usr/lib下好了,但执行发现调到的还是python2.6。那把python2.6删了呢?那也不会调用python2.7,报各个模块都找不到,无奈把python2.7名字改成python2.6试试吧,几经调用,最后还是报_weakref找不到。

自此,进展是知道了虽然报ncclient找不到,但透过现象,本质是执行playbook和命令行所调用到的python不是同一个,尽管敲play-book –version时显示的是 ansible python module location = /usr/local/lib/python2.7/site-packages/ansible-2.4.0.0-py2.7.egg/ansible;executable location = /usr/local/bin/ansible-playbook,但执行ansible-play的时候就是调到usr/lib下的python2.6,至于为什么这样?可能要问ansible的开发人员。

困难是现在有两个方向:

1是升级usr/lib下的python2.6,使其与usr/local/lib下的完全一致,这样就该不会有问题,但是怎么升级才能保证同一linux上安装两个相同的python版本呢 ?

2是修改ansible-playbook的执行路径,使其调用usr/local/lib下面的python2.7,可是怎么改呢?

又是一轮度娘,最后在文库上看到,python存在默认指向,可能执行playbook的时候就调用了这个默认指向的python,而python2.6恰好是系统自带的python,具备天时地利,感觉有戏,于是,历经一个多星期的数百次失败,终于成功了。。。

其实就是把usr/bin/python及usr/bin/python-config删除,重新建立软表连接:

LFG1000040684:/usr/bin # ln -s /usr/local/bin/python2.7 /usr/bin/python

LFG1000040684:/usr/bin # ln -s /usr/local/bin/python2.7-config /usr/bin/python-config

使其指向自己安装的python2.7即可。

执行该命令的时候报ce_command的时候报raise socket.timeout()

ansible -m ce_command -a 'host=192.168.1.5 port=22 username=admin@123 password=Huawei@123456
commands="display version"' localhost --connection local -vvvv
执行该命令的时候报raise socket.timeout()
An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_un2ETe/ansible_module_ce_command.py", line 263, in
main()
File "/tmp/ansible_un2ETe/ansible_module_ce_command.py", line 199, in main
supports_check_mode=True)
File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/network.py", line 112, in init
File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/network.py", line 148, in connect
File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/cloudengine.py", line 243, in connect
File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/shell.py", line 226, in connect
File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/shell.py", line 116, in open
File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/shell.py", line 128, in receive
File "/usr/lib/python2.7/site-packages/paramiko/channel.py", line 667, in recv

raise socket.timeout()

socket.timeout

localhost | FAILED! => {
"changed": false,
"failed": true,
"invocation": {
"module_name": "ce_command"
},
"module_stderr": "Traceback (most recent call last):\n File "/tmp/ansible_un2ETe/ansible_module_ce_command.py", line 263, in \n main()\n File "/tmp/ansible_un2ETe/ansible_module_ce_command.py", line 199, in main\n supports_check_mode=True)\n File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/network.py", line 112, in init\n File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/network.py", line 148, in connect\n File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/cloudengine.py", line 243, in connect\n File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/shell.py", line 226, in connect\n File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/shell.py", line 116, in open\n File "/tmp/ansible_un2ETe/ansible_modlib.zip/ansible/module_utils/shell.py", line 128, in receive\n File "/usr/lib/python2.7/site-packages/paramiko/channel.py", line 667, in recv\n raise socket.timeout()\nsocket.timeout\n",
"module_stdout": "",
"msg": "MODULE FAILURE"

使用ce_file_copy模块 报"msg": "'Error: No scp package, please install it.'"

ansible 2.4.2版本
使用ce_file_copy模块进行远程上传文件时,报如下错误
The full traceback is:
File "/tmp/ansible_lH24EP/ansible_module_ce_file_copy.py", line 119, in
from scp import SCPClient

fatal: [172.16.255.1]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"file_system": "flash:",
"host": null,
"local_file": "/ce-save.yml",
"password": null,
"port": null,
"provider": {
"host": "172.16.255.1",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 22,
"timeout": null,
"transport": "cli",
"use_ssl": null,
"username": "admin123",
"validate_certs": null
},
"remote_file": null,
"timeout": null,
"transport": "cli",
"use_ssl": null,
"username": null,
"validate_certs": null
}
},
"msg": "'Error: No scp package, please install it.'"
确认ce交换机和liunx系统都有安装scp的服务,请问下大概是什么问题?

ce_file_copy is failing with deafult value for file_system

fatal: [swt1-rlab.mgm.lsoffice.cz]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "file_system": "flash:",
            "host": "swt1-rlab.mgm.lsoffice.cz",
            "local_file": "/data/ansible/storage//CE5855EI-V200R003C00SPC810.cc",
            "password": null,
            "port": 22,
            "provider": {
                "host": "swt1-rlab.mgm.lsoffice.cz",
                "password": null,
                "port": 22,
                "timeout": null,
                "transport": "cli",
                "use_ssl": null,
                "username": "netoor",
                "validate_certs": null
            },
            "remote_file": "CE5855EI-V200R003C00SPC810.cc",
            "timeout": null,
            "transport": "cli",
            "use_ssl": null,
            "username": "netoor",
            "validate_certs": null
        }
    },
    "msg": "Could not transfer file. There was an error during transfer. Please make sure the format of input parameters is right."
}

playbook task:

  - name: COPYING IMAGE TO DEVICE FLASH
    ce_file_copy:
      provider: "{{ cli }}"
      local_file: "{{ file_storage }}/{{ local_image }}"
      remote_file: "{{ remote_image }}"

It works fine when I use this config for task in playbook:

  - name: COPYING IMAGE TO DEVICE FLASH
    ce_file_copy:
      provider: "{{ cli }}"
      local_file: "{{ file_storage }}/{{ local_image }}"
      file_system: "flash:/"
      remote_file: "{{ remote_image }}"

The file_system or remote_file should be checked in ce_file_copy.py value and if ther is '/' missing, than added it automaticaly.

ad hoc command error

espl@ansible:~$ ansible -m ce_command -a "commands='display vlan summary' transport='cli' host=10.11.104.2 port=22 username=huawei password=huawei123" localhost --connection local

and get the error message as below

localhost | FAILED! => {
    "msg": "Traceback (most recent call last):\n  File \"/usr/local/bin/ansible-connection\", line 50, in <module>\n   from ansible.plugins import connection_loader\nImportError: cannot import name connection_loader\n"

ce_command dealing with multiple hosts

I am using this sample playbook:

---
- name: "sample book"
  hosts: localhost
  connection: local
  vars:
    cli:
      host: 172.19.2.1
      port: 22
      username: telnet
      password: Huawei@123
      transport: cli

  tasks:
  - name: run display version on remote devices
    ce_command:
      commands: display version
      provider: "{{ cli }}"

It works well when connecting a single CE switch. But how can I connect to a group of switches which I already defined in /etc/ansible/hosts in the first place?
Assuming I have got group which is called SIS, when I replace the '172.19.2.1' with 'SIS', ansible is actually trying to connect 'SIS', but not the IP addresses listing in /etc/ansible/hosts.
Plz help!

network_cli - Connection plugin problem

Greetings,

I'm testing various modules and I have experiencing that only ce_command and ce_config support the network_cli plugin.

In others modules, example ce_bgp_neighbor_af, i don't understand why it uses the netconf module if I defined the provider cli.

Is possible for you to standardizing the network connection plugin and updates the documentation ?

Regards
Gerardo

关于ce_vrf模块报错问题

YMAL脚本:

  • name: CloudEngine command test
    hosts: CE_6851
    connection: local
    gather_facts: no
    vars_files:
    - creds.yaml
    vars:
    cli:
    host: "{{ inventory_hostname }}"
    port: "{{ ansible_ssh_port }}"
    username: "{{ username }}"
    password: "{{ password }}"
    transport: cli
    tasks:
  • name: Config a vpn install named vpna, description is test
    ce_vrf:
    vrf: vpna
    description: test
    state: present
    provider: "{{ cli }}"

ansible verion: 2.8.5
python version: 3.7.3

Running module on Ansible in virtualenv

Hello,

I'm trying to run the module but I get this error:
ansible all -M ./CloudEngine-Ansible/library -m ce_command -a "commands='display vlan summary' transport='cli'"

10.0.0.1 | FAILED! => {
"failed": true,
"msg": "The module ce_command was not found in configured module paths. Additionally, core modules are missing. If this is a checkout, run 'git submodule update --init --recursive' to correct this problem."
}

(ansible) root@debian871:~/Envs/ansible# ansible --version
ansible 2.2.1.0
config file =
configured module search path = Default w/o overrides

(ansible) root@debian871:~/Envs/ansible# cat /etc/*release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"

My other modules are in (I'm running ansible in virtualenv):
/root/Envs/ansible/lib/python2.7/site-packages/ansible/modules/

I'm running command in /root/Envs/ansible/project and here I have ansible_hosts file and also a git clone of your modules in CloudEngine-Ansible

Here's the tree command:

(ansible) root@debian871:~/Envs/ansible# tree -L 2
.
├── bin
│   ├── activate
│   ├── activate.csh
│   ├── activate.fish
│   ├── activate_this.py
│   ├── ansible
│   ├── ansible-console
│   ├── ansible-doc
│   ├── ansible-galaxy
│   ├── ansible-playbook
│   ├── ansible-pull
│   ├── ansible-vault
│   ├── easy_install
│   ├── easy_install-2.7
│   ├── get_env_details
│   ├── pip
│   ├── pip2
│   ├── pip2.7
│   ├── postactivate
│   ├── postdeactivate
│   ├── preactivate
│   ├── predeactivate
│   ├── python
│   ├── python2 -> python
│   ├── python2.7 -> python
│   ├── python-config
│   └── wheel
├── include
│   └── python2.7 -> /usr/include/python2.7
├── lib
│   └── python2.7
├── local
│   ├── bin -> /root/Envs/ansible/bin
│   ├── include -> /root/Envs/ansible/include
│   └── lib -> /root/Envs/ansible/lib
├── pip-selfcheck.json
└── project
├── ansible_hosts
└── CloudEngine-Ansible

And requirments
(ansible) root@debian871:/Envs/ansible# pip freeze
ansible==2.2.1.0
appdirs==1.4.0
cffi==1.9.1
cryptography==1.7.2
enum34==1.1.6
idna==2.2
ipaddress==1.0.18
Jinja2==2.8.1
lxml==3.7.2
MarkupSafe==0.23
ncclient==0.5.3
packaging==16.8
paramiko==2.1.1
pyasn1==0.1.9
pycparser==2.17
pycrypto==2.6.1
pyparsing==2.1.10
PyYAML==3.12
six==1.10.0
(ansible) root@debian871:
/Envs/ansible#

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.