---
- debug: msg="START cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection }}"

- name: setup
  iosxr_config:
    lines:
      - class-map match-any c1
      - match precedence 7
      - policy-map p1
      - class c1
      - set precedence 2
    before: ['no policy-map p1', 'no class-map match-any c1']
    match: none

- name: configure sub level command using strict match
  iosxr_config:
    lines:
      - set precedence 5
      - police rate percent 10
    parents: ['policy-map p1', 'class c1']
    match: strict
  register: result

- assert:
    that:
      - "result.changed == true"
      - "'set precedence 5' in result.commands"
      - "'police rate percent 10' in result.commands"

- name: change sub level command order and config with strict match
  iosxr_config:
    lines:
      - police rate percent 10
      - set precedence 5
    parents: ['policy-map p1', 'class c1']
    match: strict
  register: result

- assert:
    that:
      - "result.changed == true"
      - "'set precedence 5' in result.commands"
      - "'police rate percent 10' in result.commands"

- name: Config sub level command with strict match (Idempotency)
  iosxr_config:
    lines:
#IOSxr does not change order of class action if reconfigured
#so we have to use old order for Idempotency
      - set precedence 5
      - police rate percent 10
    parents: ['policy-map p1', 'class c1']
    match: strict
  register: result

- assert:
    that:
      - "result.changed == false"

- name: teardown
  iosxr_config:
    lines:
      - no policy-map p1
      - no class-map match-any c1
    match: none

- debug: msg="END cli/sublevel_strict_mul_parents.yaml on connection={{ ansible_connection }}"
