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