From 372efb84e3e35487e5d4ab8a18a72a5f78451d87 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:39:02 -0400 Subject: [PATCH 01/17] Try. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 065e788..7a73110 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,7 +50,7 @@ definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" with_dict: "{{ k8s_secrets }}" - when: k8s_secrets | type_debug == 'dict' + when: k8s_secrets | type_debug != 'list' - name: Creating k8s secret objects k8s: From 607b7f03c1e955c7775b5271089977b8c0cbfbbc Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:40:14 -0400 Subject: [PATCH 02/17] Try. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 7a73110..ddd9a59 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,7 +50,7 @@ definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" with_dict: "{{ k8s_secrets }}" - when: k8s_secrets | type_debug != 'list' + when: k8s_secrets | type_debug == 'foo' - name: Creating k8s secret objects k8s: From 3a8e4b2b8438244d934893f51e50820be1e869ca Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:42:37 -0400 Subject: [PATCH 03/17] Try. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index ddd9a59..a86308f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,7 +50,7 @@ definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" with_dict: "{{ k8s_secrets }}" - when: k8s_secrets | type_debug == 'foo' + when: k8s_secrets | type_debug == 'OrderedDict' - name: Creating k8s secret objects k8s: From 423e1d166f52f79cc1fca5cee59c823de525e091 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:48:05 -0400 Subject: [PATCH 04/17] Fix. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index a86308f..478a42c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -49,7 +49,7 @@ validate_certs: False definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" - with_dict: "{{ k8s_secrets }}" + with_items: "{{ k8s_secrets }}" when: k8s_secrets | type_debug == 'OrderedDict' - name: Creating k8s secret objects From c64b6794a02be1e9cc04e65d6ee830a0c8a135ef Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:49:14 -0400 Subject: [PATCH 05/17] Fix. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 478a42c..4df2171 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,7 +50,7 @@ definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" with_items: "{{ k8s_secrets }}" - when: k8s_secrets | type_debug == 'OrderedDict' + when: k8s_secrets | type_debug == 'dict' - name: Creating k8s secret objects k8s: From cb60ce0d98a445d40e13396b3f333e9a88aee1ca Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:51:29 -0400 Subject: [PATCH 06/17] Try again --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 4df2171..478a42c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,7 +50,7 @@ definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" with_items: "{{ k8s_secrets }}" - when: k8s_secrets | type_debug == 'dict' + when: k8s_secrets | type_debug == 'OrderedDict' - name: Creating k8s secret objects k8s: From 8f6a083c6d5affd1d49a19f34d49aa902d8dbf12 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:56:57 -0400 Subject: [PATCH 07/17] Fix. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 478a42c..ea8ff1f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -49,7 +49,7 @@ validate_certs: False definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" - with_items: "{{ k8s_secrets }}" + with_items: "{{ k8s_secrets.items() }}" when: k8s_secrets | type_debug == 'OrderedDict' - name: Creating k8s secret objects From b410909856e5dfbb1bead849622c7e4c54d28fd4 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 16:58:21 -0400 Subject: [PATCH 08/17] Fix. --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index ea8ff1f..f2f88c9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -50,7 +50,7 @@ definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" with_items: "{{ k8s_secrets.items() }}" - when: k8s_secrets | type_debug == 'OrderedDict' + when: k8s_secrets | type_debug == 'dict' - name: Creating k8s secret objects k8s: From 22e7ed1a7aaa8cc9b9bb44f0dcc1fe6316335e90 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 17:00:23 -0400 Subject: [PATCH 09/17] Fix. --- tasks/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index f2f88c9..8e961d5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -40,6 +40,10 @@ import_tasks: order_configs.yml when: k8s_resource_files|length>0 or k8s_resource_dirs|length>0 +- name: Type + debug: + msg: "{{ k8s_secrets | type_debug }}" + - name: Creating k8s secret objects k8s: host: "{{ k8s_auth_host }}" From e48c110e38f5764e893563f9719f31094e814620 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 17:09:23 -0400 Subject: [PATCH 10/17] Fix. --- filter_plugins/k8s_filter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/filter_plugins/k8s_filter.py b/filter_plugins/k8s_filter.py index b853342..8b38d27 100644 --- a/filter_plugins/k8s_filter.py +++ b/filter_plugins/k8s_filter.py @@ -21,7 +21,7 @@ def k8s_filter(k8s_objects): ] no_log_true = ['Secret'] - resource_files = OrderedDict() + resource_files = {} # OrderedDict() # order the resources according to what's in resource_order for res in resource_order: for k8s_res in k8s_objects: From bd9b0f1f319fdd8ab3644caf3dfc19f407b8a9cd Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 17:15:20 -0400 Subject: [PATCH 11/17] Fix. --- filter_plugins/k8s_filter.py | 2 +- tasks/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/filter_plugins/k8s_filter.py b/filter_plugins/k8s_filter.py index 8b38d27..b853342 100644 --- a/filter_plugins/k8s_filter.py +++ b/filter_plugins/k8s_filter.py @@ -21,7 +21,7 @@ def k8s_filter(k8s_objects): ] no_log_true = ['Secret'] - resource_files = {} # OrderedDict() + resource_files = OrderedDict() # order the resources according to what's in resource_order for res in resource_order: for k8s_res in k8s_objects: diff --git a/tasks/main.yml b/tasks/main.yml index 8e961d5..4628190 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -54,7 +54,7 @@ definition: "{{ lookup('template', item.key) }}" no_log: "{{ global_no_log |bool }}" with_items: "{{ k8s_secrets.items() }}" - when: k8s_secrets | type_debug == 'dict' + when: k8s_secrets is mapping - name: Creating k8s secret objects k8s: From 6a4eaf38703e340190b008df5165855be56d6f51 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 17:16:56 -0400 Subject: [PATCH 12/17] Fix. --- tasks/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index 4628190..ba692f6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -44,6 +44,14 @@ debug: msg: "{{ k8s_secrets | type_debug }}" +- name: Type + debug: + msg: "{{ k8s_secrets is mapping }}" + +- name: Type + debug: + msg: "{{ k8s_secrets.items() is mapping }}" + - name: Creating k8s secret objects k8s: host: "{{ k8s_auth_host }}" From f63458f88dcf8345240f348fda1ac961469bd2d3 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 17:32:39 -0400 Subject: [PATCH 13/17] Fix. --- filter_plugins/k8s_filter.py | 3 ++- tasks/main.yml | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/filter_plugins/k8s_filter.py b/filter_plugins/k8s_filter.py index b853342..859578f 100644 --- a/filter_plugins/k8s_filter.py +++ b/filter_plugins/k8s_filter.py @@ -21,11 +21,12 @@ def k8s_filter(k8s_objects): ] no_log_true = ['Secret'] - resource_files = OrderedDict() + resource_files = {} #OrderedDict() # order the resources according to what's in resource_order for res in resource_order: for k8s_res in k8s_objects: if selected_object(res, k8s_res): + print("Adding " + k8s_res) if res in no_log_true: resource_files[k8s_res] = True else: diff --git a/tasks/main.yml b/tasks/main.yml index ba692f6..a50d888 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -59,10 +59,10 @@ namespace: "{{ openshift_project }}" state: "{{ k8s_state }}" validate_certs: False - definition: "{{ lookup('template', item.key) }}" + definition: "{{ lookup('template', item) }}" no_log: "{{ global_no_log |bool }}" - with_items: "{{ k8s_secrets.items() }}" - when: k8s_secrets is mapping + with_items: "{{ k8s_secrets | list }}" + when: k8s_secrets | type_debug == 'dict' - name: Creating k8s secret objects k8s: From f4543e644cd827f17353ed8250eaedacfd0fb69d Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 21:20:09 -0400 Subject: [PATCH 14/17] Fix. --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index a50d888..a6210f5 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -83,8 +83,8 @@ namespace: "{{ openshift_project }}" state: "{{ k8s_state }}" validate_certs: False - definition: "{{ lookup('template', item.key) }}" - with_dict: "{{ k8s_resources }}" + definition: "{{ lookup('template', item) }}" + with_items: "{{ k8s_resources | list }}" when: k8s_resources | type_debug == 'dict' - name: Creating k8s objects From 0166bac7ea573ef7fc0e8cd633dd706af6477e44 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 21:45:25 -0400 Subject: [PATCH 15/17] Fix. --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index a6210f5..b311757 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -52,7 +52,7 @@ debug: msg: "{{ k8s_secrets.items() is mapping }}" -- name: Creating k8s secret objects +- name: Creating k8s secret objects - greg 1 k8s: host: "{{ k8s_auth_host }}" api_key: "{{ k8s_auth_api_key }}" @@ -76,7 +76,7 @@ with_items: "{{ k8s_secrets }}" when: k8s_secrets | type_debug == 'list' -- name: Creating k8s objects +- name: Creating k8s objects - greg 2 k8s: host: "{{ k8s_auth_host }}" api_key: "{{ k8s_auth_api_key }}" From ee7669a4a2eb928c86e8292e8a68ff3819131253 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Fri, 23 Sep 2022 22:08:42 -0400 Subject: [PATCH 16/17] Fix. --- tasks/main.yml | 4 ++-- tasks/order_configs.yml | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index b311757..d7eca06 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -61,7 +61,7 @@ validate_certs: False definition: "{{ lookup('template', item) }}" no_log: "{{ global_no_log |bool }}" - with_items: "{{ k8s_secrets | list }}" + with_items: "{{ k8s_secrets_ordered }}" when: k8s_secrets | type_debug == 'dict' - name: Creating k8s secret objects @@ -84,7 +84,7 @@ state: "{{ k8s_state }}" validate_certs: False definition: "{{ lookup('template', item) }}" - with_items: "{{ k8s_resources | list }}" + with_items: "{{ k8s_resources_ordered }}" when: k8s_resources | type_debug == 'dict' - name: Creating k8s objects diff --git a/tasks/order_configs.yml b/tasks/order_configs.yml index 8aa6e81..d6a9698 100644 --- a/tasks/order_configs.yml +++ b/tasks/order_configs.yml @@ -28,8 +28,16 @@ - name: set k8s_secrets with set files set_fact: - k8s_secrets: "{{ k8s_secret_files | k8s_filter }}" + k8s_secrets: "{{ k8s_secret_files | k8s_filter }}" + +- name: set k8s_secrets_ordered with set files + set_fact: + k8s_secrets_ordered: "{{ k8s_secret_files | k8s_filter | list }}" - name: set k8s_resources with set files set_fact: - k8s_resources: "{{ k8s_res_files | k8s_filter }}" + k8s_resources: "{{ k8s_res_files | k8s_filter }}" + +- name: set k8s_resources_ordered with set files + set_fact: + k8s_resources_ordered: "{{ k8s_res_files | k8s_filter | list}}" From e0708eed94c9a5d2fac70f0e5b015f9cf696e1f0 Mon Sep 17 00:00:00 2001 From: Greg Allen Date: Mon, 10 Oct 2022 15:54:39 -0400 Subject: [PATCH 17/17] Clean up. --- filter_plugins/k8s_filter.py | 4 +--- tasks/main.yml | 16 ++-------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/filter_plugins/k8s_filter.py b/filter_plugins/k8s_filter.py index 859578f..624790a 100644 --- a/filter_plugins/k8s_filter.py +++ b/filter_plugins/k8s_filter.py @@ -2,7 +2,6 @@ from ansible.utils.display import Display from ansible import constants as C -from collections import OrderedDict import os display = Display() @@ -21,12 +20,11 @@ def k8s_filter(k8s_objects): ] no_log_true = ['Secret'] - resource_files = {} #OrderedDict() + resource_files = {} # order the resources according to what's in resource_order for res in resource_order: for k8s_res in k8s_objects: if selected_object(res, k8s_res): - print("Adding " + k8s_res) if res in no_log_true: resource_files[k8s_res] = True else: diff --git a/tasks/main.yml b/tasks/main.yml index d7eca06..608b7f0 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -40,19 +40,7 @@ import_tasks: order_configs.yml when: k8s_resource_files|length>0 or k8s_resource_dirs|length>0 -- name: Type - debug: - msg: "{{ k8s_secrets | type_debug }}" - -- name: Type - debug: - msg: "{{ k8s_secrets is mapping }}" - -- name: Type - debug: - msg: "{{ k8s_secrets.items() is mapping }}" - -- name: Creating k8s secret objects - greg 1 +- name: Creating k8s secret objects k8s: host: "{{ k8s_auth_host }}" api_key: "{{ k8s_auth_api_key }}" @@ -76,7 +64,7 @@ with_items: "{{ k8s_secrets }}" when: k8s_secrets | type_debug == 'list' -- name: Creating k8s objects - greg 2 +- name: Creating k8s objects k8s: host: "{{ k8s_auth_host }}" api_key: "{{ k8s_auth_api_key }}"