Repository: ansible-collections/community.vmware

Issue:
default for enable_drs in vmware_cluster_drs module
##### SUMMARY
Need change default choise for parameter enable_drs in vmware_cluster_drs. By default, this parameter contains No (False) - if the user does not specify this parameter explicitly by setting it to Yes (True), then the consequences for the cluster can be destructive, because disabling DRS destroys the entire Resourse Pools tree. For some environments (eg VCD, VRA) the consequences will be disastrous.

##### ISSUE TYPE
- Feature Idea

##### COMPONENT NAME
[plugins/modules/vmware_cluster_drs.py](https://github.com/ansible-collections/community.vmware/blob/main/plugins/modules/vmware_cluster_drs.py)



Discussion:
Files identified in the description:
* [`plugins/modules/vmware_cluster_drs.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/vmware_cluster_drs.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Akasurde @Tomorrow9 @goneri @lparkes @pgbidkar @warthog9
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
@ihumster I understand the problem but changing the default to `True` might affect people in the opposite way it affects you: They think that not specifying `enable_drs` means it's disabled, but suddenly their playbooks would enable DRS when not setting this parameter.

Maybe it would be better to _not_ have a default and make this a required parameter. This would force people to explicitly state what they want to achieve.

@Akasurde @goneri @sky-joker 

What's your opinion? Change the default to `True` or don't have a default for `enable_drs` and make it a required parameter? Or keep it as is... after all, the default value of `False` is documented. Personally, I tend to make it a required parameter. Maybe the [The Zen of Python](https://www.python.org/dev/peps/pep-0020/) _is_ right and explicit is better than implicit.

`vmware_cluster_ha` and `vmware_cluster_vsan` may have a similar problem since enabling these also defaults to `False`.
> Maybe it would be better to not have a default and make this a required parameter.

I see.  
If it modifies the option, I think that way is better.
> > Maybe it would be better to not have a default and make this a required parameter.
> 
> I see.
> If it modifies the option, I think that way is better.

@sky-joker Thanks for sharing your opinion on this. I'll prepare a PR to make the parameter required.
I understand it's a desirable improvement but it's also a breaking change. I suggest we start a (short) deprecation cycle. For now we show up a warning if the key is not set and we slip the switch for Ansible 5.0.0.
@ihumster As it turned out, this is considered a breaking change. So we won't do it right now. But I've changed my PR to announce that we will change the default in the future.
@ihumster 

> I understand it's a desirable improvement but it's also a breaking change. I suggest we start a (short) deprecation cycle. For now we show up a warning if the key is not set and we slip the switch for Ansible 5.0.0.

A breaking change means we're talking about version 2 of this collection, which won't be part of Ansible 5 (see #1056).

So you'll have to wait for Ansible 6. Or, alternatively, use this collection directly in version 2 via ansible-galaxy.

cc @goneri 

Resolving patch:
diff --git a/plugins/modules/vmware_cluster_drs.py b/plugins/modules/vmware_cluster_drs.py
--- a/plugins/modules/vmware_cluster_drs.py
+++ b/plugins/modules/vmware_cluster_drs.py
@@ -39,8 +39,7 @@
       description:
       - Whether to enable DRS.
       type: bool
-      default: false
-      aliases: [ enable_drs ]
+      default: true
     drs_enable_vm_behavior_overrides:
       description:
       - Whether DRS Behavior overrides for individual virtual machines are enabled.
@@ -153,9 +152,6 @@ def __init__(self, module):
         else:
             self.changed_advanced_settings = None
 
-        self.module.warn("The default for enable will change from false to true in a future version to make the behavior more consistent with other modules."
-                         "Please make sure your playbooks don't rely on the default being false so you don't run into problems.")
-
     def check_drs_config_diff(self):
         """
         Check DRS configuration diff
@@ -218,7 +214,7 @@ def main():
         cluster_name=dict(type='str', required=True),
         datacenter=dict(type='str', required=True, aliases=['datacenter_name']),
         # DRS
-        enable=dict(type='bool', default=False, aliases=['enable_drs']),
+        enable=dict(type='bool', default=True),
         drs_enable_vm_behavior_overrides=dict(type='bool', default=True),
         drs_default_vm_behavior=dict(type='str',
                                      choices=['fullyAutomated', 'manual', 'partiallyAutomated'],
diff --git a/plugins/modules/vmware_cluster_ha.py b/plugins/modules/vmware_cluster_ha.py
--- a/plugins/modules/vmware_cluster_ha.py
+++ b/plugins/modules/vmware_cluster_ha.py
@@ -40,8 +40,7 @@
       description:
       - Whether to enable HA.
       type: bool
-      default: false
-      aliases: [ enable_ha ]
+      default: true
     ha_host_monitoring:
       description:
       - Whether HA restarts virtual machines after a host fails.
@@ -284,9 +283,6 @@ def __init__(self, module):
         else:
             self.changed_advanced_settings = None
 
-        self.module.warn("The default for enable will change from false to true in a future version to make the behavior more consistent with other modules."
-                         "Please make sure your playbooks don't rely on the default being false so you don't run into problems.")
-
     def get_failover_hosts(self):
         """
         Get failover hosts for failover_host_admission_control policy
@@ -459,7 +455,7 @@ def main():
         cluster_name=dict(type='str', required=True),
         datacenter=dict(type='str', required=True, aliases=['datacenter_name']),
         # HA
-        enable=dict(type='bool', default=False, aliases=['enable_ha']),
+        enable=dict(type='bool', default=True),
         ha_host_monitoring=dict(type='str',
                                 default='enabled',
                                 choices=['enabled', 'disabled']),
diff --git a/plugins/modules/vmware_cluster_vsan.py b/plugins/modules/vmware_cluster_vsan.py
--- a/plugins/modules/vmware_cluster_vsan.py
+++ b/plugins/modules/vmware_cluster_vsan.py
@@ -41,8 +41,7 @@
       description:
       - Whether to enable vSAN.
       type: bool
-      default: false
-      aliases: [ enable_vsan ]
+      default: true
     vsan_auto_claim_storage:
       description:
       - Whether the VSAN service is configured to automatically claim local storage
@@ -170,9 +169,6 @@ def __init__(self, module):
         vcMos = vsanapiutils.GetVsanVcMos(client_stub, context=ssl_context, version=apiVersion)
         self.vsanClusterConfigSystem = vcMos['vsan-cluster-config-system']
 
-        self.module.warn("The default for enable will change from false to true in a future version to make the behavior more consistent with other modules."
-                         "Please make sure your playbooks don't rely on the default being false so you don't run into problems.")
-
     def check_vsan_config_diff(self):
         """
         Check VSAN configuration diff
@@ -261,7 +257,7 @@ def main():
         cluster_name=dict(type='str', required=True),
         datacenter=dict(type='str', required=True, aliases=['datacenter_name']),
         # VSAN
-        enable=dict(type='bool', default=False, aliases=['enable_vsan']),
+        enable=dict(type='bool', default=True),
         vsan_auto_claim_storage=dict(type='bool', default=False),
         advanced_options=dict(type='dict', options=dict(
             automatic_rebalance=dict(type='bool', required=False),


Test patch:
diff --git a/tests/integration/targets/vmware_cluster_drs/tasks/main.yml b/tests/integration/targets/vmware_cluster_drs/tasks/main.yml
--- a/tests/integration/targets/vmware_cluster_drs/tasks/main.yml
+++ b/tests/integration/targets/vmware_cluster_drs/tasks/main.yml
@@ -42,7 +42,7 @@
     password: "{{ vcenter_password }}"
     datacenter_name: "{{ dc1 }}"
     cluster_name: test_cluster_drs
-    enable_drs: false
+    enable: false
   register: cluster_drs_result_0002
 
 - name: Ensure DRS is disabled
diff --git a/tests/integration/targets/vmware_cluster_ha/tasks/main.yml b/tests/integration/targets/vmware_cluster_ha/tasks/main.yml
--- a/tests/integration/targets/vmware_cluster_ha/tasks/main.yml
+++ b/tests/integration/targets/vmware_cluster_ha/tasks/main.yml
@@ -40,7 +40,7 @@
     password: "{{ vcenter_password }}"
     datacenter_name: "{{ dc1 }}"
     cluster_name: test_cluster_ha
-    enable_ha: false
+    enable: false
   register: disable_ha_result
 
 - name: Ensure HA is disabled
diff --git a/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml b/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml
--- a/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml
+++ b/tests/integration/targets/vmware_cluster_vsan/tasks/main.yml
@@ -44,7 +44,7 @@
         password: "{{ vcenter_password }}"
         datacenter_name: "{{ dc1 }}"
         cluster_name: test_cluster_vsan
-        enable_vsan: true
+        enable: true
       register: cluster_vsan_result_0002
 
     - name: Ensure vSAN is not enabled again