----name:Example playbookhosts:alltasks:-name:Set environment variableansible.builtin.command:MY_ENV_VAR=my_value# <- Sets an environment variable in the command module.
----name:Example playbookhosts:alltasks:-name:Set environment variableansible.builtin.shell:echo $MY_ENV_VARenvironment:MY_ENV_VAR:my_value# <- Sets an environment variable with the environment keyword.
----name:Example playbookhosts:alltasks:-name:Set environment variableansible.builtin.shell:MY_ENV_VAR=my_value# <- Sets an environment variable with the shell module.