Hi NSI,
The <inherit: "defaults"> option should do the trick for your use case. "To retrieve data from the post-inheritance configuration, which displays statements that are inherited from user-defined groups and ranges as children of the inheriting statements, you can include the options
argument with inherit: "inherit"
Now, if we check the <get-configuration> RPC, the "defaults" value for the inherit option is also present -
https://www.juniper.net/documentation/en_US/junos/topics/reference/tag-summary/junos-xml-protocol-get-configuration.html
This worked for me -
---
- name: Get Configuration Inheritence Defaults
hosts:
- all
roles:
- Juniper.junos
connection: local
gather_facts: no
vars_prompt:
- name: username
prompt: Junos Username
private: no
- name: password
prompt: Junos Password
private: yes
tasks:
- name: "Get = show configuration | display inheritence defaults | display xml"
juniper_junos_config:
retrieve: "committed"
options:
inherit: "defaults"
provider:
host: "{{ ansible_host }}"
port: 22
user: "{{ username }}"
passwd: "{{ password }}"
format: xml
return_output: true
Result:
PLAYBOOK: config-inherit-defaults.yaml **************************************************************************************************************************************************************
1 plays in config-inherit-defaults.yaml
Junos Username: xxx
Junos Password:
PLAY [Get Configuration Inheritence Defaults] *******************************************************************************************************************************************************
META: ran handlers
TASK [Get = show configuration | display inheritence defaults | display xml] ************************************************************************************************************************
<...>
ok: [sony] => {
"changed": false,
"config_lines": [
"<configuration commit-seconds=\"1173401135\" commit-localtime=\"2007-03-08 16:45:35 PST\" commit-user=xxx..",
" <version>16.1R6-S3.1</version>",
" <comment>#",
"# Defines the default for dynamic-profiles",
"#</comment>",
" <dynamic-profiles>",
" <name>junos-default-profile</name>",
" <variables>",
" <name>junos-interface-unit</name>",
" <undocumented><internal/></undocumented>",
" <undocumented><valid-path>interface_unit_number|unit-number unit interface interface-set</valid-path></undocumented>",
<...>
REF: Using Ansible to Retrieve or Compare Junos OS Configurations.
========================================
Please mark this solution as "Accepted" if it works.
Kudos are always appreciated as well 🙂