Optional dependencies like Cloudflare Zero Trust or the DevOps dependencies are installed by Ansible with the local-exec provider.
The issue is that Terraform is executing them in parallel since they are optional and can't be linked with depends_onfor example.
If multiple executions of apt or dpkg are run simultaneously, the first execution will lock the execution for the other commands (dpkg lock file).
The sequence of the optional dependencies installation needs to be changed by a single script with args or something else.