Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. ---
  2. - name: GET
  3. hosts: fw
  4. roles:
  5. - Juniper.junos
  6. connection: local
  7. gather_facts: no
  8.  
  9. # Execute tasks (plays) this way "ansible-playbook <path>/GET.yml --tags <tag-name>"
  10. tasks:
  11. # Check if a device is NETCONF-aware
  12. - name: CHECK-NETCONF
  13. tags: check-netconf
  14. wait_for: host="{{ inventory_hostname }}" port="{{ juniper_port }}"
  15.  
  16. ### WEB ### junos-ansible-modules.readthedocs.org/en/1.3.1/
  17. ### JUNOS_GET_FACTS SECTION
  18. # Get information about a device (model, active software version, serial number) and show as ansible output
  19. - name: GET-MODEL
  20. tags: get-model
  21. junos_get_facts: host="{{ inventory_hostname }}" user="{{ juniper_user }}" port="{{ juniper_port }}"
  22. savedir="/opt/juniper/"
  23. register: junos
  24. - name: SHOW VARS
  25. tags: get-model
  26. debug: msg="MODEL {{ junos.facts.model }} | SOFTWARE {{ junos.facts.version }} | S/N {{ junos.facts.serialnumber }}"
  27.  
  28. ### JUNOS_GET_CONFIG SECTION
  29. # Execute "show configuration system" and save output to a file
  30. - name: GET-CONFIG-SYSTEM
  31. tags: get-config-system
  32. junos_get_config: host="{{ inventory_hostname }}" user="{{ juniper_user }}" port="{{ juniper_port }}"
  33. format=text
  34. dest="/opt/juniper/{{ inventory_hostname }}_get-config-system.output"
  35. filter=system
  36.  
  37. ### JUNOS_CLI SECTION
  38. # Get list of interfaces and save output to a file
  39. - name: GET-INTERFACES
  40. tags: get-interfaces
  41. junos_cli: host="{{ inventory_hostname }}" user="{{ juniper_user }}" port="{{ juniper_port }}"
  42. dest="/opt/juniper/{{ inventory_hostname }}_get-interfaces.output"
  43. cli="show interfaces terse"
  44.  
  45. ### EOF ###
  46.  
  47.  
  48.  
  49. I get following error:
  50.  
  51. funabashi@vps:/etc/ansible/roles/Juniper.junos/library$ sudo ansible-playbook GET.yml -l fw -u ansible -k -t get-config-system
  52. SSH password:
  53.  
  54. PLAY [GET] ******************************************************************************************************************************************************************************************
  55.  
  56. TASK [GET-CONFIG-SYSTEM] ****************************************************************************************************************************************************************************
  57. fatal: [212.37.x.x]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'juniper_user' is undefined\n\nThe error appears to have been in '/etc/ansible/roles/Juniper.junos/library/GET.yml': line 30, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n # Execute \"show configuration system\" and save output to a file\n - name: GET-CONFIG-SYSTEM\n ^ here\n"}
  58. to retry, use: --limit @/etc/ansible/roles/Juniper.junos/library/GET.retry
  59.  
  60. PLAY RECAP ******************************************************************************************************************************************************************************************
  61. 212.37.x.x : ok=0 changed=0 unreachable=0 failed=1
  62.  
  63. funabashin@vps:/etc/ansible/roles/Juniper.junos/library$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement