From 3aa123c5b2b145e57776e297ac62e133b3f6993e Mon Sep 17 00:00:00 2001 From: Thomas Wiest Date: Tue, 7 Feb 2017 16:39:51 -0500 Subject: Fixed ansible module unit and integration tests and added runners. --- roles/lib_openshift/library/oc_label.py | 2 +- roles/lib_openshift/src/ansible/oc_label.py | 2 +- .../src/test/generate-and-run-tests.sh | 54 +++++ .../src/test/integration/oadm_manage_node.yml | 27 ++- .../src/test/integration/oc_label.yml | 59 +++--- .../src/test/integration/oc_service.yml | 2 +- roles/lib_utils/src/test/generate-and-run-tests.sh | 42 ++++ roles/lib_utils/src/test/integration/yedit.yml | 222 +++++++++++++++++++++ .../lib_utils/src/test/integration/yedit_test.yml | 221 -------------------- 9 files changed, 375 insertions(+), 256 deletions(-) create mode 100755 roles/lib_openshift/src/test/generate-and-run-tests.sh create mode 100755 roles/lib_utils/src/test/generate-and-run-tests.sh create mode 100755 roles/lib_utils/src/test/integration/yedit.yml delete mode 100755 roles/lib_utils/src/test/integration/yedit_test.yml (limited to 'roles') diff --git a/roles/lib_openshift/library/oc_label.py b/roles/lib_openshift/library/oc_label.py index f2f5787f5..a650049ee 100644 --- a/roles/lib_openshift/library/oc_label.py +++ b/roles/lib_openshift/library/oc_label.py @@ -1552,7 +1552,7 @@ def main(): state=dict(default='present', type='str', choices=['present', 'absent', 'list', 'add']), debug=dict(default=False, type='bool'), - kind=dict(default='node', type='str', required=True, + kind=dict(default='node', type='str', choices=['node', 'pod', 'namespace']), name=dict(default=None, type='str'), namespace=dict(default=None, type='str'), diff --git a/roles/lib_openshift/src/ansible/oc_label.py b/roles/lib_openshift/src/ansible/oc_label.py index 28f004621..84c5e336a 100644 --- a/roles/lib_openshift/src/ansible/oc_label.py +++ b/roles/lib_openshift/src/ansible/oc_label.py @@ -10,7 +10,7 @@ def main(): state=dict(default='present', type='str', choices=['present', 'absent', 'list', 'add']), debug=dict(default=False, type='bool'), - kind=dict(default='node', type='str', required=True, + kind=dict(default='node', type='str', choices=['node', 'pod', 'namespace']), name=dict(default=None, type='str'), namespace=dict(default=None, type='str'), diff --git a/roles/lib_openshift/src/test/generate-and-run-tests.sh b/roles/lib_openshift/src/test/generate-and-run-tests.sh new file mode 100755 index 000000000..cd7571372 --- /dev/null +++ b/roles/lib_openshift/src/test/generate-and-run-tests.sh @@ -0,0 +1,54 @@ +#!/bin/bash -e + + +if [ $# -ne 1 ] ; then + echo "Usage: $(basename $0) " + exit 1 +fi + +MASTER=$1 + + + +# Put us in the same dir as the script. +cd $(dirname $0) + + +echo +echo "Running lib_utils generate-and-run-tests.sh" +echo "-------------------------------------------" +../../../lib_utils/src/test/generate-and-run-tests.sh + + +echo +echo "Running lib_openshift generate" +echo "------------------------------" +../generate.py + + +echo +echo "Running lib_openshift Unit Tests" +echo "----------------------------" +cd unit + +for test in *.py; do + echo + echo "--------------------------------------------------------------------------------" + echo + echo "Running $test..." + ./$test +done + + +echo +echo "Running lib_openshift Integration Tests" +echo "-----------------------------------" +cd ../integration + +for test in *.yml; do + echo + echo "--------------------------------------------------------------------------------" + echo + echo "Running $test..." + ./$test -vvv -e cli_master_test="$MASTER" +done diff --git a/roles/lib_openshift/src/test/integration/oadm_manage_node.yml b/roles/lib_openshift/src/test/integration/oadm_manage_node.yml index 69a701b17..3ee13a409 100755 --- a/roles/lib_openshift/src/test/integration/oadm_manage_node.yml +++ b/roles/lib_openshift/src/test/integration/oadm_manage_node.yml @@ -1,40 +1,51 @@ #!/usr/bin/ansible-playbook --module-path=../../../library/ -# ./oadm_manage_node.yml -M ../../../library -e "cli_master_test=$OPENSHIFT_MASTER cli_node_test=$OPENSHIFT_NODE +# +# ./oadm_manage_node.yml -e "cli_master_test=$OPENSHIFT_MASTER --- - hosts: "{{ cli_master_test }}" gather_facts: no user: root tasks: + - name: get list of nodes + oc_obj: + state: list + kind: node + register: obj_out + + - name: Set the node to work with + set_fact: + node_to_test: "{{ obj_out['results']['results'][0]['items'][0]['metadata']['name'] }}" + - name: list pods from a node oadm_manage_node: list_pods: True node: - - "{{ cli_node_test }}" + - "{{ node_to_test }}" register: podout - debug: var=podout - assert: - that: "'{{ cli_node_test }}' in podout.results.nodes" + that: "'{{ node_to_test }}' in podout.results.nodes" msg: Pod data was not returned - name: set node to unschedulable oadm_manage_node: schedulable: False node: - - "{{ cli_node_test }}" + - "{{ node_to_test }}" register: nodeout - debug: var=nodeout - name: assert that schedulable=False assert: that: nodeout.results.nodes[0]['schedulable'] == False - msg: "{{ cli_node_test }} schedulable set to True" + msg: "{{ node_to_test }} schedulable set to True" - name: get node scheduable oc_obj: kind: node state: list - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" namespace: None register: nodeout @@ -48,11 +59,11 @@ oadm_manage_node: schedulable: True node: - - "{{ cli_node_test }}" + - "{{ node_to_test }}" register: nodeout - debug: var=nodeout - name: assert that schedulable=False assert: that: nodeout.results.nodes[0]['schedulable'] - msg: "{{ cli_node_test }} schedulable set to False" + msg: "{{ node_to_test }} schedulable set to False" diff --git a/roles/lib_openshift/src/test/integration/oc_label.yml b/roles/lib_openshift/src/test/integration/oc_label.yml index ce9bc25bb..b4e721407 100755 --- a/roles/lib_openshift/src/test/integration/oc_label.yml +++ b/roles/lib_openshift/src/test/integration/oc_label.yml @@ -1,5 +1,7 @@ #!/usr/bin/ansible-playbook --module-path=../../../library/ -# ./oc_label.yml -e "cli_master_test=$OPENSHIFT_MASTER -e "cli_node_test=ip-172-0-31-1.ec2" +# +# ./oc_label.yml -e "cli_master_test=$OPENSHIFT_MASTER +# --- - hosts: "{{ cli_master_test }}" gather_facts: no @@ -15,16 +17,25 @@ msg: "{{ item }} not defined" when: "{{ item }} is not defined" with_items: - - cli_node_test # openshift node to be used to add/remove labels to - cli_master_test # ansible inventory instance to run playbook against tasks: + - name: get list of nodes + oc_obj: + state: list + kind: node + register: obj_out + + - name: Set the node to work with + set_fact: + node_to_test: "{{ obj_out['results']['results'][0]['items'][0]['metadata']['name'] }}" + - name: delete test labels (start from known starting position) oc_label: state: absent namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 - key: testlabel3 @@ -34,7 +45,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: original_labels - name: assert that testlabel2 and testlabel3 test labels don't exist assert: @@ -47,7 +58,7 @@ state: add namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 value: "yes" @@ -62,7 +73,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: label_out - name: assert that testlabel2 label actually added assert: @@ -75,7 +86,7 @@ state: add namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 value: "yes" @@ -90,7 +101,7 @@ state: add namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 value: "different" @@ -105,7 +116,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: label_out - name: assert that testlabel2 label actually modified assert: @@ -118,7 +129,7 @@ state: absent namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabelnone register: label_out @@ -132,7 +143,7 @@ state: absent namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 register: label_out @@ -146,7 +157,7 @@ state: absent namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 register: label_out @@ -160,7 +171,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: label_out - name: assert label actually deleted assert: @@ -172,7 +183,7 @@ state: add namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 value: "yes" @@ -189,7 +200,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: label_out - name: assert that both labels actually exist assert: @@ -204,7 +215,7 @@ state: absent namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 - key: testlabel3 @@ -219,7 +230,7 @@ state: absent namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: - key: testlabel2 - key: testlabel3 @@ -237,7 +248,7 @@ state: present namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: "{{ original_labels_as_key_value_list }}" register: label_out - name: assert that no changes are made when current list matches existing list @@ -250,7 +261,7 @@ state: present namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: "{{ original_labels_as_key_value_list + [{'key': 'testlabel2', 'value': 'yes'}] }}" register: label_out - name: assert that changes were made @@ -263,7 +274,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: label_out - name: asssert that new label was actually added assert: @@ -276,7 +287,7 @@ state: present namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: "{{ original_labels_as_key_value_list + [{'key': 'testlabel2', 'value': 'different'}]}}" register: label_out - name: assert that changes were made when existing key's value is changed @@ -289,7 +300,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: label_out - name: asssert that changed label was actually changed assert: @@ -302,7 +313,7 @@ state: present namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" labels: "{{ original_labels_as_key_value_list }}" register: label_out - name: assert that changes were made @@ -315,7 +326,7 @@ state: list namespace: "{{ def_namespace }}" kind: "{{ def_kind }}" - name: "{{ cli_node_test }}" + name: "{{ node_to_test }}" register: label_out - name: asssert that present-removed actually removed assert: diff --git a/roles/lib_openshift/src/test/integration/oc_service.yml b/roles/lib_openshift/src/test/integration/oc_service.yml index 616694382..3eb6facef 100755 --- a/roles/lib_openshift/src/test/integration/oc_service.yml +++ b/roles/lib_openshift/src/test/integration/oc_service.yml @@ -123,6 +123,6 @@ - assert: that: - svc_out.changed == False - - svc_out.results.returncode == 1 + - svc_out.results.returncode == 0 - "'not found' in svc_out.results.stderr" msg: service get failed diff --git a/roles/lib_utils/src/test/generate-and-run-tests.sh b/roles/lib_utils/src/test/generate-and-run-tests.sh new file mode 100755 index 000000000..4b534c8f2 --- /dev/null +++ b/roles/lib_utils/src/test/generate-and-run-tests.sh @@ -0,0 +1,42 @@ +#!/bin/bash -e + + +# Put us in the same dir as the script. +cd $(dirname $0) + +echo +echo "Running lib_openshift generate" +echo "------------------------------" +../generate.py + + +echo +echo "Running lib_utils Unit Tests" +echo "----------------------------" +cd unit + +for test in *.py; do + echo + echo "--------------------------------------------------------------------------------" + echo + echo "Running $test..." + ./$test +done + + +echo +echo "Running lib_utils Integration Tests" +echo "-----------------------------------" +cd ../integration + +for test in *.yml; do + echo + echo "--------------------------------------------------------------------------------" + echo + echo "Running $test..." + ./$test -vvv +done + +# Clean up this damn file +# TODO: figure out why this is being written and clean it up. +rm kube-manager-test.yaml diff --git a/roles/lib_utils/src/test/integration/yedit.yml b/roles/lib_utils/src/test/integration/yedit.yml new file mode 100755 index 000000000..e3dfd490b --- /dev/null +++ b/roles/lib_utils/src/test/integration/yedit.yml @@ -0,0 +1,222 @@ +#!/usr/bin/ansible-playbook --module-path=../../../library/ +# +# Yedit test so that we can quickly determine if features are working +# Ensure that the kube-manager.yaml file exists +# +# ./yedit_test.yml +# +--- +- hosts: localhost + gather_facts: no + vars: + test_file: kube-manager-test.yaml + test: test + strategy: debug + + post_tasks: + - name: copy the kube-manager.yaml file so that we have a pristine copy each time + copy: + src: kube-manager.yaml + dest: "./{{ test_file }}" + changed_when: False + + ####### add key to top level ##### + - name: add a key at the top level + yedit: + src: "{{ test_file }}" + key: yedittest + value: yedittest + + - name: retrieve the inserted key + yedit: + src: "{{ test_file }}" + state: list + key: yedittest + register: results + + - name: Assert that key is at top level + assert: + that: results.result == 'yedittest' + msg: 'Test: add a key to top level failed. yedittest != [{{ results.result }}]' + ###### end add key to top level ##### + + ###### modify multilevel key, value ##### + - name: modify multilevel key, value + yedit: + src: "{{ test_file }}" + key: metadata-namespace + value: openshift-is-awesome + separator: '-' + + - name: retrieve the inserted key + yedit: + src: "{{ test_file }}" + state: list + key: metadata-namespace + separator: '-' + register: results + + - name: Assert that key is as expected + assert: + that: results.result == 'openshift-is-awesome' + msg: 'Test: multilevel key, value modification: openshift-is-awesome != [{{ results.result }}]' + ###### end modify multilevel key, value ##### + + ###### test a string boolean ##### + - name: test a string boolean + yedit: + src: "{{ test_file }}" + key: spec.containers[0].volumeMounts[1].readOnly + value: 'true' + value_type: str + + - name: retrieve the inserted key + yedit: + src: "{{ test_file }}" + state: list + key: spec.containers[0].volumeMounts[1].readOnly + register: results + + - name: Assert that key is a string + assert: + that: results.result == "true" + msg: "Test: boolean str: 'true' != [{{ results.result }}]" + + - name: Assert that key is not bool + assert: + that: results.result != true + msg: "Test: boolean str: true != [{{ results.result }}]" + ###### end test boolean string ##### + + ###### test array append ##### + - name: test array append + yedit: + src: "{{ test_file }}" + key: spec.containers[0].command + value: --my-new-parameter=openshift + append: True + + - name: retrieve the array + yedit: + src: "{{ test_file }}" + state: list + key: spec.containers[0].command + register: results + + - name: Assert that the last element in array is our value + assert: + that: results.result[-1] == "--my-new-parameter=openshift" + msg: "Test: '--my-new-parameter=openshift' != [{{ results.result[-1] }}]" + ###### end test array append ##### + + ###### test non-existing array append ##### + - name: test array append to non-existing key + yedit: + src: "{{ test_file }}" + key: nonexistingkey + value: --my-new-parameter=openshift + append: True + + - name: retrieve the array + yedit: + src: "{{ test_file }}" + state: list + key: nonexistingkey + register: results + + - name: Assert that the last element in array is our value + assert: + that: results.result[-1] == "--my-new-parameter=openshift" + msg: "Test: '--my-new-parameter=openshift' != [{{ results.result[-1] }}]" + ###### end test non-existing array append ##### + + ###### test array update modify ##### + - name: test array update modify + yedit: + src: "{{ test_file }}" + key: spec.containers[0].command + value: --root-ca-file=/etc/k8s/ssl/my.pem + curr_value: --root-ca-file=/etc/kubernetes/ssl/ca.pem + curr_value_format: str + update: True + + - name: retrieve the array + yedit: + src: "{{ test_file }}" + state: list + key: spec.containers[0].command + register: results + + - name: Assert that the element in array is our value + assert: + that: results.result[5] == "--root-ca-file=/etc/k8s/ssl/my.pem" + msg: "Test: '--root-ca-file=/etc/k8s/ssl/my.pem' != [{{ results.result[5] }}]" + ###### end test array update modify##### + + ###### test dict create ##### + - name: test dict create + yedit: + src: "{{ test_file }}" + key: a.b.c + value: d + + - name: retrieve the key + yedit: + src: "{{ test_file }}" + state: list + key: a.b.c + register: results + + - name: Assert that the key was created + assert: + that: results.result == "d" + msg: "Test: 'd' != [{{ results.result }}]" + ###### end test dict create ##### + + ###### test create dict value ##### + - name: test create dict value + yedit: + src: "{{ test_file }}" + key: e.f.g + value: + h: + i: + j: k + + - name: retrieve the key + yedit: + src: "{{ test_file }}" + state: list + key: e.f.g.h.i.j + register: results + + - name: Assert that the key was created + assert: + that: results.result == "k" + msg: "Test: 'k' != [{{ results.result }}]" + ###### end test dict create ##### + + ###### test create list value ##### + - name: test create list value + yedit: + src: "{{ test_file }}" + key: z.x.y + value: + - 1 + - 2 + - 3 + + - name: retrieve the key + yedit: + src: "{{ test_file }}" + state: list + key: z#x#y + separator: '#' + register: results + - debug: var=results + + - name: Assert that the key was created + assert: + that: results.result == [1, 2, 3] + msg: "Test: '[1, 2, 3]' != [{{ results.result }}]" +###### end test create list value ##### diff --git a/roles/lib_utils/src/test/integration/yedit_test.yml b/roles/lib_utils/src/test/integration/yedit_test.yml deleted file mode 100755 index 1760a7466..000000000 --- a/roles/lib_utils/src/test/integration/yedit_test.yml +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/ansible-playbook -# Yedit test so that we can quickly determine if features are working -# Ensure that the kube-manager.yaml file exists -# -# ./yedit_test.yml -M ../../library -# ---- -- hosts: localhost - gather_facts: no - vars: - test_file: kube-manager-test.yaml - test: test - strategy: debug - - post_tasks: - - name: copy the kube-manager.yaml file so that we have a pristine copy each time - copy: - src: kube-manager.yaml - dest: "./{{ test_file }}" - changed_when: False - - ####### add key to top level ##### - - name: add a key at the top level - yedit: - src: "{{ test_file }}" - key: yedittest - value: yedittest - - - name: retrieve the inserted key - yedit: - src: "{{ test_file }}" - state: list - key: yedittest - register: results - - - name: Assert that key is at top level - assert: - that: results.result == 'yedittest' - msg: 'Test: add a key to top level failed. yedittest != [{{ results.result }}]' - ###### end add key to top level ##### - - ###### modify multilevel key, value ##### - - name: modify multilevel key, value - yedit: - src: "{{ test_file }}" - key: metadata-namespace - value: openshift-is-awesome - separator: '-' - - - name: retrieve the inserted key - yedit: - src: "{{ test_file }}" - state: list - key: metadata-namespace - separator: '-' - register: results - - - name: Assert that key is as expected - assert: - that: results.result == 'openshift-is-awesome' - msg: 'Test: multilevel key, value modification: openshift-is-awesome != [{{ results.result }}]' - ###### end modify multilevel key, value ##### - - ###### test a string boolean ##### - - name: test a string boolean - yedit: - src: "{{ test_file }}" - key: spec.containers[0].volumeMounts[1].readOnly - value: 'true' - value_type: str - - - name: retrieve the inserted key - yedit: - src: "{{ test_file }}" - state: list - key: spec.containers[0].volumeMounts[1].readOnly - register: results - - - name: Assert that key is a string - assert: - that: results.result == "true" - msg: "Test: boolean str: 'true' != [{{ results.result }}]" - - - name: Assert that key is not bool - assert: - that: results.result != true - msg: "Test: boolean str: true != [{{ results.result }}]" - ###### end test boolean string ##### - - ###### test array append ##### - - name: test array append - yedit: - src: "{{ test_file }}" - key: spec.containers[0].command - value: --my-new-parameter=openshift - append: True - - - name: retrieve the array - yedit: - src: "{{ test_file }}" - state: list - key: spec.containers[0].command - register: results - - - name: Assert that the last element in array is our value - assert: - that: results.result[-1] == "--my-new-parameter=openshift" - msg: "Test: '--my-new-parameter=openshift' != [{{ results.result[-1] }}]" - ###### end test array append ##### - - ###### test non-existing array append ##### - - name: test array append to non-existing key - yedit: - src: "{{ test_file }}" - key: nonexistingkey - value: --my-new-parameter=openshift - append: True - - - name: retrieve the array - yedit: - src: "{{ test_file }}" - state: list - key: nonexistingkey - register: results - - - name: Assert that the last element in array is our value - assert: - that: results.result[-1] == "--my-new-parameter=openshift" - msg: "Test: '--my-new-parameter=openshift' != [{{ results.result[-1] }}]" - ###### end test non-existing array append ##### - - ###### test array update modify ##### - - name: test array update modify - yedit: - src: "{{ test_file }}" - key: spec.containers[0].command - value: --root-ca-file=/etc/k8s/ssl/my.pem - curr_value: --root-ca-file=/etc/kubernetes/ssl/ca.pem - curr_value_format: str - update: True - - - name: retrieve the array - yedit: - src: "{{ test_file }}" - state: list - key: spec.containers[0].command - register: results - - - name: Assert that the element in array is our value - assert: - that: results.result[5] == "--root-ca-file=/etc/k8s/ssl/my.pem" - msg: "Test: '--root-ca-file=/etc/k8s/ssl/my.pem' != [{{ results.result[5] }}]" - ###### end test array update modify##### - - ###### test dict create ##### - - name: test dict create - yedit: - src: "{{ test_file }}" - key: a.b.c - value: d - - - name: retrieve the key - yedit: - src: "{{ test_file }}" - state: list - key: a.b.c - register: results - - - name: Assert that the key was created - assert: - that: results.result == "d" - msg: "Test: 'd' != [{{ results.result }}]" - ###### end test dict create ##### - - ###### test create dict value ##### - - name: test create dict value - yedit: - src: "{{ test_file }}" - key: e.f.g - value: - h: - i: - j: k - - - name: retrieve the key - yedit: - src: "{{ test_file }}" - state: list - key: e.f.g.h.i.j - register: results - - - name: Assert that the key was created - assert: - that: results.result == "k" - msg: "Test: 'k' != [{{ results.result }}]" - ###### end test dict create ##### - - ###### test create list value ##### - - name: test create list value - yedit: - src: "{{ test_file }}" - key: z.x.y - value: - - 1 - - 2 - - 3 - - - name: retrieve the key - yedit: - src: "{{ test_file }}" - state: list - key: z#x#y - separator: '#' - register: results - - debug: var=results - - - name: Assert that the key was created - assert: - that: results.result == [1, 2, 3] - msg: "Test: '[1, 2, 3]' != [{{ results.result }}]" -###### end test create list value ##### -- cgit v1.2.3