What is the `environment` keyword and when do you use it?
BeginnerConceptPlaybooks, Plays, Tasks and Handlers
Answer
environment sets environment variables for the commands a task runs on the target, at task, block or play level. It is the clean way to set proxies or cloud region for a few tasks.
- name: Install through proxy
ansible.builtin.pip:
name: boto3
environment:
https_proxy: "http://proxy.corp:3128"
PIP_INDEX_URL: "https://pypi.corp/simple"
It only affects the module process on the target; it does not change the control node's environment.