parent
9163a6773b
commit
09362a2d98
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
trivial:
|
||||||
|
- Fix ansible-lint errors
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "{{ parser }} validate argspec"
|
- name: "validate argspec {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: ""
|
text: ""
|
||||||
parser:
|
parser:
|
||||||
|
@ -9,13 +9,13 @@
|
||||||
register: argfail
|
register: argfail
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: "{{ parser }} Check argspec fail"
|
- name: "Check argspec fail {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in argfail.errors }}"
|
that: "{{ msg in argfail.errors }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "parameters are mutually exclusive: command|template_path found in parser"
|
msg: "parameters are mutually exclusive: command|template_path found in parser"
|
||||||
|
|
||||||
- name: "{{ parser }} validate argspec"
|
- name: "validate argspec {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: ""
|
text: ""
|
||||||
command: ls
|
command: ls
|
||||||
|
@ -25,13 +25,13 @@
|
||||||
register: argfail
|
register: argfail
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: "{{ parser }} Check argspec fail"
|
- name: "Check argspec fail {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in argfail.errors }}"
|
that: "{{ msg in argfail.errors }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "parameters are mutually exclusive: command|text"
|
msg: "parameters are mutually exclusive: command|text"
|
||||||
|
|
||||||
- name: "{{ parser }} validate argspec"
|
- name: "validate argspec {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
parser:
|
parser:
|
||||||
name: ansible.netcommon.json
|
name: ansible.netcommon.json
|
||||||
|
@ -39,13 +39,13 @@
|
||||||
register: argfail
|
register: argfail
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: "{{ parser }} Check argspec fail"
|
- name: "Check argspec fail {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in argfail.errors }}"
|
that: "{{ msg in argfail.errors }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "one of the following is required: command, text"
|
msg: "one of the following is required: command, text"
|
||||||
|
|
||||||
- name: "{{ parser }} validate argspec"
|
- name: "validate argspec {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: ""
|
text: ""
|
||||||
parser:
|
parser:
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
register: argfail
|
register: argfail
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- name: "{{ parser }} Check arspec fail"
|
- name: "Check arspec fail {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in argfail.msg }}"
|
that: "{{ msg in argfail.msg }}"
|
||||||
vars:
|
vars:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "{{ parser }} Run command and parse with textfsm"
|
- name: "Run command and parse with textfsm {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
command: "ifconfig"
|
command: "ifconfig"
|
||||||
parser:
|
parser:
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
ansible.builtin.set_fact: myfact
|
ansible.builtin.set_fact: myfact
|
||||||
register: ifconfig_out
|
register: ifconfig_out
|
||||||
|
|
||||||
- name: "{{ parser }} Check parser output"
|
- name: "Check parser output {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "{{ parser }} Run command and parse with ttp"
|
- name: "Run command and parse with ttp {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
command: "df -h"
|
command: "df -h"
|
||||||
parser:
|
parser:
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
ansible.builtin.set_fact: myfact
|
ansible.builtin.set_fact: myfact
|
||||||
register: df_h_out
|
register: df_h_out
|
||||||
|
|
||||||
- name: "{{ parser }} Check parser output"
|
- name: "Check parser output {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "{{ parser }} Run command and parse with textfsm"
|
- name: "Run command and parse with textfsm {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
command: "ifconfig"
|
command: "ifconfig"
|
||||||
parser:
|
parser:
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
ansible.builtin.set_fact: myfact
|
ansible.builtin.set_fact: myfact
|
||||||
register: ifconfig_out
|
register: ifconfig_out
|
||||||
|
|
||||||
- name: "{{ parser }} Check parser output"
|
- name: "Check parser output {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "{{ parser }} Run command and parse with ttp"
|
- name: "Run command and parse with ttp {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
command: "df -h"
|
command: "df -h"
|
||||||
parser:
|
parser:
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
ansible.builtin.set_fact: myfact
|
ansible.builtin.set_fact: myfact
|
||||||
register: df_h_out
|
register: df_h_out
|
||||||
|
|
||||||
- name: "{{ parser }} Check parser output"
|
- name: "Check parser output {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -3,29 +3,34 @@
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
os: "{{ ansible_distribution|d }}"
|
os: "{{ ansible_distribution|d }}"
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: argspec.yaml
|
- name: Include argspec.yaml
|
||||||
|
ansible.builtin.include_tasks: argspec.yaml
|
||||||
vars:
|
vars:
|
||||||
parser: "({{ inventory_hostname }}/argspec)"
|
parser: "({{ inventory_hostname }}/argspec)"
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "nxos_json.yaml"
|
- name: Include nxos_json.yaml
|
||||||
|
ansible.builtin.include_tasks: "nxos_json.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(nxos/json)"
|
parser: "(nxos/json)"
|
||||||
tags:
|
tags:
|
||||||
- json
|
- json
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "nxos_textfsm.yaml"
|
- name: Include nxos_textfsm.yaml
|
||||||
|
ansible.builtin.include_tasks: "nxos_textfsm.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(nxos/textfsm)"
|
parser: "(nxos/textfsm)"
|
||||||
tags:
|
tags:
|
||||||
- textfsm
|
- textfsm
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "nxos_ttp.yaml"
|
- name: Include nxos_ttp.yaml
|
||||||
|
ansible.builtin.include_tasks: "nxos_ttp.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(nxos/ttp)"
|
parser: "(nxos/ttp)"
|
||||||
tags:
|
tags:
|
||||||
- ttp
|
- ttp
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "nxos_xml.yaml"
|
- name: Include nxos_xml.yaml
|
||||||
|
ansible.builtin.include_tasks: "nxos_xml.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(nxos/xml)"
|
parser: "(nxos/xml)"
|
||||||
tags:
|
tags:
|
||||||
|
@ -35,42 +40,48 @@
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "{{ os }}"
|
msg: "{{ os }}"
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "centos_textfsm.yaml"
|
- name: Include centos_textfsm.yaml
|
||||||
|
ansible.builtin.include_tasks: "centos_textfsm.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(centos/textfsm)"
|
parser: "(centos/textfsm)"
|
||||||
when: os == 'centos'
|
when: os == 'centos'
|
||||||
tags:
|
tags:
|
||||||
- textfsm
|
- textfsm
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "centos_ttp.yaml"
|
- name: Include centos_ttp.yaml
|
||||||
|
ansible.builtin.include_tasks: "centos_ttp.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(centos/ttp)"
|
parser: "(centos/ttp)"
|
||||||
when: os == 'centos'
|
when: os == 'centos'
|
||||||
tags:
|
tags:
|
||||||
- ttp
|
- ttp
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "fedora_textfsm.yaml"
|
- name: Include fedora_textfsm.yaml
|
||||||
|
ansible.builtin.include_tasks: "fedora_textfsm.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(fedora/textfsm)"
|
parser: "(fedora/textfsm)"
|
||||||
when: os == 'fedora'
|
when: os == 'fedora'
|
||||||
tags:
|
tags:
|
||||||
- textfsm
|
- textfsm
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "fedora_ttp.yaml"
|
- name: Include fedora_ttp.yaml
|
||||||
|
ansible.builtin.include_tasks: "fedora_ttp.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(fedora/ttp)"
|
parser: "(fedora/ttp)"
|
||||||
when: os == 'fedora'
|
when: os == 'fedora'
|
||||||
tags:
|
tags:
|
||||||
- ttp
|
- ttp
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "ubuntu_textfsm.yaml"
|
- name: Include ubuntu_textfsm.yaml
|
||||||
|
ansible.builtin.include_tasks: "ubuntu_textfsm.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(ubuntu/textfsm)"
|
parser: "(ubuntu/textfsm)"
|
||||||
when: os == 'ubuntu'
|
when: os == 'ubuntu'
|
||||||
tags:
|
tags:
|
||||||
- textfsm
|
- textfsm
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "ubuntu_ttp.yaml"
|
- name: Include ubuntu_ttp.yaml
|
||||||
|
ansible.builtin.include_tasks: "ubuntu_ttp.yaml"
|
||||||
vars:
|
vars:
|
||||||
parser: "(ubuntu/ttp)"
|
parser: "(ubuntu/ttp)"
|
||||||
when: os == 'ubuntu'
|
when: os == 'ubuntu'
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
nxos_json_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
nxos_json_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
||||||
|
|
||||||
- name: "{{ parser }} Run command and parse with json"
|
- name: "Run command and parse with json {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_json_text.txt') }}"
|
||||||
parser:
|
parser:
|
||||||
name: ansible.utils.json
|
name: ansible.utils.json
|
||||||
register: nxos_json_text
|
register: nxos_json_text
|
||||||
|
|
||||||
- name: "{{ parser }} Confirm response"
|
- name: "Confirm response {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
nxos_textfsm_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_version_textfsm_parsed.json') | from_json }}"
|
nxos_textfsm_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_version_textfsm_parsed.json') | from_json }}"
|
||||||
|
|
||||||
- name: "{{ parser }} Pass text and command"
|
- name: "Pass text and command {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_version.txt') }}"
|
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_version.txt') }}"
|
||||||
parser:
|
parser:
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
template_path: "{{ role_path }}/templates/nxos_show_version.textfsm"
|
template_path: "{{ role_path }}/templates/nxos_show_version.textfsm"
|
||||||
register: nxos_textfsm_text
|
register: nxos_textfsm_text
|
||||||
|
|
||||||
- name: "{{ parser }} Confirm response"
|
- name: "Confirm response {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
nxos_ttp_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_ttp_parsed.json') | from_json }}"
|
nxos_ttp_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_ttp_parsed.json') | from_json }}"
|
||||||
|
|
||||||
- name: "{{ parser }} Pass text and template_path"
|
- name: "Pass text and template_path {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||||
parser:
|
parser:
|
||||||
|
@ -11,14 +12,14 @@
|
||||||
set_fact: POpqMQoJWTiDpEW
|
set_fact: POpqMQoJWTiDpEW
|
||||||
register: nxos_ttp_text
|
register: nxos_ttp_text
|
||||||
|
|
||||||
- name: "{{ parser }} Confirm response"
|
- name: "Confirm response {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "{{ POpqMQoJWTiDpEW is defined }}"
|
- "{{ POpqMQoJWTiDpEW is defined }}"
|
||||||
- "{{ nxos_ttp_text['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length }}"
|
- "{{ nxos_ttp_text['parsed'][0][0] | selectattr('interface', 'search', 'mgmt0') | list | length }}"
|
||||||
- "{{ nxos_ttp_text['parsed'] == nxos_ttp_text_parsed }}"
|
- "{{ nxos_ttp_text['parsed'] == nxos_ttp_text_parsed }}"
|
||||||
|
|
||||||
- name: "{{ parser }} Pass text and custom variable"
|
- name: "Pass text and custom variable {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||||
parser:
|
parser:
|
||||||
|
@ -29,13 +30,13 @@
|
||||||
extra_var: some_text
|
extra_var: some_text
|
||||||
register: nxos_ttp_vars
|
register: nxos_ttp_vars
|
||||||
|
|
||||||
- name: "{{ parser }} Confirm modified results"
|
- name: "Confirm modified results {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ nxos_ttp_vars['parsed'][0][0][0]['var'] == 'some_text' }}"
|
- "{{ nxos_ttp_vars['parsed'][0][0][0]['var'] == 'some_text' }}"
|
||||||
|
|
||||||
- name: "{{ parser }} Pass text and ttp_results modified"
|
- name: "Pass text and ttp_results modified {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.txt') }}"
|
||||||
parser:
|
parser:
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
format: yaml
|
format: yaml
|
||||||
register: nxos_ttp_results
|
register: nxos_ttp_results
|
||||||
|
|
||||||
- name: "{{ parser }} Confirm modified results"
|
- name: "Confirm modified results {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
nxos_xml_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_xml_parsed.json') | from_json }}"
|
nxos_xml_text_parsed: "{{ lookup('ansible.builtin.file', '{{ role_path }}/output/nxos_show_interface_xml_parsed.json') | from_json }}"
|
||||||
|
|
||||||
- name: "{{ parser }} Pass text and parse with xml"
|
- name: "Pass text and parse with xml {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.xml') }}"
|
text: "{{ lookup('ansible.builtin.file', '{{ role_path }}/files/nxos_show_interface.xml') }}"
|
||||||
parser:
|
parser:
|
||||||
|
@ -10,7 +11,7 @@
|
||||||
os: nxos
|
os: nxos
|
||||||
register: nxos_xml_text
|
register: nxos_xml_text
|
||||||
|
|
||||||
- name: "{{ parser }} Confirm response"
|
- name: "Confirm response {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "{{ parser }} Run command and parse with textfsm"
|
- name: "Run command and parse with textfsm {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
command: "ifconfig"
|
command: "ifconfig"
|
||||||
parser:
|
parser:
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
ansible.builtin.set_fact: myfact
|
ansible.builtin.set_fact: myfact
|
||||||
register: ifconfig_out
|
register: ifconfig_out
|
||||||
|
|
||||||
- name: "{{ parser }} Check parser output"
|
- name: "Check parser output {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: "{{ parser }} Run command and parse with ttp"
|
- name: "Run command and parse with ttp {{ parser }}"
|
||||||
ansible.utils.cli_parse:
|
ansible.utils.cli_parse:
|
||||||
command: "df -h"
|
command: "df -h"
|
||||||
parser:
|
parser:
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
ansible.builtin.set_fact: myfact
|
ansible.builtin.set_fact: myfact
|
||||||
register: df_h_out
|
register: df_h_out
|
||||||
|
|
||||||
- name: "{{ parser }} Check parser output"
|
- name: "Check parser output {{ parser }}"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item }}"
|
that: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"description": "This is a user template",
|
"description": "This is a user template",
|
||||||
"enabled": True,
|
"enabled": true,
|
||||||
"name": "GigabitEthernet0/1",
|
"name": "GigabitEthernet0/1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "This is a user template",
|
"description": "This is a user template",
|
||||||
"enabled": True,
|
"enabled": true,
|
||||||
"name": "GigabitEthernet0/2",
|
"name": "GigabitEthernet0/2",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ string in result.msg }}"
|
that: "{{ string in result.msg }}"
|
||||||
loop:
|
loop:
|
||||||
- "missing required arguments:"
|
- "missing required arguments:"
|
||||||
|
@ -12,13 +13,14 @@
|
||||||
- after
|
- after
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: string
|
loop_var: string
|
||||||
when: "{{result.msg|type_debug != 'list'}}"
|
when: "result.msg | type_debug != 'list'"
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "missing required arguments: after, before"
|
msg: "missing required arguments: after, before"
|
||||||
when: "{{result.msg|type_debug == 'list'}}"
|
when: "result.msg | type_debug == 'list'"
|
||||||
|
|
||||||
- name: Check argspec validation, skip_lines must be a dict
|
- name: Check argspec validation, skip_lines must be a dict
|
||||||
ansible.utils.fact_diff:
|
ansible.utils.fact_diff:
|
||||||
|
@ -31,10 +33,12 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ 'unable to convert to list' in result.msg }}"
|
that: "{{ 'unable to convert to list' in result.msg }}"
|
||||||
when: "{{result.msg|type_debug != 'list'}}"
|
when: "result.msg | type_debug != 'list'"
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ 'unable to convert to list' in result.msg[0] }}"
|
that: "{{ 'unable to convert to list' in result.msg[0] }}"
|
||||||
when: "{{result.msg|type_debug == 'list'}}"
|
when: "result.msg | type_debug == 'list'"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
before:
|
before:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
|
@ -75,7 +76,7 @@
|
||||||
|
|
||||||
#### Show the difference between complex object using restconf
|
#### Show the difference between complex object using restconf
|
||||||
# ansible_connection: ansible.netcommon.httpapi
|
# ansible_connection: ansible.netcommon.httpapi
|
||||||
# ansible_httpapi_use_ssl: True
|
# ansible_httpapi_use_ssl: true
|
||||||
# ansible_httpapi_validate_certs: False
|
# ansible_httpapi_validate_certs: False
|
||||||
# ansible_network_os: ansible.netcommon.restconf
|
# ansible_network_os: ansible.netcommon.restconf
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "The regex '+', is not valid"
|
msg: "The regex '+', is not valid"
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ data|ansible.utils.from_xml() }}"
|
msg: "{{ data|ansible.utils.from_xml() }}"
|
||||||
|
|
||||||
- name: Integration tests with and without default engine as xmltodict and
|
- name: Integration tests with and without default engine as xmltodict and
|
||||||
|
@ -33,7 +34,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "Error when using plugin 'from_xml': Input Xml is not valid"
|
msg: "Error when using plugin 'from_xml': Input Xml is not valid"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -13,7 +14,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "missing required arguments: path"
|
msg: "missing required arguments: path"
|
||||||
|
@ -24,7 +26,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ item in result.msg }}"
|
that: "{{ item in result.msg }}"
|
||||||
loop:
|
loop:
|
||||||
- "missing required arguments:"
|
- "missing required arguments:"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -66,7 +67,7 @@
|
||||||
# ok: [nxos101] => (item=a.b.c.d[1]) =>
|
# ok: [nxos101] => (item=a.b.c.d[1]) =>
|
||||||
# msg: The value of path a.b.c.d[1] in vars is 1
|
# msg: The value of path a.b.c.d[1] in vars is 1
|
||||||
# ok: [nxos101] => (item=a.b.c.e[0]) =>
|
# ok: [nxos101] => (item=a.b.c.e[0]) =>
|
||||||
# msg: The value of path a.b.c.e[0] in vars is True
|
# msg: The value of path a.b.c.e[0] in vars is true
|
||||||
# ok: [nxos101] => (item=a.b.c.e[1]) =>
|
# ok: [nxos101] => (item=a.b.c.e[1]) =>
|
||||||
# msg: The value of path a.b.c.e[1] in vars is False
|
# msg: The value of path a.b.c.e[1] in vars is False
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -66,7 +67,7 @@
|
||||||
# ok: [nxos101] => (item=a.b.c.d[1]) =>
|
# ok: [nxos101] => (item=a.b.c.d[1]) =>
|
||||||
# msg: The value of path a.b.c.d[1] in vars is 1
|
# msg: The value of path a.b.c.d[1] in vars is 1
|
||||||
# ok: [nxos101] => (item=a.b.c.e[0]) =>
|
# ok: [nxos101] => (item=a.b.c.e[0]) =>
|
||||||
# msg: The value of path a.b.c.e[0] in vars is True
|
# msg: The value of path a.b.c.e[0] in vars is true
|
||||||
# ok: [nxos101] => (item=a.b.c.e[1]) =>
|
# ok: [nxos101] => (item=a.b.c.e[1]) =>
|
||||||
# msg: The value of path a.b.c.e[1] in vars is False
|
# msg: The value of path a.b.c.e[1] in vars is False
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -40,7 +41,8 @@
|
||||||
- result: '{{ lookup(''ansible.utils.get_path'', a, ''b["c"]'') }}'
|
- result: '{{ lookup(''ansible.utils.get_path'', a, ''b["c"]'') }}'
|
||||||
expected: "{{ a.b.c }}"
|
expected: "{{ a.b.c }}"
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -51,9 +53,9 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item.result == item.expected }}"
|
that: "{{ item.result == item.expected }}"
|
||||||
loop:
|
loop:
|
||||||
- result: "{{ vars|ansible.utils.get_path('a.b.c.d[0]', wantlist=True) }}"
|
- result: "{{ vars|ansible.utils.get_path('a.b.c.d[0]', wantlist=true) }}"
|
||||||
expected:
|
expected:
|
||||||
- "{{ a.b.c.d[0] }}"
|
- "{{ a.b.c.d[0] }}"
|
||||||
- result: "{{ lookup('ansible.utils.get_path', vars, 'a.b.c.d[0]', wantlist=True) }}"
|
- result: "{{ lookup('ansible.utils.get_path', vars, 'a.b.c.d[0]', wantlist=true) }}"
|
||||||
expected:
|
expected:
|
||||||
- "{{ a.b.c.d[0] }}"
|
- "{{ a.b.c.d[0] }}"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
complex:
|
complex:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
|
@ -17,7 +18,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "cannot be converted to a list"
|
msg: "cannot be converted to a list"
|
||||||
|
@ -28,7 +30,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "missing required arguments: test"
|
msg: "missing required arguments: test"
|
||||||
|
@ -39,7 +42,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "cannot be converted to a list"
|
msg: "cannot be converted to a list"
|
||||||
|
@ -50,7 +54,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ item in result.msg }}"
|
that: "{{ item in result.msg }}"
|
||||||
loop:
|
loop:
|
||||||
- "missing required arguments:"
|
- "missing required arguments:"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
#### Simple examples
|
#### Simple examples
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
data:
|
data:
|
||||||
- 1
|
- 1
|
||||||
- 2
|
- 2
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
|
|
||||||
- name: Find the index of 2, ensure list is returned
|
- name: Find the index of 2, ensure list is returned
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
indices: "{{ data|ansible.utils.index_of('eq', 2, wantlist=True) }}"
|
indices: "{{ data|ansible.utils.index_of('eq', 2, wantlist=true) }}"
|
||||||
|
|
||||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||||
# ok: [nxos101] => changed=false
|
# ok: [nxos101] => changed=false
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
|
|
||||||
- name: Find the index of 3 using the long format
|
- name: Find the index of 3 using the long format
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
indices: "{{ data|ansible.utils.index_of(test='eq', value=value, wantlist=True) }}"
|
indices: "{{ data|ansible.utils.index_of(test='eq', value=value, wantlist=true) }}"
|
||||||
vars:
|
vars:
|
||||||
value: 3
|
value: 3
|
||||||
|
|
||||||
|
@ -53,7 +54,8 @@
|
||||||
|
|
||||||
#### Working with lists of dictionaries
|
#### Working with lists of dictionaries
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
data:
|
data:
|
||||||
- name: sw01.example.lan
|
- name: sw01.example.lan
|
||||||
type: switch
|
type: switch
|
||||||
|
@ -93,7 +95,8 @@
|
||||||
msg: "The device named {{ data[item].name }} is a {{ data[item].type }}"
|
msg: "The device named {{ data[item].name }} is a {{ data[item].type }}"
|
||||||
loop: "{{ data|ansible.utils.index_of('regex', expression, 'name') }}"
|
loop: "{{ data|ansible.utils.index_of('regex', expression, 'name') }}"
|
||||||
vars:
|
vars:
|
||||||
expression: '\.corp$' # ends with .corp
|
expression: '\.corp$'
|
||||||
|
# ends with .corp
|
||||||
|
|
||||||
# TASK [Find the index of all devices with a .corp name] *********************
|
# TASK [Find the index of all devices with a .corp name] *********************
|
||||||
# ok: [nxos101] => (item=2) =>
|
# ok: [nxos101] => (item=2) =>
|
||||||
|
@ -126,7 +129,7 @@
|
||||||
# vars:
|
# vars:
|
||||||
# found: []
|
# found: []
|
||||||
# ip: '192.168.101.'
|
# ip: '192.168.101.'
|
||||||
# address: "{{ item.1.ipv4|d([])|ansible.utils.index_of('search', ip, 'address', wantlist=True) }}"
|
# address: "{{ item.1.ipv4|d([])|ansible.utils.index_of('search', ip, 'address', wantlist=true) }}"
|
||||||
# entry:
|
# entry:
|
||||||
# - interface_idx: "{{ item.0 }}"
|
# - interface_idx: "{{ item.0 }}"
|
||||||
# address_idxs: "{{ address }}"
|
# address_idxs: "{{ address }}"
|
||||||
|
@ -153,7 +156,8 @@
|
||||||
|
|
||||||
#### Working with deeply nested data
|
#### Working with deeply nested data
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
data:
|
data:
|
||||||
interfaces:
|
interfaces:
|
||||||
interface:
|
interface:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
#### Simple examples
|
#### Simple examples
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
data:
|
data:
|
||||||
- 1
|
- 1
|
||||||
- 2
|
- 2
|
||||||
|
@ -17,7 +18,7 @@
|
||||||
|
|
||||||
- name: Find the index of 2, ensure list is returned
|
- name: Find the index of 2, ensure list is returned
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2, wantlist=True) }}"
|
indices: "{{ lookup('ansible.utils.index_of', data, 'eq', 2, wantlist=true) }}"
|
||||||
|
|
||||||
# TASK [Find the index of 2, ensure list is returned] ************************
|
# TASK [Find the index of 2, ensure list is returned] ************************
|
||||||
# ok: [nxos101] => changed=false
|
# ok: [nxos101] => changed=false
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
|
|
||||||
- name: Find the index of 3 using the long format
|
- name: Find the index of 3 using the long format
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
indices: "{{ lookup('ansible.utils.index_of', data=data, test='eq', value=value, wantlist=True) }}"
|
indices: "{{ lookup('ansible.utils.index_of', data=data, test='eq', value=value, wantlist=true) }}"
|
||||||
vars:
|
vars:
|
||||||
value: 3
|
value: 3
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@
|
||||||
# indices:
|
# indices:
|
||||||
# - 2
|
# - 2
|
||||||
|
|
||||||
#- name: Find numbers greater than 1, using loop
|
# - name: Find numbers greater than 1, using loop
|
||||||
# ansible.builtin.debug:
|
# ansible.builtin.debug:
|
||||||
# msg: "{{ data[item] }} is {{ test }} than {{ value }}"
|
# msg: "{{ data[item] }} is {{ test }} than {{ value }}"
|
||||||
# loop: "{{ lookup('ansible.utils.index_of', data, test, value) }}"
|
# loop: "{{ lookup('ansible.utils.index_of', data, test, value) }}"
|
||||||
|
@ -69,7 +70,8 @@
|
||||||
|
|
||||||
#### Working with lists of dictionaries
|
#### Working with lists of dictionaries
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
data:
|
data:
|
||||||
- name: sw01.example.lan
|
- name: sw01.example.lan
|
||||||
type: switch
|
type: switch
|
||||||
|
@ -109,7 +111,8 @@
|
||||||
msg: "The device named {{ data[item].name }} is a {{ data[item].type }}"
|
msg: "The device named {{ data[item].name }} is a {{ data[item].type }}"
|
||||||
loop: "{{ lookup('ansible.utils.index_of', data, 'regex', expression, 'name') }}"
|
loop: "{{ lookup('ansible.utils.index_of', data, 'regex', expression, 'name') }}"
|
||||||
vars:
|
vars:
|
||||||
expression: '\.corp$' # ends with .corp
|
expression: '\.corp$'
|
||||||
|
# ends with .corp
|
||||||
|
|
||||||
# TASK [Find the index of all devices with a .corp name] *********************
|
# TASK [Find the index of all devices with a .corp name] *********************
|
||||||
# ok: [nxos101] => (item=2) =>
|
# ok: [nxos101] => (item=2) =>
|
||||||
|
@ -142,7 +145,7 @@
|
||||||
# vars:
|
# vars:
|
||||||
# found: []
|
# found: []
|
||||||
# ip: '192.168.101.'
|
# ip: '192.168.101.'
|
||||||
# address: "{{ lookup('ansible.utils.index_of', item.1.ipv4|d([]), 'search', ip, 'address', wantlist=True) }}"
|
# address: "{{ lookup('ansible.utils.index_of', item.1.ipv4|d([]), 'search', ip, 'address', wantlist=true) }}"
|
||||||
# entry:
|
# entry:
|
||||||
# - interface_idx: "{{ item.0 }}"
|
# - interface_idx: "{{ item.0 }}"
|
||||||
# address_idxs: "{{ address }}"
|
# address_idxs: "{{ address }}"
|
||||||
|
@ -169,7 +172,8 @@
|
||||||
|
|
||||||
#### Working with deeply nested data
|
#### Working with deeply nested data
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
data:
|
data:
|
||||||
interfaces:
|
interfaces:
|
||||||
interface:
|
interface:
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
complex:
|
complex:
|
||||||
a:
|
a:
|
||||||
- true
|
- true
|
||||||
|
@ -27,13 +28,13 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item.test == item.result }}"
|
that: "{{ item.test == item.result }}"
|
||||||
loop:
|
loop:
|
||||||
- test: "{{ complex.a|ansible.utils.index_of('eq', True) }}"
|
- test: "{{ complex.a|ansible.utils.index_of('eq', true) }}"
|
||||||
result: [0, 1]
|
result: [0, 1]
|
||||||
- test: "{{ lookup('ansible.utils.index_of', complex.a, 'eq', True) }}"
|
- test: "{{ lookup('ansible.utils.index_of', complex.a, 'eq', true) }}"
|
||||||
result: [0, 1]
|
result: [0, 1]
|
||||||
- test: "{{ complex.a|ansible.utils.index_of('in', [True, False]) }}"
|
- test: "{{ complex.a|ansible.utils.index_of('in', [true, False]) }}"
|
||||||
result: [0, 1, 2]
|
result: [0, 1, 2]
|
||||||
- test: "{{ lookup('ansible.utils.index_of', complex.a, 'in', [True, False]) }}"
|
- test: "{{ lookup('ansible.utils.index_of', complex.a, 'in', [true, False]) }}"
|
||||||
result: [0, 1, 2]
|
result: [0, 1, 2]
|
||||||
# These are commented out due to jinja < 2.11 w/ 2.9, 'integer' not avaialable
|
# These are commented out due to jinja < 2.11 w/ 2.9, 'integer' not avaialable
|
||||||
# can be enabled at a later date
|
# can be enabled at a later date
|
||||||
|
@ -57,7 +58,8 @@
|
||||||
- test: "{{ lookup('ansible.utils.index_of', complex.d, 'match', '.*d$') }}"
|
- test: "{{ lookup('ansible.utils.index_of', complex.d, 'match', '.*d$') }}"
|
||||||
result: [0, 1]
|
result: [0, 1]
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
complex:
|
complex:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
|
@ -77,27 +79,27 @@
|
||||||
result: "0"
|
result: "0"
|
||||||
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', 'ansible', 'e1') }}"
|
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', 'ansible', 'e1') }}"
|
||||||
result: "0"
|
result: "0"
|
||||||
- test: "{{ complex.a.b.c.d|ansible.utils.index_of('eq', 'ansible', 'e1', wantlist=True) }}"
|
- test: "{{ complex.a.b.c.d|ansible.utils.index_of('eq', 'ansible', 'e1', wantlist=true) }}"
|
||||||
result: [0]
|
result: [0]
|
||||||
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', 'ansible', 'e1', wantlist=True) }}"
|
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', 'ansible', 'e1', wantlist=true) }}"
|
||||||
result: [0]
|
result: [0]
|
||||||
|
|
||||||
- name: Test a missing key in the list of dictionaries
|
- name: Test a missing key in the list of dictionaries
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item.test == item.result }}"
|
that: "{{ item.test == item.result }}"
|
||||||
loop:
|
loop:
|
||||||
- test: "{{ complex.a.b.c.d|ansible.utils.index_of('eq', True, 'e2') }}"
|
- test: "{{ complex.a.b.c.d|ansible.utils.index_of('eq', true, 'e2') }}"
|
||||||
result: "0"
|
result: "0"
|
||||||
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', True, 'e2') }}"
|
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', true, 'e2') }}"
|
||||||
result: "0"
|
result: "0"
|
||||||
|
|
||||||
- name: Test a missing key in the list of dictionaries, fail on missing
|
- name: Test a missing key in the list of dictionaries, fail on missing
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item.test == item.result }}"
|
that: "{{ item.test == item.result }}"
|
||||||
loop:
|
loop:
|
||||||
- test: "{{ complex.a.b.c.d|ansible.utils.index_of('eq', True, 'e2', fail_on_missing=True) }}"
|
- test: "{{ complex.a.b.c.d|ansible.utils.index_of('eq', true, 'e2', fail_on_missing=true) }}"
|
||||||
result: "0"
|
result: "0"
|
||||||
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', True, 'e2', fail_on_missing=True) }}"
|
- test: "{{ lookup('ansible.utils.index_of', complex.a.b.c.d, 'eq', true, 'e2', fail_on_missing=true) }}"
|
||||||
result: "0"
|
result: "0"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
- 192.168.32.0/24
|
- 192.168.32.0/24
|
||||||
- fe80::100/10
|
- fe80::100/10
|
||||||
- "42540766412265424405338506004571095040/64"
|
- "42540766412265424405338506004571095040/64"
|
||||||
- True
|
- true
|
||||||
|
|
||||||
- name: ipaddr filter with empty string query
|
- name: ipaddr filter with empty string query
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
@ -58,7 +58,8 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ result6 == '192.168.255.123' }}"
|
that: "{{ result6 == '192.168.255.123' }}"
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "Test int input for ipaddr filter"
|
msg: "Test int input for ipaddr filter"
|
||||||
|
|
||||||
- name: set fact 1
|
- name: set fact 1
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
- 192.168.32.0/24
|
- 192.168.32.0/24
|
||||||
- fe80::100/10
|
- fe80::100/10
|
||||||
- "42540766412265424405338506004571095040/64"
|
- "42540766412265424405338506004571095040/64"
|
||||||
- True
|
- true
|
||||||
|
|
||||||
- name: ipv4 filter
|
- name: ipv4 filter
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
- ::ffff:192.24.2.1/128
|
- ::ffff:192.24.2.1/128
|
||||||
- 192.168.32.0/24
|
- 192.168.32.0/24
|
||||||
- fe80::100/10
|
- fe80::100/10
|
||||||
- True
|
- true
|
||||||
|
|
||||||
- name: ipv6 filter
|
- name: ipv6 filter
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
- 192.168.32.0/24
|
- 192.168.32.0/24
|
||||||
- fe80::100/10
|
- fe80::100/10
|
||||||
- "42540766412265424405338506004571095040/64"
|
- "42540766412265424405338506004571095040/64"
|
||||||
- True
|
- true
|
||||||
|
|
||||||
- name: ipwrap filter
|
- name: ipwrap filter
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
- name: Assert result for network_in_network.
|
- name: Assert result for network_in_network.
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ result1 == True }}"
|
that: "{{ result1 == true }}"
|
||||||
|
|
||||||
- name: network_in_network filter test2
|
- name: network_in_network filter test2
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
@ -21,4 +21,4 @@
|
||||||
|
|
||||||
- name: Assert result for network_in_network
|
- name: Assert result for network_in_network
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ result1 == True }}"
|
that: "{{ result1 == true }}"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
- name: Assert result for network_in_usable.
|
- name: Assert result for network_in_usable.
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ result1 == True }}"
|
that: "{{ result1 == true }}"
|
||||||
|
|
||||||
- name: network_in_usable filter test2
|
- name: network_in_usable filter test2
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
|
@ -21,4 +21,4 @@
|
||||||
|
|
||||||
- name: Assert result for network_in_usable
|
- name: Assert result for network_in_usable
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ result1 == True }}"
|
that: "{{ result1 == true }}"
|
||||||
|
|
|
@ -39,7 +39,7 @@ ipwrap_result1:
|
||||||
- "192.168.32.0/24"
|
- "192.168.32.0/24"
|
||||||
- "[fe80::100]/10"
|
- "[fe80::100]/10"
|
||||||
- "[2001:db8:32c:faad::]/64"
|
- "[2001:db8:32c:faad::]/64"
|
||||||
- True
|
- true
|
||||||
|
|
||||||
ipv6_result1:
|
ipv6_result1:
|
||||||
- "::ffff:192.168.32.0/120"
|
- "::ffff:192.168.32.0/120"
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
mtu: 600
|
mtu: 600
|
||||||
is_enabled: false
|
is_enabled: false
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ data|ansible.utils.keep_keys(target=['desc', 'interface_'], matching_parameter= 'starts_with') }}"
|
msg: "{{ data|ansible.utils.keep_keys(target=['desc', 'interface_'], matching_parameter= 'starts_with') }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -60,7 +61,8 @@
|
||||||
mtu: 600
|
mtu: 600
|
||||||
is_enabled: false
|
is_enabled: false
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ data|ansible.utils.keep_keys(target=['interface_name', 'is_enabled', 'vlan_id']) }}"
|
msg: "{{ data|ansible.utils.keep_keys(target=['interface_name', 'is_enabled', 'vlan_id']) }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
- name: "resolvable: Check if {{ good_name }} is resolvable or not"
|
- name: "resolvable: Check if good_name is resolvable or not"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ good_name is ansible.utils.resolvable }}"
|
that: "{{ good_name is ansible.utils.resolvable }}"
|
||||||
|
|
||||||
- name: "resolvable: Check if {{ ipv4_localhost }} is resolvable or not"
|
- name: "resolvable: Check if ipv4_localhost is resolvable or not"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ ipv4_localhost is ansible.utils.resolvable }}"
|
that: "{{ ipv4_localhost is ansible.utils.resolvable }}"
|
||||||
|
|
||||||
- name: "resolvable: Check if {{ ipv6_localhost }} is resolvable or not"
|
- name: "resolvable: Check if ipv6_localhost is resolvable or not"
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ ipv6_localhost is ansible.utils.resolvable }}"
|
that: "{{ ipv6_localhost is ansible.utils.resolvable }}"
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "START param_list_compare integration tests on connection={{ ansible_connection }}"
|
msg: "START param_list_compare integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: Setup supported resource module list json
|
- name: Setup supported resource module list json
|
||||||
|
@ -52,5 +53,7 @@
|
||||||
that:
|
that:
|
||||||
- "{{ expected_network_resources | symmetric_difference(final_network_resources['actionable']) |length\
|
- "{{ expected_network_resources | symmetric_difference(final_network_resources['actionable']) |length\
|
||||||
\ == 0 }}"
|
\ == 0 }}"
|
||||||
- ansible.builtin.debug:
|
|
||||||
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "END param_list_compare integration tests on connection={{ ansible_connection }}"
|
msg: "END param_list_compare integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -29,7 +29,8 @@
|
||||||
mtu: 600
|
mtu: 600
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ data|ansible.utils.remove_keys(target=['notes', 'comment']) }}"
|
msg: "{{ data|ansible.utils.remove_keys(target=['notes', 'comment']) }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
mtu: 600
|
mtu: 600
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ data|ansible.utils.replace_keys(target=[{'before':'interface_name', 'after':'name'}]) }}"
|
msg: "{{ data|ansible.utils.replace_keys(target=[{'before':'interface_name', 'after':'name'}]) }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -12,9 +13,12 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
var: result
|
var: result
|
||||||
- ansible.builtin.assert:
|
|
||||||
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "'5' is not a valid boolean"
|
msg: "'5' is not a valid boolean"
|
||||||
|
@ -25,9 +29,12 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
var: result
|
var: result
|
||||||
- ansible.builtin.assert:
|
|
||||||
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "missing required arguments: var"
|
msg: "missing required arguments: var"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b: []
|
b: []
|
||||||
c: {}
|
c: {}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
#### Simple examples
|
#### Simple examples
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -11,7 +12,8 @@
|
||||||
- true
|
- true
|
||||||
- false
|
- false
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
paths: "{{ a|ansible.utils.to_paths }}"
|
paths: "{{ a|ansible.utils.to_paths }}"
|
||||||
|
|
||||||
# TASK [ansible.builtin.set_fact] ********************************************
|
# TASK [ansible.builtin.set_fact] ********************************************
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
---
|
---
|
||||||
#### Simple examples
|
#### Simple examples
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -11,7 +12,8 @@
|
||||||
- true
|
- true
|
||||||
- false
|
- false
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
paths: "{{ lookup('ansible.utils.to_paths', a) }}"
|
paths: "{{ lookup('ansible.utils.to_paths', a) }}"
|
||||||
|
|
||||||
# TASK [ansible.builtin.set_fact] ********************************************
|
# TASK [ansible.builtin.set_fact] ********************************************
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -28,7 +29,8 @@
|
||||||
a.b.c.d[0]: 0
|
a.b.c.d[0]: 0
|
||||||
a.b.c.d[1]: 1
|
a.b.c.d[1]: 1
|
||||||
|
|
||||||
- ansible.builtin.set_fact:
|
- name: Set fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
a:
|
a:
|
||||||
b:
|
b:
|
||||||
c:
|
c:
|
||||||
|
@ -39,15 +41,15 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that: "{{ item.result == item.expected }}"
|
that: "{{ item.result == item.expected }}"
|
||||||
loop:
|
loop:
|
||||||
- result: "{{ a|ansible.utils.to_paths(wantlist=True) }}"
|
- result: "{{ a|ansible.utils.to_paths(wantlist=true) }}"
|
||||||
expected:
|
expected:
|
||||||
- b.c.d[0]: 0
|
- b.c.d[0]: 0
|
||||||
- result: "{{ lookup('ansible.utils.to_paths', a, wantlist=True) }}"
|
- result: "{{ lookup('ansible.utils.to_paths', a, wantlist=true) }}"
|
||||||
expected:
|
expected:
|
||||||
- b.c.d[0]: 0
|
- b.c.d[0]: 0
|
||||||
- result: "{{ a|ansible.utils.to_paths(wantlist=True, prepend='a') }}"
|
- result: "{{ a|ansible.utils.to_paths(wantlist=true, prepend='a') }}"
|
||||||
expected:
|
expected:
|
||||||
- a.b.c.d[0]: 0
|
- a.b.c.d[0]: 0
|
||||||
- result: "{{ lookup('ansible.utils.to_paths', a, wantlist=True, prepend='a') }}"
|
- result: "{{ lookup('ansible.utils.to_paths', a, wantlist=true, prepend='a') }}"
|
||||||
expected:
|
expected:
|
||||||
- a.b.c.d[0]: 0
|
- a.b.c.d[0]: 0
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
---
|
---
|
||||||
- name: Setup xml and expected json
|
- name: Setup xml
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
data:
|
data:
|
||||||
"interface-configurations":
|
"interface-configurations":
|
||||||
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg"
|
"@xmlns": "http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg"
|
||||||
"interface-configuration":
|
"interface-configuration":
|
||||||
output: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<interface-configurations xmlns=\"http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg\">\n\t<interface-configuration></interface-configuration>\n</interface-configurations>"
|
|
||||||
|
|
||||||
- ansible.builtin.debug:
|
- name: Debug
|
||||||
|
ansible.builtin.debug:
|
||||||
msg: "{{ data|ansible.utils.to_xml() }}"
|
msg: "{{ data|ansible.utils.to_xml() }}"
|
||||||
|
|
||||||
- name: Integration tests with and without default engine as xmltodict and
|
- name: Integration tests with and without default engine as xmltodict and
|
||||||
|
@ -29,7 +29,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result.msg }}"
|
that: "{{ msg in result.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "Error when using plugin 'to_xml': engine: dicttoxml is not supported"
|
msg: "Error when using plugin 'to_xml': engine: dicttoxml is not supported"
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
output: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<interface-configurations xmlns=\"http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg\">\n\t<interface-configuration></interface-configuration>\n</interface-configurations>"
|
|
@ -16,7 +16,8 @@
|
||||||
value: 20
|
value: 20
|
||||||
register: updated
|
register: updated
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ updated.a == expected.a }}"
|
that: "{{ updated.a == expected.a }}"
|
||||||
vars:
|
vars:
|
||||||
expected:
|
expected:
|
||||||
|
@ -38,7 +39,8 @@
|
||||||
- true
|
- true
|
||||||
register: updated
|
register: updated
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ updated.a == expected.a }}"
|
that: "{{ updated.a == expected.a }}"
|
||||||
vars:
|
vars:
|
||||||
expected:
|
expected:
|
||||||
|
@ -58,7 +60,8 @@
|
||||||
index: "{{ a.b.c|ansible.utils.index_of('eq', 2) }}"
|
index: "{{ a.b.c|ansible.utils.index_of('eq', 2) }}"
|
||||||
register: updated
|
register: updated
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ updated.a == expected.a }}"
|
that: "{{ updated.a == expected.a }}"
|
||||||
vars:
|
vars:
|
||||||
expected:
|
expected:
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result1
|
register: result1
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result1.msg }}"
|
that: "{{ msg in result1.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "does not appear to be an IPv4 or IPv6 network"
|
msg: "does not appear to be an IPv4 or IPv6 network"
|
||||||
|
@ -16,7 +17,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result2
|
register: result2
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result2.msg }}"
|
that: "{{ msg in result2.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "does not appear to be an IPv4 or IPv6 network"
|
msg: "does not appear to be an IPv4 or IPv6 network"
|
||||||
|
@ -27,7 +29,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result3
|
register: result3
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result3.msg }}"
|
that: "{{ msg in result3.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "has host bits set"
|
msg: "has host bits set"
|
||||||
|
@ -38,7 +41,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result4
|
register: result4
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result4.msg }}"
|
that: "{{ msg in result4.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "does not appear to be an IPv4 or IPv6 network"
|
msg: "does not appear to be an IPv4 or IPv6 network"
|
||||||
|
@ -49,7 +53,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result5
|
register: result5
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result5.msg }}"
|
that: "{{ msg in result5.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "does not appear to be an IPv4 or IPv6 network"
|
msg: "does not appear to be an IPv4 or IPv6 network"
|
||||||
|
@ -60,7 +65,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result6
|
register: result6
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result6.msg }}"
|
that: "{{ msg in result6.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "does not appear to be an IPv4 or IPv6 network"
|
msg: "does not appear to be an IPv4 or IPv6 network"
|
||||||
|
@ -71,7 +77,8 @@
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
register: result7
|
register: result7
|
||||||
|
|
||||||
- ansible.builtin.assert:
|
- name: Assert
|
||||||
|
ansible.builtin.assert:
|
||||||
that: "{{ msg in result7.msg }}"
|
that: "{{ msg in result7.msg }}"
|
||||||
vars:
|
vars:
|
||||||
msg: "does not appear to be an IPv4 or IPv6 network"
|
msg: "does not appear to be an IPv4 or IPv6 network"
|
||||||
|
|
|
@ -10,5 +10,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
|
@ -7,5 +7,6 @@
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
register: found
|
register: found
|
||||||
|
|
||||||
- ansible.builtin.include_tasks: "{{ item.path }}"
|
- name: Include tasks
|
||||||
|
ansible.builtin.include_tasks: "{{ item.path }}"
|
||||||
loop: "{{ found.files }}"
|
loop: "{{ found.files }}"
|
||||||
|
|
Loading…
Reference in New Issue