terraform-provider-lxd icon indicating copy to clipboard operation
terraform-provider-lxd copied to clipboard

Create symbolic link inside container before starting it

Open johnlane opened this issue 2 years ago • 0 comments

I'm looking for a way to create a symbolic link inside a contaier before it is started, similar to how files may be copied in.

There isn't an equivalent lxc command for this but it can be done using curl:

curl --unix-socket /var/lib/lxd/unix.socket -s lxd/1.0/containers/mycontainer/files?path=/etc/runlevels/default/firstboot -H "X-LXD-type: symlink" -H "Content-Type: text/plain" -d "/etc/init.d/firstboot"

I don't know if it's possible to execute such a curl command using Terraform? It would need to execute on the lxd host - which may not be (and is not, in my case) where Terraform is run. I thought about local_exec (runs on TF host) and remote_exec (runs inside running container over ssh) - neither of which are suitable for this.

My specific use-case is to set up a firstboot script in an Alpine Linux container which needs to be done before the container starts. I'm using the upstream Alpine image and would prefer to avoid maintaining my own image.

johnlane avatar Mar 07 '22 16:03 johnlane