Repository: ansible-collections/community.general

Issue:
4.6.0 has broken terraform module
### Summary

Previously-working playbooks are now failing, because of the new terraform variable logic in 4.6.0.

The module is now wrapping everything in EXTRA double quotes because the terraform provider now forces **EVERYTHING** through a `json.dumps()`.

`"msg": "Terraform plan could not be created\r\nSTDOUT: \r\n\r\nSTDERR: \nError: Invalid AWS Region: \"us-east-1\"\n\n  with provider[\"registry.terraform.io/hashicorp/aws\"],\n  on main.tf line 1, in provider \"aws\":\n   1: provider \"aws\" {\n\n",`

when the variables passed are:
```
            "variables": {
                "lv_component_release": "u20",
                "lv_env": "tst2",
                "aws_region": "us-east-1"
            },
```

and, in a different job:
```
    "msg": "Terraform plan could not be created\r\nSTDOUT: \r\n\r\nSTDERR: \nError: Invalid value for input variable\n\nThe argument -var=\"custom_tags=...\" does not contain a valid value for\nvariable \"custom_tags\": map of string required.\n",
```

with variables defined as:
```
            "variables": {
                "lv_component_release": "u17",
                "lv_env": "stg4",
                "aws_region": "us-east-1",
                "custom_tags": "{}"
            },
```

### Issue Type

Bug Report

### Component Name

terraform

### Ansible Version

```
ansible 2.10.6
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /export/awx_custom_envs/ansible-2.10/lib/python3.6/site-packages/ansible
  executable location = bin/ansible
  python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
```


### Community.general Version

```console (paste below)
Collection        Version
----------------- -------
community.general 4.6.0
```


### Configuration


### OS / Environment

CentOS 7

### Steps to Reproduce

Invoke a terraform module using input variables. Observe that the `json.dumps()` in 4.6.0 incorrectly JSON-escapes all input, making it fail at the terraform layer.

### Expected Results

I expected this to continue working without incorrectly escaping all my input variables.

### Actual Results

It is incorrectly escaping all my input variables. see above.

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/cloud/misc/terraform.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/misc/terraform.py)

If these files are incorrect, 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/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @m-yosefpor @rainerleber
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
Another user references the same issue, also resolved by pinning back to 4.5.0: https://github.com/ansible-collections/community.general/pull/4281#issuecomment-1068415151


Resolving patch:
diff --git a/plugins/modules/cloud/misc/terraform.py b/plugins/modules/cloud/misc/terraform.py
--- a/plugins/modules/cloud/misc/terraform.py
+++ b/plugins/modules/cloud/misc/terraform.py
@@ -443,7 +443,7 @@ def main():
     for k, v in variables.items():
         variables_args.extend([
             '-var',
-            '{0}={1}'.format(k, json.dumps(v))
+            '{0}={1}'.format(k, v)
         ])
     if variables_files:
         for f in variables_files:


Test patch: