2017-05-09 15:11:48 +02:00
|
|
|
---
|
2018-01-08 13:28:47 +01:00
|
|
|
- debug: msg="START netconf/facts.yaml on connection={{ ansible_connection }}"
|
2017-05-09 15:11:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
- name: Collect default facts from device
|
|
|
|
junos_facts:
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "'ansible_net_hostname' in result['ansible_facts']"
|
|
|
|
- "'ansible_net_interfaces' in result['ansible_facts']"
|
|
|
|
- "'ansible_net_memfree_mb' in result['ansible_facts']"
|
|
|
|
|
|
|
|
- name: Collect config facts from device
|
|
|
|
junos_facts:
|
|
|
|
gather_subset: config
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "'ansible_net_config' in result['ansible_facts']"
|
|
|
|
- "'ansible_net_interfaces' not in result['ansible_facts']"
|
|
|
|
- "'ansible_net_memfree_mb' not in result['ansible_facts']"
|
|
|
|
|
|
|
|
- name: Collect all facts from device except hardware
|
|
|
|
junos_facts:
|
|
|
|
gather_subset: "!hardware"
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
- "'ansible_net_config' in result['ansible_facts']"
|
|
|
|
- "'ansible_net_interfaces' in result['ansible_facts']"
|
|
|
|
- "'ansible_net_memfree_mb' not in result['ansible_facts']"
|
|
|
|
|
|
|
|
- name: Invalid facts subset value
|
|
|
|
junos_facts:
|
|
|
|
gather_subset: test
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.failed == true"
|
2019-06-10 16:10:58 +02:00
|
|
|
- "'Subset must be one of' in result.msg"
|
2017-05-09 15:11:48 +02:00
|
|
|
|
|
|
|
- name: Collect config facts from device in set format
|
|
|
|
junos_facts:
|
|
|
|
gather_subset: config
|
|
|
|
config_format: set
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
2018-01-29 19:05:43 +01:00
|
|
|
- "'set system services netconf ssh' in result['ansible_facts']['ansible_net_config']"
|
2017-05-09 15:11:48 +02:00
|
|
|
|
|
|
|
- name: Collect config facts from device in xml format
|
|
|
|
junos_facts:
|
|
|
|
gather_subset: config
|
|
|
|
config_format: xml
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
2018-01-30 19:37:01 +01:00
|
|
|
- "'<netconf>' in result['ansible_facts']['ansible_net_config']"
|
2017-05-09 15:11:48 +02:00
|
|
|
|
|
|
|
- name: Collect config facts from device in json format
|
|
|
|
junos_facts:
|
|
|
|
gather_subset: config
|
|
|
|
config_format: json
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
2018-01-30 19:37:01 +01:00
|
|
|
- "'{{ result['ansible_facts']['ansible_net_config']['configuration'][0]['system'][0]['service'][0]['netconf'] }}' is defined"
|
2017-11-24 07:34:47 +01:00
|
|
|
when: ansible_net_version == "15.1X49-D15.4"
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
2018-07-12 06:23:03 +02:00
|
|
|
- "'ssh' in result['ansible_facts']['ansible_net_config']['configuration']['system']['services']['netconf']"
|
2017-11-24 07:34:47 +01:00
|
|
|
when: ansible_net_version == "17.3R1.10"
|
2017-05-09 15:11:48 +02:00
|
|
|
|
|
|
|
- name: Collect config facts from device in text format
|
|
|
|
junos_facts:
|
|
|
|
gather_subset: config
|
|
|
|
config_format: text
|
|
|
|
provider: "{{ netconf }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
2018-01-30 19:37:01 +01:00
|
|
|
- "'netconf {' in result['ansible_facts']['ansible_net_config']"
|
2017-05-09 15:11:48 +02:00
|
|
|
|
2018-01-08 13:28:47 +01:00
|
|
|
- debug: msg="END netconf/facts.yaml on connection={{ ansible_connection }}"
|