summaryrefslogtreecommitdiffstats
path: root/examples/playbooks/vars
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 /examples/playbooks/vars
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 'examples/playbooks/vars')
-rw-r--r--examples/playbooks/vars/empty.transformed.yml3
-rw-r--r--examples/playbooks/vars/empty.yml3
-rw-r--r--examples/playbooks/vars/empty_vars.transformed.yml2
-rw-r--r--examples/playbooks/vars/empty_vars.yml2
-rw-r--r--examples/playbooks/vars/invalid_vars_schema.yml2
-rw-r--r--examples/playbooks/vars/jinja-spacing.yml41
-rw-r--r--examples/playbooks/vars/other.yml2
-rw-r--r--examples/playbooks/vars/rule_jinja_vars.yml5
-rw-r--r--examples/playbooks/vars/rule_var_naming_fail.yml14
-rw-r--r--examples/playbooks/vars/strings.transformed.yml39
-rw-r--r--examples/playbooks/vars/strings.yml45
-rw-r--r--examples/playbooks/vars/subfolder/settings.yml2
-rw-r--r--examples/playbooks/vars/vault_full.yml11
-rw-r--r--examples/playbooks/vars/vault_partial.yml8
14 files changed, 179 insertions, 0 deletions
diff --git a/examples/playbooks/vars/empty.transformed.yml b/examples/playbooks/vars/empty.transformed.yml
new file mode 100644
index 0000000..10abfa5
--- /dev/null
+++ b/examples/playbooks/vars/empty.transformed.yml
@@ -0,0 +1,3 @@
+
+---
+# broken vars files due to spacing at the start of the file.
diff --git a/examples/playbooks/vars/empty.yml b/examples/playbooks/vars/empty.yml
new file mode 100644
index 0000000..10abfa5
--- /dev/null
+++ b/examples/playbooks/vars/empty.yml
@@ -0,0 +1,3 @@
+
+---
+# broken vars files due to spacing at the start of the file.
diff --git a/examples/playbooks/vars/empty_vars.transformed.yml b/examples/playbooks/vars/empty_vars.transformed.yml
new file mode 100644
index 0000000..a6e18c1
--- /dev/null
+++ b/examples/playbooks/vars/empty_vars.transformed.yml
@@ -0,0 +1,2 @@
+---
+# Make sure that the Transformer does not mangle comment-only files!
diff --git a/examples/playbooks/vars/empty_vars.yml b/examples/playbooks/vars/empty_vars.yml
new file mode 100644
index 0000000..a6e18c1
--- /dev/null
+++ b/examples/playbooks/vars/empty_vars.yml
@@ -0,0 +1,2 @@
+---
+# Make sure that the Transformer does not mangle comment-only files!
diff --git a/examples/playbooks/vars/invalid_vars_schema.yml b/examples/playbooks/vars/invalid_vars_schema.yml
new file mode 100644
index 0000000..d4142a2
--- /dev/null
+++ b/examples/playbooks/vars/invalid_vars_schema.yml
@@ -0,0 +1,2 @@
+---
+123: true # invalid as schema expects string key
diff --git a/examples/playbooks/vars/jinja-spacing.yml b/examples/playbooks/vars/jinja-spacing.yml
new file mode 100644
index 0000000..419c7bc
--- /dev/null
+++ b/examples/playbooks/vars/jinja-spacing.yml
@@ -0,0 +1,41 @@
+---
+# Should raise jinja[spacing] at line [14, 15, 16, 17, 18, 19, 22, 32, 38], at following variables.
+# ".bad_var_1", ".bad_var_2", ".bad_var_3", ".invalid_multiline_nested_json", ".invalid_nested_json"
+good_var_1: "{{ good_format }}"
+good_var_2: "Value: {{ good_format }}"
+good_var_3: "{{ good_format | filter }}"
+good_var_4: "Value: {{ good_format | filter }}"
+jinja_escape_1: "{{ '{{' }}"
+jinja_escape_2: docker info --format '{{ '{{' }}json .Swarm.LocalNodeState{{ '}}' }}' | tr -d '"'
+jinja_whitespace_control: |
+ {{ good_format }}/
+ {{- good_format }}
+ {{- good_format -}}
+bad_var_1: "{{bad_format}}" # <-- 1
+bad_var_2: "Value: {{ bad_format}}" # <-- 2
+bad_var_3: "{{bad_format }}" # <-- 3
+bad_var_4: "{{ bad_format|filter }}" # <-- 4
+bad_var_5: "Value: {{ bad_format |filter }}" # <-- 5
+bad_var_6: "{{ bad_format| filter }}" # <-- 6
+# spell-checker: disable-next-line
+non_jinja_var: "data = ${lookup{$local_part}lsearch{/etc/aliases}}" # noqa: jinja[spacing]
+json_inside_jinja: "{{ {'test': {'subtest': variable}} }}"
+multiline_vars: # Assert that no false positive on multiline exists
+ cases:
+ case1: >-
+ http://example.com/{{
+ case1 }}
+ case2: >-
+ http://example.com/{{
+ case2 }}
+valid_nested_json: "{{ {'dummy_2': {'nested_dummy_1': 'value_1', 'nested_dummy_2': value_2}} | combine(dummy_1) }}"
+invalid_nested_json: "{{ {'dummy_2': {'nested_dummy_1': 'value_1', 'nested_dummy_2': value_2}} | combine(dummy_1)}}" # <-- 7
+
+valid_multiline_nested_json: >-
+ {{ {'dummy_2': {'nested_dummy_1': value_1,
+ 'nested_dummy_2': value_2}} |
+ combine(dummy_1) }}
+invalid_multiline_nested_json: >- # ignored multiline expression, for now
+ {{ {'dummy_2': {'nested_dummy_1': value_1,
+ 'nested_dummy_2': value_2}} |
+ combine(dummy_1)}}
diff --git a/examples/playbooks/vars/other.yml b/examples/playbooks/vars/other.yml
new file mode 100644
index 0000000..2771218
--- /dev/null
+++ b/examples/playbooks/vars/other.yml
@@ -0,0 +1,2 @@
+---
+some_var: some_value_defined_in_vars_other
diff --git a/examples/playbooks/vars/rule_jinja_vars.yml b/examples/playbooks/vars/rule_jinja_vars.yml
new file mode 100644
index 0000000..da9e6d1
--- /dev/null
+++ b/examples/playbooks/vars/rule_jinja_vars.yml
@@ -0,0 +1,5 @@
+# this should not trigger any errors because a 'when' inside
+# a vars files, does not use implicit jinja.
+---
+foo:
+ when: "{{ var }}"
diff --git a/examples/playbooks/vars/rule_var_naming_fail.yml b/examples/playbooks/vars/rule_var_naming_fail.yml
new file mode 100644
index 0000000..3870c26
--- /dev/null
+++ b/examples/playbooks/vars/rule_var_naming_fail.yml
@@ -0,0 +1,14 @@
+---
+CamelCaseIsBad: false # invalid
+this_is_valid: # valid because content is a dict, not a variable
+ CamelCase: ...
+ ALL_CAPS: ...
+ALL_CAPS_ARE_BAD_TOO: ... # invalid
+"{{ 'test_' }}var": "value" # noqa: schema
+CamelCaseButErrorIgnored: true # noqa: var-naming
+assert: true # invalid due to being Python reserved keyword
+é: true # invalid due to non-ascii character
+hosts: true # invalid as being Ansible reserved name
+role_name: boo # invalid as being Ansible special magic variable
+ansible_facts: {} # special variable that we allow to be written
+ansible_python_interpreter: python3 # special variable that we allow to be written
diff --git a/examples/playbooks/vars/strings.transformed.yml b/examples/playbooks/vars/strings.transformed.yml
new file mode 100644
index 0000000..6f2aae1
--- /dev/null
+++ b/examples/playbooks/vars/strings.transformed.yml
@@ -0,0 +1,39 @@
+---
+# Make sure that the Transformer does not mangle strings
+# TODO: there is a bug in ruamel.yaml that discards some EOL comments
+
+single: single # this is a comment
+single_with_double: '"single" quoted' # this is a comment
+
+single_multiline_with_octothorpe: "single over 160 char line to force wrapping. over 160 char line to force wrapping. over 160 char line to force wrapping. over 160\n
+ # this is not a comment"
+
+double: double # this is a comment
+double_with_single: "'double' quoted" # this is a comment
+
+double_multiline_with_octothorpe: "double over 160 char line to force wrapping. over 160 char line to force wrapping. over 160 char line to force wrapping. over 160\n
+ # this is not a comment"
+
+# this is a comment
+folded_block_scalar_with_octothorpe: > # comment 1
+ # this is not a comment
+
+# this is a comment
+folded_chomp_strip_block_scalar_with_octothorpe: >- # comment 2
+ # this is not a comment
+
+# this is a comment
+folded_chomp_keep_block_scalar_with_octothorpe: >+ # comment 3
+ # this is not a comment
+
+# this is a comment
+literal_block_scalar_with_octothorpe: | # this is a | EOL comment
+ # this is not a comment
+
+# this is a comment
+literal_chomp_strip_block_scalar_with_octothorpe: |- # this is a | EOL comment
+ # this is not a comment
+
+# this is a comment
+literal_chomp_keep_block_scalar_with_octothorpe: | # this is a | EOL comment
+ # this is not a comment
diff --git a/examples/playbooks/vars/strings.yml b/examples/playbooks/vars/strings.yml
new file mode 100644
index 0000000..a1b7868
--- /dev/null
+++ b/examples/playbooks/vars/strings.yml
@@ -0,0 +1,45 @@
+---
+# Make sure that the Transformer does not mangle strings
+# TODO: there is a bug in ruamel.yaml that discards some EOL comments
+
+single: "single" # this is a comment
+single_with_double: '"single" quoted' # this is a comment
+
+single_multiline_with_octothorpe: # this EOL comment gets lost
+ "single over 160 char line to force wrapping. over 160 char line to force wrapping. over 160 char line to force wrapping.
+ over 160
+
+ # this is not a comment"
+
+double: "double" # this is a comment
+double_with_single: "'double' quoted" # this is a comment
+
+double_multiline_with_octothorpe: # this EOL comment gets lost
+ "double over 160 char line to force wrapping. over 160 char line to force wrapping. over 160 char line to force wrapping.
+ over 160
+
+ # this is not a comment"
+
+# this is a comment
+folded_block_scalar_with_octothorpe: > # comment 1
+ # this is not a comment
+
+# this is a comment
+folded_chomp_strip_block_scalar_with_octothorpe: >- # comment 2
+ # this is not a comment
+
+# this is a comment
+folded_chomp_keep_block_scalar_with_octothorpe: >+ # comment 3
+ # this is not a comment
+
+# this is a comment
+literal_block_scalar_with_octothorpe: | # this is a | EOL comment
+ # this is not a comment
+
+# this is a comment
+literal_chomp_strip_block_scalar_with_octothorpe: |- # this is a | EOL comment
+ # this is not a comment
+
+# this is a comment
+literal_chomp_keep_block_scalar_with_octothorpe: |+ # this is a | EOL comment
+ # this is not a comment
diff --git a/examples/playbooks/vars/subfolder/settings.yml b/examples/playbooks/vars/subfolder/settings.yml
new file mode 100644
index 0000000..1c84d58
--- /dev/null
+++ b/examples/playbooks/vars/subfolder/settings.yml
@@ -0,0 +1,2 @@
+---
+some_var: some_value_defined_in_vars_subfolder_settings
diff --git a/examples/playbooks/vars/vault_full.yml b/examples/playbooks/vars/vault_full.yml
new file mode 100644
index 0000000..c432c62
--- /dev/null
+++ b/examples/playbooks/vars/vault_full.yml
@@ -0,0 +1,11 @@
+---
+$ANSIBLE_VAULT;1.1;AES256
+35366433323361393130396530643233373262666636646439303032366431303363316232313738
+3738636130636431623936303932306430316635663136610a353737333966353462333532393631
+36613030643762636138613734313862333165346464626461313361353732336131633137653865
+3862386136386137650a303433643531613337393735633338383163353737656339653134346363
+63613436333937313738633437373566333065663662643664643261313366323236356364316663
+62336264666464323066336365616634626336616537646336656266343562336533343732613539
+61643661303566313664313164623731316236666235656337363632393665353536303730666532
+64666639306361653963363462393966623763626566613831613739333666333665343734333630
+63623730623033346163393834396639383234393637653733396466316132663131
diff --git a/examples/playbooks/vars/vault_partial.yml b/examples/playbooks/vars/vault_partial.yml
new file mode 100644
index 0000000..9806786
--- /dev/null
+++ b/examples/playbooks/vars/vault_partial.yml
@@ -0,0 +1,8 @@
+---
+ldap_password: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 35323062386261383633623963303361313937653837333033613933623434343138663331336164
+ 3534373564393166656664306537633035613962356662645a316562353832363736313935383665
+ 33306432623765646338303236363061326538653163643466643446716164326364643937623365
+ 6239383765373639390a646361343566353934633532376231653838386231653865386665303733
+ 34336534613538326639306139363538306636383463663437643466653064646363