diff --git a/plugins/modules/ntnx_security_rules.py b/plugins/modules/ntnx_security_rules.py index 84f78fae..59a56286 100644 --- a/plugins/modules/ntnx_security_rules.py +++ b/plugins/modules/ntnx_security_rules.py @@ -61,6 +61,10 @@ description: security_rule Name required: false type: str + description: + description: security_rule Description + required: false + type: str security_rule_uuid: description: - security_rule UUID @@ -881,6 +885,7 @@ - name: create app security rule ntnx_security_rules: name: test_app_rule + description: App Security Rule allow_ipv6_traffic: true policy_hitlog: true app_rule: @@ -986,6 +991,7 @@ type: dict sample: name: test_app_rule + description: App Security Rule resources: allow_ipv6_traffic: true app_rule: @@ -1184,6 +1190,7 @@ def get_module_spec(): ) module_args = dict( name=dict(type="str"), + description=dict(type="str"), security_rule_uuid=dict(type="str"), allow_ipv6_traffic=dict(type="bool"), policy_hitlog=dict(type="bool"), diff --git a/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml b/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml index 0e9b038e..9bb73dc8 100644 --- a/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml +++ b/tests/integration/targets/ntnx_security_rules/tasks/app_rule.yml @@ -1,81 +1,74 @@ - name: create app security rule with inbound and outbound list ntnx_security_rules: name: test_app_rule + description: App Security Rule app_rule: target_group: - categories: - apptype: Apache_Spark - apptype_filter_by_category: - AppFamily: - - Backup - apptiers: - - "{{categories.apptiers[0]}}" - - "{{categories.apptiers[1]}}" + categories: + apptype: Apache_Spark + apptype_filter_by_category: + AppFamily: + - Backup + apptiers: + - "{{categories.apptiers[0]}}" + - "{{categories.apptiers[1]}}" - default_internal_policy: DENY_ALL + default_internal_policy: DENY_ALL inbounds: - - - categories: - AppFamily: - - Databases - - DevOps - description: test description - protocol: - tcp: - - start_port: 22 - end_port: 80 - - - categories: - AppFamily: - - Databases - - DevOps - protocol: - icmp: - - code: 1 - type: 1 - - - categories: - AppFamily: - - Databases - - DevOps - protocol: - udp: - - start_port: 82 - end_port: 8080 - - - categories: - AppFamily: - - Databases - - DevOps - protocol: - service: - name: 6a44 - - - ip_subnet: - prefix_length: 24 - ip: 192.168.1.0 - description: test description - - - address: + - categories: + AppFamily: + - Databases + - DevOps + description: test description + protocol: + tcp: + - start_port: 22 + end_port: 80 + - categories: + AppFamily: + - Databases + - DevOps + protocol: + icmp: + - code: 1 + type: 1 + - categories: + AppFamily: + - Databases + - DevOps + protocol: + udp: + - start_port: 82 + end_port: 8080 + - categories: + AppFamily: + - Databases + - DevOps + protocol: + service: + name: 6a44 + - ip_subnet: + prefix_length: 24 + ip: 192.168.1.0 + description: test description + - address: name: dest outbounds: - - - categories: - AppFamily: - - Databases - - DevOps - protocol: - icmp: - - code: 1 - type: 1 + - categories: + AppFamily: + - Databases + - DevOps + protocol: + icmp: + - code: 1 + type: 1 policy_mode: MONITOR allow_ipv6_traffic: true policy_hitlog: true register: result ignore_errors: true - - name: Creation Status assert: that: @@ -84,28 +77,27 @@ - result.response.status.state == 'COMPLETE' - result.response.status.name=="test_app_rule" - result.response.status.resources.app_rule.target_group.filter.params.AppTier | length == 2 - fail_msg: ' fail: unable to create app security rule with inbound and outbound list' - success_msg: 'pass: create app security rule with inbound and outbound list successfully' + - result.response.description=="App Security Rule" + fail_msg: " fail: unable to create app security rule with inbound and outbound list" + success_msg: "pass: create app security rule with inbound and outbound list successfully" - name: update app security rule by adding to outbound list and remove tule from inbound list ntnx_security_rules: - security_rule_uuid: '{{ result.response.metadata.uuid }}' + security_rule_uuid: "{{ result.response.metadata.uuid }}" app_rule: policy_mode: APPLY inbounds: - - - rule_id: "{{result.response.spec.resources.app_rule.inbound_allow_list.0.rule_id}}" + - rule_id: "{{result.response.spec.resources.app_rule.inbound_allow_list.0.rule_id}}" state: absent outbounds: - - - protocol: - icmp: - - code: 1 - type: 1 - categories: - AppFamily: - - Databases - - DevOps + - protocol: + icmp: + - code: 1 + type: 1 + categories: + AppFamily: + - Databases + - DevOps register: result ignore_errors: true @@ -117,13 +109,13 @@ - result.response.status.state == 'COMPLETE' - result.response.spec.resources.app_rule.action == "APPLY" - result.response.spec.resources.app_rule.outbound_allow_list.0.icmp_type_code_list is defined - fail_msg: ' fail: unable to update app security rule with outbound list ' - success_msg: 'pass :update app security rule with outbound list successfully' + fail_msg: " fail: unable to update app security rule with outbound list " + success_msg: "pass :update app security rule with outbound list successfully" - name: delete app security rule ntnx_security_rules: state: absent - security_rule_uuid: '{{ result.response.metadata.uuid }}' + security_rule_uuid: "{{ result.response.metadata.uuid }}" register: result ignore_errors: true @@ -133,22 +125,22 @@ - result.response is defined - result.failed == false - result.response.status == 'SUCCEEDED' - fail_msg: ' fail: unable to delete app security rule ' - success_msg: 'pass : delete app security rule successfully' + fail_msg: " fail: unable to delete app security rule " + success_msg: "pass : delete app security rule successfully" - name: create app security rule with allow all inbound and outbound list ntnx_security_rules: name: test_app_rule app_rule: target_group: - categories: - apptype: Apache_Spark - apptype_filter_by_category: - AppFamily: - - Backup - apptiers: - - "{{categories.apptiers[0]}}" - - "{{categories.apptiers[1]}}" - default_internal_policy: DENY_ALL + categories: + apptype: Apache_Spark + apptype_filter_by_category: + AppFamily: + - Backup + apptiers: + - "{{categories.apptiers[0]}}" + - "{{categories.apptiers[1]}}" + default_internal_policy: DENY_ALL allow_all_outbounds: true allow_all_inbounds: true policy_mode: MONITOR @@ -166,12 +158,12 @@ - result.response.spec.name=="test_app_rule" - result.response.status.resources.app_rule.target_group.filter.params.AppTier | length == 2 - fail_msg: ' fail: unable to create app security rule with allow all inbound and outbound list' - success_msg: 'pass: create app security rule with allow all inbound and outbound list successfully' + fail_msg: " fail: unable to create app security rule with allow all inbound and outbound list" + success_msg: "pass: create app security rule with allow all inbound and outbound list successfully" - name: delete app security rule ntnx_security_rules: state: absent - security_rule_uuid: '{{ result.response.metadata.uuid }}' + security_rule_uuid: "{{ result.response.metadata.uuid }}" register: result ignore_errors: true @@ -181,5 +173,5 @@ - result.response is defined - result.failed == false - result.response.status == 'SUCCEEDED' - fail_msg: ' fail: unable to delete app security rule ' - success_msg: 'pass : delete app security rule successfully' + fail_msg: " fail: unable to delete app security rule " + success_msg: "pass : delete app security rule successfully"