# Pass a variable into a config file before uploading with file provisioner

**URL:** <https://discuss.hashicorp.com/t/pass-a-variable-into-a-config-file-before-uploading-with-file-provisioner/37555>\
**Category:** Packer\
**Created:** [March 25, 2022, 10:06am UTC](https://discuss.hashicorp.com/t/pass-a-variable-into-a-config-file-before-uploading-with-file-provisioner/37555 "2022-03-25T10:06:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![baronnenate](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/baronnenate/32/16471_2.png) [@baronnenate](https://discuss.hashicorp.com/u/baronnenate)\
**Post date:** [March 25, 2022, 10:06am UTC](https://discuss.hashicorp.com/t/pass-a-variable-into-a-config-file-before-uploading-with-file-provisioner/37555/1 "2022-03-25T10:06:30Z")

</div>

I have a SQL unattended config file which I would like to pass in a variable before that file is uploaded using the file provisioner.  
ConfigurationFile.ini  
`SQLSYSADMINACCOUNTS="${usr}" "Administrator" "NT AUTHORITY\SYSTEM" "BUILTIN\Administrators"`

How do I go about passing in a variable to replace the ${usr} ?

---

<div class="post-metadata">

**Author:** ![aram](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@aram](https://discuss.hashicorp.com/u/aram)\
**Post date:** [March 25, 2022, 11:35am UTC](https://discuss.hashicorp.com/t/pass-a-variable-into-a-config-file-before-uploading-with-file-provisioner/37555/2 "2022-03-25T11:35:30Z")

</div>

> **[Shell - Provisioners | Packer by HashiCorp](https://www.packer.io/docs/provisioners/shell#environment_vars)**
>
> The shell Packer provisioner provisions machines built by Packer using shell
> scripts. Shell provisioning is the easiest way to get software installed and
> configured on a machine.

---

<div class="post-metadata">

**Author:** ![baronnenate](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/baronnenate/32/16471_2.png) [@baronnenate](https://discuss.hashicorp.com/u/baronnenate)\
**Post date:** [March 25, 2022, 11:37am UTC](https://discuss.hashicorp.com/t/pass-a-variable-into-a-config-file-before-uploading-with-file-provisioner/37555/3 "2022-03-25T11:37:45Z")

</div>

thanks, not sure what you’re pointing out specifically. perhaps I should have mentioned this is a Windows machine

---

<div class="post-metadata">

**Author:** ![aram](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@aram](https://discuss.hashicorp.com/u/aram)\
**Post date:** [March 25, 2022, 2:02pm UTC](https://discuss.hashicorp.com/t/pass-a-variable-into-a-config-file-before-uploading-with-file-provisioner/37555/4 "2022-03-25T14:02:15Z")

</div>

I don’t think that would make a difference, you still use the `environment_vars` to pass the env variable you want to the script or run command to replace the $x into the value.

---

<div class="post-metadata">

**Author:** ![baronnenate](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/baronnenate/32/16471_2.png) [@baronnenate](https://discuss.hashicorp.com/u/baronnenate)\
**Post date:** [March 25, 2022, 3:37pm UTC](https://discuss.hashicorp.com/t/pass-a-variable-into-a-config-file-before-uploading-with-file-provisioner/37555/5 "2022-03-25T15:37:20Z")

</div>

it isn’t a script in this case, it’s just a config.ini file which has a load of settings that are passed to the SQL Server installation for unattended install. I don’t think if I placed an environment variable in the config.ini it would be picked up and changed into a literal value
