Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

https://github.com/Juniper/Intro-to-Using-Ansible-with-Junos-OS/wiki/Health-Checks

Junos Automation: Using Ansible to pull basic information from a network device

Widget Connector
urlhttps://www.youtube.com/watch?v=BsRZCj1AKNg

...

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
jlk@ubuntu:/etc/ansible$ more /etc/ansible/hosts
[vsrx]
vsrx1

[srx300]
192.168.0.2





junos_get_facts


Code Block
titleget facts
collapsetrue
jlk@ubuntu:/etc/ansible/roles/ex3400$ more tasks/main.yml 
---
# tasks file for ex3400
# Enter those command into the JunOS box
#
#set system login user jansible class super-user
#set system login user jansible authentication plain-text-password
#
- name: Get facts Play
  hosts: EX4300 
  connection: local
  gather_facts: no
  roles:
    - Juniper.junos
  vars:
    ansible_python_interpreter: "/usr/bin/python"
  tasks:
    - name: Checking NETCONF connectivity Task
      wait_for: host={{ inventory_hostname }} port=830 timeout=5
    - name: Get junos facts Task
      junos_get_facts:
        host: "172.30.95.194"
        user: "jansible"
        passwd: "jansible123"
      register: junos
    - name: Print facts
      debug:
        var: junos











jlk@ubuntu:/etc/ansible$ more /etc/ansible/facts.pb.yaml
---
- name: Get facts
hosts: vsrx
connection: local
gather_facts: no
roles:
- Juniper.junos
vars_prompt:
- name: ADMUSER
prompt: Username
private: no
- name: ADMPASS
prompt: password
private: yes
tasks:
- name: Get junos facts
junos_get_facts:
host: "{{ inventory_hostname }}"
user: "{{ ADMUSER }}"
passwd: "{{ ADMPASS }}"
register: junos
- name: Print facts
debug:
var: junos

...