I'm new to Ansible, so I'm working my way though learning it. I have a
small very basic playbook with two tasks. The first task uses the junos
module to back the config of a switch. The second tasks changes the host
name of the switch. Ansible reports that only first task was successful.
After the playbook completeds its run I see the config was downloaded and
the host name of the switch was actually changed. Any one know what is
going on here I'm a bit confused. So far Ansible seems a bit buggy, but I
have to believe I'm just not understanding something. Any one have any
idea whats going on?
[root@automation 3400s]# cat get_conf.yml
---
- name: Examples of juniper_junos_command
hosts: 209.120.7.1
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
- name: get backup of switch.
junos_config:
backup: yes
- name: Change hostname.
junos_config:
lines:
- set system host-name test5
[root@automation 3400s]# ansible-playbook -i inventory
get_conf_from_3400.yml
PLAY [Examples of juniper_junos_command]
**********************************************************************************************************************************************************************
TASK [get backup of switch.]
**********************************************************************************************************************************************************************************
ok: [209.120.7.1]
TASK [Change hostname.]
***************************************************************************************************************************************************************************************
fatal: [209.120.7.1]: FAILED! => {"changed": false, "module_stderr":
"/root/.ansible/tmp/ansible-tmp-1581016781.067035-265612933567133/AnsiballZ_junos_config.py:17:
DeprecationWarning: the imp module is deprecated in favour of importlib;
see the module's documentation for alternative uses\n import imp\n",
"module_stdout": "\n{\"msg\": \"b'command timeout triggered, timeout value
is 10 secs.\\\\nSee the timeout setting options in the Network Debug and
Troubleshooting Guide.'\", \"failed\": true, \"invocation\":
{\"module_args\": {\"lines\": [\"set system host-name test5\"],
\"provider\": {\"host\": null, \"port\": null, \"username\": null,
\"password\": null, \"ssh_keyfile\": null, \"timeout\": null,
\"transport\": \"netconf\"}, \"update\": \"merge\", \"confirm\": 0,
\"comment\": \"configured by junos_config\", \"confirm_commit\": false,
\"backup\": false, \"zeroize\": false, \"src\": null, \"src_format\": null,
\"replace\": null, \"rollback\": null, \"host\": null, \"port\": null,
\"username\": null, \"password\": null, \"ssh_keyfile\": null, \"timeout\":
null, \"transport\": null}}}\n\n{\"msg\": \"b'command timeout triggered,
timeout value is 10 secs.\\\\nSee the timeout setting options in the
Network Debug and Troubleshooting Guide.'\", \"failed\": true,
\"invocation\": {\"module_args\": {\"lines\": [\"set system host-name
test5\"], \"provider\": {\"host\": null, \"port\": null, \"username\":
null, \"password\": null, \"ssh_keyfile\": null, \"timeout\": null,
\"transport\": \"netconf\"}, \"update\": \"merge\", \"confirm\": 0,
\"comment\": \"configured by junos_config\", \"confirm_commit\": false,
\"backup\": false, \"zeroize\": false, \"src\": null, \"src_format\": null,
\"replace\": null, \"rollback\": null, \"host\": null, \"port\": null,
\"username\": null, \"password\": null, \"ssh_keyfile\": null, \"timeout\":
null, \"transport\": null}}}\n", "msg": "MODULE FAILURE\nSee stdout/stderr
for the exact error", "rc": 1}
to retry, use: --limit @/home/mevans/ansible/3400s/get_conf.retry
PLAY RECAP
****************************************************************************************************************************************************************************************************
209.120.7.1 : ok=1 changed=0 unreachable=0 failed=1
#directory listing. backup foder was created and backup configuration file
was created
[root@automation 3400s]# ls -al
total 116
drwxrwxr-x. 4 root root 4096 Feb 6 13:19 .
drwxrwxr-x. 10 root root 134 Feb 5 15:18 ..
-rw-r--r--. 1 root root 20300 Feb 5 16:44 ansible.cfg
drwxr-xr-x. 2 root root 52 Feb 6 13:19 backup
-rw-r--r--. 1 root root 12 Feb 6 13:20 get_conf.retry
-rw-r--r--. 1 root root 495 Feb 6 13:18 get_conf.yml
[root@automation 3400s]# ls -la backup
total 48
drwxr-xr-x. 2 root root 52 Feb 6 13:19 .
drwxrwxr-x. 4 root root 4096 Feb 6 13:19 ..
-rw-r--r--. 1 root root 41827 Feb 6 13:19
209.120.7.1_config.2020-02-06@13:19:40
#Host name on the switch was changed.
{master:0}
mevans@test30>
{master:0}
mevans@test5>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ee82a835-65d7-47a9-a084-f812511a9179%40googlegroups.com.