summaryrefslogtreecommitdiffstats
path: root/examples/playbooks/vars
diff options
context:
space:
mode:
Diffstat (limited to 'examples/playbooks/vars')
-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/not_decryptable.yml10
-rw-r--r--examples/playbooks/vars/other.yml2
-rw-r--r--examples/playbooks/vars/rule_jinja_vars.yml5
-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
10 files changed, 150 insertions, 0 deletions
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/not_decryptable.yml b/examples/playbooks/vars/not_decryptable.yml
new file mode 100644
index 0000000..9a19b07
--- /dev/null
+++ b/examples/playbooks/vars/not_decryptable.yml
@@ -0,0 +1,10 @@
+$ANSIBLE_VAULT;1.1;AES256
+35366433323361393130396530643233373262666636646439303032366431303363316232313738
+3738636130636431623936303932306430316635663136610a353737333966353462333532393631
+36613030643762636138613734313862333165346464626461313361353732336131633137653865
+3862386136386137650a303433643531613337393735633338383163353737656339653134346363
+63613436333937313738633437373566333065663662643664643261313366323236356364316663
+62336264666464323066336365616634626336616537646336656266343562336533343732613539
+61643661303566313664313164623731316236666235656337363632393665353536303730666532
+64666639306361653963363462393966623763626566613831613739333666333665343734333630
+63623730623033346163393834396639383234393637653733396466316132663131
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/strings.transformed.yml b/examples/playbooks/vars/strings.transformed.yml
new file mode 100644
index 0000000..d4a737a
--- /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: >
+ # this is not a comment
+
+# this is a comment
+folded_chomp_strip_block_scalar_with_octothorpe: >-
+ # this is not a comment
+
+# this is a comment
+folded_chomp_keep_block_scalar_with_octothorpe: >+
+ # 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..6be848e
--- /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: > # > EOL comment gets lost
+ # this is not a comment
+
+# this is a comment
+folded_chomp_strip_block_scalar_with_octothorpe: >- # > EOL comment gets lost
+ # this is not a comment
+
+# this is a comment
+folded_chomp_keep_block_scalar_with_octothorpe: >+ # > EOL comment gets lost
+ # 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