Docs: issue 75922 add code-blocks to user_guide/playbooks_environment.rst (#75929)

Add code-blocks in the 6 outlined examples from the Issue
pull/75987/head
nicpayne713 3 years ago committed by GitHub
parent b03afeec6c
commit 4381336fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,7 +15,9 @@ When you set a value with ``environment:`` at the play or block level, it is ava
Setting the remote environment in a task
----------------------------------------
You can set the environment directly at the task level::
You can set the environment directly at the task level.
.. code-block:: yaml
- hosts: all
remote_user: root
@ -29,7 +31,9 @@ You can set the environment directly at the task level::
environment:
http_proxy: http://proxy.example.com:8080
You can re-use environment settings by defining them as variables in your play and accessing them in a task as you would access any stored Ansible variable::
You can re-use environment settings by defining them as variables in your play and accessing them in a task as you would access any stored Ansible variable.
.. code-block:: yaml
- hosts: all
remote_user: root
@ -47,7 +51,9 @@ You can re-use environment settings by defining them as variables in your play a
state: present
environment: "{{ proxy_env }}"
You can store environment settings for re-use in multiple playbooks by defining them in a group_vars file::
You can store environment settings for re-use in multiple playbooks by defining them in a group_vars file.
.. code-block:: yaml
---
# file: group_vars/boston
@ -58,7 +64,9 @@ You can store environment settings for re-use in multiple playbooks by defining
http_proxy: http://proxy.bos.example.com:8080
https_proxy: http://proxy.bos.example.com:8080
You can set the remote environment at the play level::
You can set the remote environment at the play level.
.. code-block:: yaml
- hosts: testing
@ -74,7 +82,9 @@ These examples show proxy settings, but you can provide any number of settings t
Working with language-specific version managers
===============================================
Some language-specific version managers (such as rbenv and nvm) require you to set environment variables while these tools are in use. When using these tools manually, you usually source some environment variables from a script or from lines added to your shell configuration file. In Ansible, you can do this with the environment keyword at the play level::
Some language-specific version managers (such as rbenv and nvm) require you to set environment variables while these tools are in use. When using these tools manually, you usually source some environment variables from a script or from lines added to your shell configuration file. In Ansible, you can do this with the environment keyword at the play level.
.. code-block:: yaml+jinja
---
### A playbook demonstrating a common npm workflow:
@ -116,7 +126,9 @@ Some language-specific version managers (such as rbenv and nvm) require you to s
.. warning::
Environment variables are normally passed in clear text (shell plugin dependent) so they are not a recommended way of passing secrets to the module being executed.
You can also specify the environment at the task level::
You can also specify the environment at the task level.
.. code-block:: yaml+jinja
---
- name: Install ruby 2.3.1

Loading…
Cancel
Save