Variable in a POD using Ansible

Hi All,
Using Ansible, I want to set a variable inside a POD.
Any idea how do I do that?
The below 3 things failed:

docker_container:
namespace: consul
pod: consul-server-0
env:
X1: x2

kubernetes.core.k8s_exec:
namespace: consul
pod: consul-server-0
command: export CONSUL_HTTP_TOKEN=“x2”

kubernetes.core.k8s_exec:
  namespace: consul
  pod: consul-server-0
  command: export CONSUL_HTTP_TOKEN="{{ decoded_bootstrap.stdout }}"

Hi @rana_niket

I do not think it is possible to do what you want. The ansible task will call kubectl exec under the hood which will start a new shell in a separate process tree from where the application is running, therefore the application won’t see it.

Furthermore, when the exec returns, the shell it created will terminate, taking the variable you created with it.