diff --git a/changelogs/fragments/3540-terraform_add_parallelism_parameter.yml b/changelogs/fragments/3540-terraform_add_parallelism_parameter.yml new file mode 100644 index 0000000000..45b1b0d0f4 --- /dev/null +++ b/changelogs/fragments/3540-terraform_add_parallelism_parameter.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - terraform - add ``parallelism`` parameter (https://github.com/ansible-collections/community.general/pull/3540). diff --git a/plugins/modules/cloud/misc/terraform.py b/plugins/modules/cloud/misc/terraform.py index c5619b8eb0..5e3b952c0c 100644 --- a/plugins/modules/cloud/misc/terraform.py +++ b/plugins/modules/cloud/misc/terraform.py @@ -137,6 +137,11 @@ options: type: bool default: false version_added: '3.3.0' + parallelism: + description: + - Restrict concurrent operations when Terraform applies the plan. + type: int + version_added: '3.8.0' notes: - To just run a `terraform plan`, use check mode. requirements: [ "terraform" ] @@ -363,6 +368,7 @@ def main(): init_reconfigure=dict(type='bool', default=False), overwrite_init=dict(type='bool', default=True), check_destroy=dict(type='bool', default=False), + parallelism=dict(type='int'), ), required_if=[('state', 'planned', ['plan_file'])], supports_check_mode=True, @@ -415,6 +421,9 @@ def main(): elif state == 'absent': command.extend(DESTROY_ARGS) + if state == 'present' and module.params.get('parallelism') is not None: + command.append('-parallelism=%d' % module.params.get('parallelism')) + variables_args = [] for k, v in variables.items(): variables_args.extend([