From 150a7e054562876eec8a22aaf9ec3091960711d1 Mon Sep 17 00:00:00 2001 From: William Guilherme Date: Wed, 20 Dec 2023 20:49:48 -0800 Subject: [PATCH] fix: Fixed several resources --- plugins/modules/zpa_application_segment.py | 4 ++ .../zpa_policy_access_app_protection_rule.py | 2 +- .../zpa_policy_access_forwarding_rule.py | 2 +- .../zpa_policy_access_isolation_rule.py | 2 +- plugins/modules/zpa_policy_access_rule.py | 2 +- .../modules/zpa_policy_access_timeout_rule.py | 2 +- plugins/modules/zpa_server_group.py | 2 +- pyproject.toml | 2 +- tests/integration/sweep.yml | 47 +++++++------------ 9 files changed, 28 insertions(+), 37 deletions(-) diff --git a/plugins/modules/zpa_application_segment.py b/plugins/modules/zpa_application_segment.py index ec11d4d..37c8b42 100644 --- a/plugins/modules/zpa_application_segment.py +++ b/plugins/modules/zpa_application_segment.py @@ -332,6 +332,7 @@ def core(module): existing_app.update(app) existing_app["id"] = id + module.warn(f"Final payload being sent to SDK: {app}") if state == "present": if existing_app is not None: if differences_detected: @@ -375,6 +376,7 @@ def core(module): ), ) ) + module.warn("Payload Update for SDK: {}".format(existing_app)) existing_app = client.app_segments.update_segment( **existing_app ).to_dict() @@ -383,6 +385,7 @@ def core(module): """No Changes Needed""" module.exit_json(changed=False, data=existing_app) else: + module.warn("Creating new rule as no existing rule found") """Create""" app = deleteNone( dict( @@ -412,6 +415,7 @@ def core(module): udp_port_ranges=convert_ports_list(app.get("udp_port_range", None)), ) ) + module.warn("Payload for SDK: {}".format(app)) app = client.app_segments.add_segment(**app) module.exit_json(changed=True, data=app) elif ( diff --git a/plugins/modules/zpa_policy_access_app_protection_rule.py b/plugins/modules/zpa_policy_access_app_protection_rule.py index 24b3a57..8233ba2 100644 --- a/plugins/modules/zpa_policy_access_app_protection_rule.py +++ b/plugins/modules/zpa_policy_access_app_protection_rule.py @@ -237,7 +237,7 @@ def core(module): if key not in fields_to_exclude and current_policy.get(key) != value: differences_detected = True module.warn( - "Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" + f"Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" ) if existing_policy is not None: diff --git a/plugins/modules/zpa_policy_access_forwarding_rule.py b/plugins/modules/zpa_policy_access_forwarding_rule.py index d9cb3fe..5eb984e 100644 --- a/plugins/modules/zpa_policy_access_forwarding_rule.py +++ b/plugins/modules/zpa_policy_access_forwarding_rule.py @@ -263,7 +263,7 @@ def core(module): if key not in fields_to_exclude and current_policy.get(key) != value: differences_detected = True module.warn( - "Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" + f"Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" ) if existing_policy is not None: diff --git a/plugins/modules/zpa_policy_access_isolation_rule.py b/plugins/modules/zpa_policy_access_isolation_rule.py index 6a2d4b3..36aed74 100644 --- a/plugins/modules/zpa_policy_access_isolation_rule.py +++ b/plugins/modules/zpa_policy_access_isolation_rule.py @@ -238,7 +238,7 @@ def core(module): if key not in fields_to_exclude and current_policy.get(key) != value: differences_detected = True module.warn( - "Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" + f"Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" ) if existing_policy is not None: diff --git a/plugins/modules/zpa_policy_access_rule.py b/plugins/modules/zpa_policy_access_rule.py index 4be1333..b92a71e 100644 --- a/plugins/modules/zpa_policy_access_rule.py +++ b/plugins/modules/zpa_policy_access_rule.py @@ -323,7 +323,7 @@ def core(module): if key not in fields_to_exclude and current_policy.get(key) != value: differences_detected = True module.warn( - "Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" + f"Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" ) if existing_policy is not None: diff --git a/plugins/modules/zpa_policy_access_timeout_rule.py b/plugins/modules/zpa_policy_access_timeout_rule.py index c370249..abf08a0 100644 --- a/plugins/modules/zpa_policy_access_timeout_rule.py +++ b/plugins/modules/zpa_policy_access_timeout_rule.py @@ -281,7 +281,7 @@ def core(module): if key not in fields_to_exclude and current_policy.get(key) != value: differences_detected = True module.warn( - "Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" + f"Difference detected in {key}. Current: {current_policy.get(key)}, Desired: {value}" ) if existing_policy is not None: diff --git a/plugins/modules/zpa_server_group.py b/plugins/modules/zpa_server_group.py index 8996014..c9a80dc 100644 --- a/plugins/modules/zpa_server_group.py +++ b/plugins/modules/zpa_server_group.py @@ -180,7 +180,7 @@ def core(module): ) module.exit_json(changed=True, data=existing_server_group) else: - # No Changes Needed + """No Changes Needed""" module.exit_json(changed=False, data=existing_server_group) else: """Create""" diff --git a/pyproject.toml b/pyproject.toml index 82d4833..317cee3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "zpacloud-ansible" -version = "2.10.0" +version = "1.0.0" description = "Ansible collection for Zscaler Private Access (ZPA)" authors = ["Zscaler Technology Alliances "] license = "MIT" diff --git a/tests/integration/sweep.yml b/tests/integration/sweep.yml index 95fdb7b..23b0687 100644 --- a/tests/integration/sweep.yml +++ b/tests/integration/sweep.yml @@ -1,4 +1,19 @@ --- +- name: List all Provisioning Keys + zscaler.zpacloud.zpa_provisioning_key_facts: + provider: "{{ zpa_cloud }}" + association_type: "{{ acg_association_type }}" + register: all_ac_provisioning_keys + +- name: Delete all Provisioning Keys 💥 + zscaler.zpacloud.zpa_provisioning_key: + provider: "{{ zpa_cloud }}" + state: absent + name: "{{ name }}" + association_type: "{{ acg_association_type }}" + loop: "{{ all_ac_provisioning_keys.data }}" + when: all_ac_provisioning_keys.data is defined + - name: List all Application Segments zscaler.zpacloud.zpa_application_segment_facts: provider: "{{ zpa_cloud }}" @@ -90,34 +105,6 @@ loop: "{{ all_application_servers.data }}" when: all_application_servers.data is defined -- name: List all Provisioning Keys - zscaler.zpacloud.zpa_provisioning_key_facts: - provider: "{{ zpa_cloud }}" - association_type: "{{ association_type }}" - register: all_provisioning_keys - -- name: Delete all Provisioning Keys 💥 - zscaler.zpacloud.zpa_provisioning_key: - provider: "{{ zpa_cloud }}" - state: absent - name: "{{ item.name }}" - association_type: "{{ item.association_type }}" - loop: "{{ all_provisioning_keys.data }}" - when: all_provisioning_keys.data is defined - -- name: List all App Protection Profiles - zscaler.zpacloud.zpa_app_protection_security_profile_facts: - provider: "{{ zpa_cloud }}" - register: all_app_protection_profiles - -- name: Delete all App Protection Profiles 💥 - zscaler.zpacloud.zpa_app_protection_security_profile: - provider: "{{ zpa_cloud }}" - state: absent - name: "{{ item.name }}" - loop: "{{ all_app_protection_profiles.data }}" - when: all_app_protection_profiles.data is defined - - name: List all App Protection Custom Controls zscaler.zpacloud.zpa_app_protection_custom_control_facts: provider: "{{ zpa_cloud }}" @@ -140,13 +127,13 @@ app_connector_groups_failed: "{{ all_app_connector_groups.failed | default(false) }}" service_edge_group_failed: "{{ all_service_edge_groups.failed | default(false) }}" segment_groups_failed: "{{ all_segment_groups.failed | default(false) }}" - provisioning_key_failed: "{{ all_provisioning_keys.failed | default(false) }}" + ac_provisioning_key_failed: "{{ all_ac_provisioning_keys.failed | default(false) }}" app_protection_profiles_failed: "{{ all_app_protection_profiles.failed | default(false) }}" app_protection_custom_controls_failed: "{{ all_app_protection_custom_controls.failed | default(false) }}" - name: Set fact for overall status ansible.builtin.set_fact: - sweep_successful: "{{ not (application_segments_failed or server_groups_failed or app_connector_groups_failed or segment_groups_failed or application_servers_failed or application_segments_ba_failed or provisioning_key_failed or service_edge_group_failed or app_protection_profiles_failed or app_protection_custom_controls_failed) }}" + sweep_successful: "{{ not (application_segments_failed or server_groups_failed or app_connector_groups_failed or segment_groups_failed or application_servers_failed or application_segments_ba_failed or ac_provisioning_key_failed or service_edge_group_failed or app_protection_profiles_failed or app_protection_custom_controls_failed) }}" - name: Print success message ✅ ansible.builtin.debug: