@@ -119,6 +119,8 @@ def generate(self, args):
119119 else :
120120 variables_file = ' '
121121
122+ auto_approve = '-auto-approve' if args .auto_approve else ''
123+
122124 if args .subcommand == 'plan' :
123125 generate_module_templates = True
124126 terraform_refresh_command = ''
@@ -157,10 +159,6 @@ def generate(self, args):
157159 # todo maybe this deserves a better implementation later
158160 generate_module_templates = True
159161
160- auto_approve = ''
161- if args .auto_approve :
162- auto_approve = '-auto-approve'
163-
164162 self .inventory_generator .clear_cache ()
165163 if args .skip_plan :
166164 # Run Terraform apply without running a plan first
@@ -198,14 +196,15 @@ def generate(self, args):
198196 "{terraform_init_command}" \
199197 "terraform plan -destroy " \
200198 "-refresh=true {vars} {variables_file} {state_argument} && " \
201- "terraform destroy {vars} {variables_file} {state_argument} -refresh=true" .format (
199+ "terraform destroy {vars} {variables_file} {state_argument} -refresh=true {auto_approve} " .format (
202200 root_dir = self .root_dir ,
203201 terraform_path = terraform_path ,
204202 variables_file = variables_file ,
205203 vars = vars ,
206204 state_argument = state_argument ,
207205 terraform_init_command = terraform_init_command ,
208- remove_local_cache = remove_local_cache
206+ remove_local_cache = remove_local_cache ,
207+ auto_approve = auto_approve
209208 )
210209 elif args .subcommand == 'output' :
211210 cmd = "cd {root_dir}/{terraform_path} && " \
0 commit comments