Skip to content

Commit

Permalink
fix: Fixed several resources
Browse files Browse the repository at this point in the history
  • Loading branch information
willguibr committed Dec 21, 2023
1 parent 3945e25 commit 150a7e0
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 37 deletions.
4 changes: 4 additions & 0 deletions plugins/modules/zpa_application_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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(
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zpa_policy_access_app_protection_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zpa_policy_access_forwarding_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zpa_policy_access_isolation_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zpa_policy_access_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zpa_policy_access_timeout_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/zpa_server_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down
47 changes: 17 additions & 30 deletions tests/integration/sweep.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
Expand Down Expand Up @@ -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 }}"
Expand All @@ -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:
Expand Down

0 comments on commit 150a7e0

Please sign in to comment.