Topic: tech juniper ijaut prev next
tech juniper ijaut > 09: JSON and YAML
Certain data types are the same across platforms: boolean, integer, string, null. Complex, or ‘bundled’, data types are list, dictionary, etc..
[
{
"name": "Retrieve interface information",
"hosts": "vmx_devices",
"roles": [ "Juniper.junos" ]
}
]
YAML is a superset of JSON with improved readability. Every JSON file is a YAML file, but the reverse is not true.
---
- name: Retrieve interface information
hosts: vmx_devices
roles:
- Juniper.junos
retrieveinterfacestatus.yml;
---
- name: Retrieve interface information
hosts: vmx_devices
roles:
- Juniper.junos
connection: local
gather_facts: no
vars_prompt:
- name: USERNAME
prompt: Username
private: no
- name: DEVICE_PASSWORD
prompt: Password
private: yes
tasks:
- name: Get Junos device information
juniper_junos_command:
user: "{{ USERNAME }}"
passwd: "{{ DEVICE_PASSWORD }}"
commands:
- show interfaces ge-0/0/[01]* terse
register: cmd_output
- name: Print result
debug:
msg: "{{ cmd output.stdout lines }}"
Run the playbook with;
ansible-playbook retrieve_interface_status.yml