@@ -119,12 +119,16 @@ resource "terraform_data" "execute_playbooks" {
119119 ]
120120 }
121121
122+ # Create the vault password_file to be used for decryption and encryption of ocp config
123+ provisioner "remote-exec" {
124+ inline = [" echo ${ var . ansible_vault_password } > password_file" ]
125+ }
126+
122127 # Decrypt ocp config if it already exists
123128 provisioner "remote-exec" {
124129 inline = [
125130 " if [ -f /root/.powervs/config.json ]; then" ,
126131 " if head -n 1 /root/.powervs/config.json | grep -q '^$ANSIBLE_VAULT'; then" ,
127- " echo ${ var . ansible_vault_password } > password_file" ,
128132 " ansible-vault decrypt /root/.powervs/config.json --vault-password-file password_file" ,
129133 " fi" ,
130134 " fi"
@@ -135,13 +139,16 @@ resource "terraform_data" "execute_playbooks" {
135139 # create password file so the script can encrypt the ocp config
136140 provisioner "remote-exec" {
137141 inline = [
138- " echo ${ var . ansible_vault_password } > password_file" ,
139142 " chmod +x ${ local . dst_script_file_path } " ,
140- " export IBMCLOUD_API_KEY=${ local . ibmcloud_api_key } && ${ local . dst_script_file_path } " ,
141- " rm -f password_file"
143+ " export IBMCLOUD_API_KEY=${ local . ibmcloud_api_key } && ${ local . dst_script_file_path } "
142144 ]
143145 }
144146
147+ # Again delete the password_file
148+ provisioner "remote-exec" {
149+ inline = [" rm -f password_file" ]
150+ }
151+
145152 # Again delete private ssh key
146153 provisioner "remote-exec" {
147154 inline = [
0 commit comments