Repository: ansible-collections/community.general

Issue:
terraform.py - List references a dict function copy() 
### Summary

When I try to run the terraform module, using community.general.terraform (ansible 2.11.10) I get an error. Upon investigation, and it seems the line 335 here: https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/misc/terraform.py#L335 points the list (commands) to the copy() function which is expecting a dict. If I change that to local_command = command[:] the module works.
```
module_stdout": "/etc/profile.d/lang.sh: line 19: warning: setlocale: LC_CTYPE: cannot change locale (C.UTF-8)
Traceback (most recent call last):
  File \"/root/.ansible/tmp/ansible-tmp-1650393795.833559-64-134168141247671/AnsiballZ_terraform.py\", line 107, in <module>
    _ansiballz_main()
  File \"/root/.ansible/tmp/ansible-tmp-1650393795.833559-64-134168141247671/AnsiballZ_terraform.py\", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/root/.ansible/tmp/ansible-tmp-1650393795.833559-64-134168141247671/AnsiballZ_terraform.py\", line 48, in invoke_module    run_name='__main__', alter_sys=True)
  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module
    fname, loader, pkg_name)
  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code
    exec code in run_globals
  File \"/tmp/ansible_community.general.terraform_payload_kqMK6T/ansible_community.general.terraform_payload.zip/ansible_collections/community/general/plugins/modules/terraform.py\", line 521, in <module>
  File \"/tmp/ansible_community.general.terraform_payload_kqMK6T/ansible_community.general.terraform_payload.zip/ansible_collections/community/general/plugins/modules/terraform.py\", line 479, in main
  File \"/tmp/ansible_community.general.terraform_payload_kqMK6T/ansible_community.general.terraform_payload.zip/ansible_collections/community/general/plugins/modules/terraform.py\", line 327, in build_plan
AttributeError: 'list' object has no attribute 'copy'",
```


### Issue Type

Bug Report

### Component Name

community.general.ansible (any version above 3.8.3)

### Ansible Version

```console (paste below)
ansible [core 2.11.10] 
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.0.3
  libyaml = True

```


### Community.general Version

```console (paste below)
# /root/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 4.7.0  

# /usr/local/lib/python3.6/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 3.8.3  

```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed
[root@localhost remote-terr-test]# ansible-config dump --only-changed
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. Current version: 3.6.8 (default, Nov 16 2020, 16:55:22) [GCC 4.8.5 20150623 (Red Hat 
4.8.5-44)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[root@localhost remote-terr-test]# 
```


### OS / Environment

centos7

### Steps to Reproduce

I have a remote host (identified in my inventory) that has a directory with all my terraform files in it. The following ansible play runs, and is supposed to initialize, and deploy the terraform configuration on that remote host.
```
---
- name: Finish Tetration Edge Deployment
  hosts: all
  gather_facts: false

  tasks:
  - name: Deploy EDGE for user
    community.general.terraform:
      project_path: '/home/jlunde/edge/edge'
      force_init: true
      state: present
```

### Expected Results

I expect terraform to initialize, plan, and deploy the terraform configuration on that remote host, in that directory. 

### Actual Results

```
module_stdout": "/etc/profile.d/lang.sh: line 19: warning: setlocale: LC_CTYPE: cannot change locale (C.UTF-8)\r\nTraceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1650393795.833559-64-134168141247671/AnsiballZ_terraform.py\", line 107, in <module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1650393795.833559-64-134168141247671/AnsiballZ_terraform.py\", line 99, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-tmp-1650393795.833559-64-134168141247671/AnsiballZ_terraform.py\", line 48, in invoke_module\r\n    run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 176, in run_module\r\n    fname, loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 82, in _run_module_code\r\n    mod_name, mod_fname, mod_loader, pkg_name)\r\n  File \"/usr/lib64/python2.7/runpy.py\", line 72, in _run_code\r\n    exec code in run_globals\r\n  File \"/tmp/ansible_community.general.terraform_payload_kqMK6T/ansible_community.general.terraform_payload.zip/ansible_collections/community/general/plugins/modules/terraform.py\", line 521, in <module>\r\n  File \"/tmp/ansible_community.general.terraform_payload_kqMK6T/ansible_community.general.terraform_payload.zip/ansible_collections/community/general/plugins/modules/terraform.py\", line 479, in main\r\n  File \"/tmp/ansible_community.general.terraform_payload_kqMK6T/ansible_community.general.terraform_payload.zip/ansible_collections/community/general/plugins/modules/terraform.py\", line 327, in build_plan\r\nAttributeError: 'list' object has no attribute 'copy'\r\n",

```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
None

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 --->
`list.copy()` is Python 3; `list[:]` works for both Python 2 and Python 3.

Would you mind creating a PR which adds Python 2 compatibility to this module?

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
@@ -324,7 +324,7 @@ def build_plan(command, project_path, variables_args, state_file, targets, state
     if plan_path is None:
         f, plan_path = tempfile.mkstemp(suffix='.tfplan')
 
-    local_command = command.copy()
+    local_command = command[:]
 
     plan_command = [command[0], 'plan']
 


Test patch: