summaryrefslogtreecommitdiffstats
path: root/src/ansiblelint/rules/inline_env_var.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:06:49 +0000
commit2fe34b6444502079dc0b84365ce82dbc92de308e (patch)
tree8fedcab52bbbc3db6c5aa909a88a7a7b81685018 /src/ansiblelint/rules/inline_env_var.md
parentInitial commit. (diff)
downloadansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.tar.xz
ansible-lint-2fe34b6444502079dc0b84365ce82dbc92de308e.zip
Adding upstream version 6.17.2.upstream/6.17.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ansiblelint/rules/inline_env_var.md')
-rw-r--r--src/ansiblelint/rules/inline_env_var.md38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ansiblelint/rules/inline_env_var.md b/src/ansiblelint/rules/inline_env_var.md
new file mode 100644
index 0000000..bc83f7e
--- /dev/null
+++ b/src/ansiblelint/rules/inline_env_var.md
@@ -0,0 +1,38 @@
+# inline-env-var
+
+This rule checks that playbooks do not set environment variables in the `ansible.builtin.command` module.
+
+You should set environment variables with the `ansible.builtin.shell` module or the `environment` keyword.
+
+## Problematic Code
+
+```yaml
+---
+- name: Example playbook
+ hosts: all
+ tasks:
+ - name: Set environment variable
+ ansible.builtin.command: MY_ENV_VAR=my_value # <- Sets an environment variable in the command module.
+```
+
+## Correct Code
+
+```yaml
+---
+- name: Example playbook
+ hosts: all
+ tasks:
+ - name: Set environment variable
+ ansible.builtin.shell: echo $MY_ENV_VAR
+ environment:
+ MY_ENV_VAR: my_value # <- Sets an environment variable with the environment keyword.
+```
+
+```yaml
+---
+- name: Example playbook
+ hosts: all
+ tasks:
+ - name: Set environment variable
+ ansible.builtin.shell: MY_ENV_VAR=my_value # <- Sets an environment variable with the shell module.
+```