From aa1d8bc6b744f08988cb20496512b0e600a6ca91 Mon Sep 17 00:00:00 2001 From: Ajinkya Udgirkar Date: Tue, 23 Apr 2024 17:24:54 +0530 Subject: [PATCH] Update `order` schema to work with jinja template (#4121) --- src/ansiblelint/schemas/ansible.json | 23 +++++++++++++++-------- src/ansiblelint/schemas/playbook.json | 23 +++++++++++++++-------- test/schemas/test/playbooks/order.yml | 10 ++++++++++ 3 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 test/schemas/test/playbooks/order.yml diff --git a/src/ansiblelint/schemas/ansible.json b/src/ansiblelint/schemas/ansible.json index efba283e9c..50ded20094 100644 --- a/src/ansiblelint/schemas/ansible.json +++ b/src/ansiblelint/schemas/ansible.json @@ -545,15 +545,22 @@ "$ref": "#/$defs/templated-boolean" }, "order": { - "enum": [ - "default", - "sorted", - "reverse_sorted", - "reverse_inventory", - "shuffle" + "oneOf": [ + { + "enum": [ + "default", + "sorted", + "reverse_sorted", + "reverse_inventory", + "shuffle" + ], + "type": "string" + }, + { + "$ref": "#/$defs/full-jinja" + } ], - "title": "Order", - "type": "string" + "title": "Order" }, "port": { "$ref": "#/$defs/templated-integer", diff --git a/src/ansiblelint/schemas/playbook.json b/src/ansiblelint/schemas/playbook.json index 7ed7edd0ce..a1a31e811a 100644 --- a/src/ansiblelint/schemas/playbook.json +++ b/src/ansiblelint/schemas/playbook.json @@ -555,15 +555,22 @@ "$ref": "#/$defs/templated-boolean" }, "order": { - "enum": [ - "default", - "sorted", - "reverse_sorted", - "reverse_inventory", - "shuffle" + "oneOf": [ + { + "enum": [ + "default", + "sorted", + "reverse_sorted", + "reverse_inventory", + "shuffle" + ], + "type": "string" + }, + { + "$ref": "#/$defs/full-jinja" + } ], - "title": "Order", - "type": "string" + "title": "Order" }, "port": { "$ref": "#/$defs/templated-integer", diff --git a/test/schemas/test/playbooks/order.yml b/test/schemas/test/playbooks/order.yml new file mode 100644 index 0000000000..a138b477f1 --- /dev/null +++ b/test/schemas/test/playbooks/order.yml @@ -0,0 +1,10 @@ +--- +- name: Test + hosts: all + order: "{{ host_order | default('shuffle') }}" + gather_facts: false + serial: 1 + tasks: + - name: ABC + ansible.builtin.debug: + msg: "hello"