-
Notifications
You must be signed in to change notification settings - Fork 11
Description
playbook
-
hosts: hw
gather_facts: no
connection: local
vars:
sport: 22
suser: "admin"
spass: "admin123456"
shost: "{{ inventory_hostname }}"tasks:
配置 snmp
- name: configure snmp
hwos_command:
sport: "{{ sport }}"
shost: "{{ shost }}"
suser: "{{ suser }}"
spass: "{{ spass }}"
save: true
command: |
system-view
snmp-agent
snmp-agent community read {{ snmp }}
snmp-agent sys-info version v2c v3
tags: snmp-ro
hosts 如下
[hw]
192.168.74.10
[hw:vars]
snmp=network-tc
当我执行playbook的时候 报错如下:
[root@es-node playbook]# ansible-playbook hw.yml -vvv --tags snmp-ro
Using /etc/ansible/ansible.cfg as config file
PLAYBOOK: hw.yml *************************************************************************************************************************************************************************************************
1 plays in hw.yml
PLAY [hw] ********************************************************************************************************************************************************************************************************
META: ran handlers
TASK [configure snmp] ********************************************************************************************************************************************************************************************
task path: /root/playbook/hw.yml:78
Using module file /usr/share/my_modules/hwos_command.py
<192.168.74.10> ESTABLISH LOCAL CONNECTION FOR USER: root
<192.168.74.10> EXEC /bin/sh -c 'echo ~ && sleep 0'
<192.168.74.10> EXEC /bin/sh -c '( umask 77 && mkdir -p "echo /root/.ansible/tmp/ansible-tmp-1496716397.56-126455380231962" && echo ansible-tmp-1496716397.56-126455380231962="echo /root/.ansible/tmp/ansible-tmp-1496716397.56-126455380231962" ) && sleep 0'
<192.168.74.10> PUT /tmp/tmppCgGfw TO /root/.ansible/tmp/ansible-tmp-1496716397.56-126455380231962/hwos_command.py
<192.168.74.10> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1496716397.56-126455380231962/ /root/.ansible/tmp/ansible-tmp-1496716397.56-126455380231962/hwos_command.py && sleep 0'
<192.168.74.10> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-1496716397.56-126455380231962/hwos_command.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1496716397.56-126455380231962/" > /dev/null 2>&1 && sleep 0'
The full traceback is:
Traceback (most recent call last):
File "/tmp/ansible_6nsAye/ansible_module_hwos_command.py", line 290, in
main()
File "/tmp/ansible_6nsAye/ansible_module_hwos_command.py", line 274, in main
raise AnsibleError('Save config error.\n' + str(e) )
ansible.errors.AnsibleError: Save config error.
Socket is closed
fatal: [192.168.74.10]: FAILED! => {
"changed": false,
"failed": true,
"module_stderr": "Traceback (most recent call last):\n File "/tmp/ansible_6nsAye/ansible_module_hwos_command.py", line 290, in \n main()\n File "/tmp/ansible_6nsAye/ansible_module_hwos_command.py", line 274, in main\n raise AnsibleError('Save config error.\n' + str(e) )\nansible.errors.AnsibleError: Save config error.\nSocket is closed\n",
"module_stdout": "",
"msg": "MODULE FAILURE",
"rc": 0
}
to retry, use: --limit @/root/playbook/hw.retry
PLAY RECAP *******************************************************************************************************************************************************************************************************
192.168.74.10 : ok=0 changed=0 unreachable=0 failed=1
[root@es-node playbook]#
我把playbook中的 save: true 拿掉 可以正常执行。