summaryrefslogtreecommitdiffstats
path: root/examples/roles
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/roles
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 '')
-rw-r--r--examples/roles/ansible-role-foo/tasks/main.yaml0
-rw-r--r--examples/roles/bobbins/tasks/imported_tasks.yml0
-rw-r--r--examples/roles/bobbins/tasks/main.yml7
-rw-r--r--examples/roles/broken_argument_specs/meta/argument_specs.yml5
-rw-r--r--examples/roles/dependency_in_meta/meta/main.yml42
-rw-r--r--examples/roles/fixture_1/tasks/main.yml21
-rw-r--r--examples/roles/foo.yml0
-rw-r--r--examples/roles/hello/meta/argument_specs.yml27
-rw-r--r--examples/roles/hello/meta/main.yml3
-rw-r--r--examples/roles/include_in_the_place/tasks/included_file.yml4
-rw-r--r--examples/roles/include_in_the_place/tasks/main.yml3
-rw-r--r--examples/roles/include_miss/tasks/main.yml3
-rw-r--r--examples/roles/include_relative/tasks/included_file.yml4
-rw-r--r--examples/roles/include_relative/tasks/main.yml7
-rw-r--r--examples/roles/invalid-name/tasks/main.yaml4
-rw-r--r--examples/roles/invalid_due_syntax/tasks/main.yml2
-rw-r--r--examples/roles/invalid_due_to_meta/meta/main.yml10
-rw-r--r--examples/roles/invalid_due_to_meta/tasks/main.yaml0
-rw-r--r--examples/roles/invalid_meta_schema/meta/main.yml9
-rw-r--r--examples/roles/invalid_requirements_schema/meta/requirements.yml3
-rw-r--r--examples/roles/invalud_meta_schema0
-rw-r--r--examples/roles/loop_var_prefix/tasks/fail.yml46
-rw-r--r--examples/roles/loop_var_prefix/tasks/pass.yml30
-rw-r--r--examples/roles/meta_categories_as_list/meta/main.yml4
-rw-r--r--examples/roles/meta_incorrect_fail/meta/main.yml12
-rw-r--r--examples/roles/meta_no_tags_galaxy_info/meta/main.yml2
-rw-r--r--examples/roles/meta_no_tags_valid/meta/main.yml4
-rw-r--r--examples/roles/meta_noqa/meta/main.yml8
-rw-r--r--examples/roles/meta_tags_no_list/meta/main.yml3
-rw-r--r--examples/roles/meta_tags_not_a_string/meta/main.yml4
-rw-r--r--examples/roles/meta_video_links_fail/meta/main.yml27
-rw-r--r--examples/roles/meta_video_links_pass/meta/main.yml13
-rw-r--r--examples/roles/more_complex/handlers/main.yml3
-rw-r--r--examples/roles/more_complex/tasks/main.yml9
-rw-r--r--examples/roles/role_for_no_same_owner/tasks/fail.yml77
-rw-r--r--examples/roles/role_for_no_same_owner/tasks/pass.yml32
-rw-r--r--examples/roles/role_with_task_inclusions/tasks/imported_tasks.yml3
-rw-r--r--examples/roles/role_with_task_inclusions/tasks/included_tasks.yml3
-rw-r--r--examples/roles/role_with_task_inclusions/tasks/main.yml10
-rw-r--r--examples/roles/subfolder/1st_role/tasks/main.yml0
-rw-r--r--examples/roles/subfolder/2nd_role/tasks/main.yml0
-rw-r--r--examples/roles/subfolder/3rd_role/tasks/main.yml0
-rw-r--r--examples/roles/subfolder/other_role/tasks/main.yml4
-rw-r--r--examples/roles/template_lookup/files/a_file0
-rw-r--r--examples/roles/template_lookup/tasks/main.yml10
-rw-r--r--examples/roles/template_lookup_missing/tasks/main.yml7
-rw-r--r--examples/roles/test-role/meta/requirements.yml3
-rw-r--r--examples/roles/test-role/molecule/default/include-import-role.yml6
-rw-r--r--examples/roles/test-role/tasks/main.yml4
-rw-r--r--examples/roles/test-role/tasks/world.yml3
-rw-r--r--examples/roles/valid-due-to-meta/meta/main.yml10
-rw-r--r--examples/roles/valid-due-to-meta/tasks/debian/main.yml2
-rw-r--r--examples/roles/valid-due-to-meta/tasks/main.yaml0
-rw-r--r--examples/roles/var_naming_pattern/.ansible-lint2
-rw-r--r--examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml5
-rw-r--r--examples/roles/var_naming_pattern/tasks/include_task_with_vars.yml13
-rw-r--r--examples/roles/var_naming_pattern/tasks/main.yml4
57 files changed, 517 insertions, 0 deletions
diff --git a/examples/roles/ansible-role-foo/tasks/main.yaml b/examples/roles/ansible-role-foo/tasks/main.yaml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/ansible-role-foo/tasks/main.yaml
diff --git a/examples/roles/bobbins/tasks/imported_tasks.yml b/examples/roles/bobbins/tasks/imported_tasks.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/bobbins/tasks/imported_tasks.yml
diff --git a/examples/roles/bobbins/tasks/main.yml b/examples/roles/bobbins/tasks/main.yml
new file mode 100644
index 0000000..992c85c
--- /dev/null
+++ b/examples/roles/bobbins/tasks/main.yml
@@ -0,0 +1,7 @@
+---
+- name: Test tasks
+ action: git a=b c=d
+
+- name: Import tasks
+ ansible.builtin.import_tasks:
+ file: imported_tasks.yml
diff --git a/examples/roles/broken_argument_specs/meta/argument_specs.yml b/examples/roles/broken_argument_specs/meta/argument_specs.yml
new file mode 100644
index 0000000..ddc9862
--- /dev/null
+++ b/examples/roles/broken_argument_specs/meta/argument_specs.yml
@@ -0,0 +1,5 @@
+---
+argument_specs:
+ main:
+ foo: bar # <-- invalid based on json schema
+ options: {}
diff --git a/examples/roles/dependency_in_meta/meta/main.yml b/examples/roles/dependency_in_meta/meta/main.yml
new file mode 100644
index 0000000..ce20d01
--- /dev/null
+++ b/examples/roles/dependency_in_meta/meta/main.yml
@@ -0,0 +1,42 @@
+---
+# meta file, determined by ending in meta/main.yml
+# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#role-dependencies
+allow_duplicates: true
+dependencies:
+ # from Bitbucket
+ - src: git+http://bitbucket.org/willthames/git-ansible-galaxy
+ version: v1.4
+
+ # from Bitbucket, alternative syntax and caveats
+ - src: http://bitbucket.org/willthames/hg-ansible-galaxy
+ scm: hg
+
+ # from galaxy
+ - src: yatesr.timezone
+
+ # from GitHub
+ - src: https://github.com/bennojoy/nginx
+
+ # from GitHub, overriding the name and specifying a specific tag
+ - src: https://github.com/bennojoy/nginx
+ version: master
+ name: nginx_role
+
+ # from GitLab or other git-based scm
+ - src: git@gitlab.company.com:my-group/my-repo.git
+ scm: git
+ version: "0.1" # quoted, so YAML doesn't parse this as a floating-point value
+
+ # from a webserver, where the role is packaged in a tar.gz
+ - src: https://some.webserver.example.com/files/master.tar.gz
+ name: http-role
+
+galaxy_info:
+ standalone: true
+ author: foo
+ description: Testing meta
+ company: Not applicable
+ license: MIT
+ min_ansible_version: "2.5"
+ platforms:
+ - name: Fedora
diff --git a/examples/roles/fixture_1/tasks/main.yml b/examples/roles/fixture_1/tasks/main.yml
new file mode 100644
index 0000000..8e1706c
--- /dev/null
+++ b/examples/roles/fixture_1/tasks/main.yml
@@ -0,0 +1,21 @@
+---
+- name: Bad git 1 # noqa: latest[git]
+ action: ansible.builtin.git repo=. clone=no
+- name: Bad git 2 <-- 1st
+ action: ansible.builtin.git repo=. clone=no
+- name: Block with rescue and always section
+ block:
+ - name: Bad git 3 # noqa: latest[git]
+ action: ansible.builtin.git repo=. clone=no
+ - name: Bad git 4 <-- 2nd
+ action: ansible.builtin.git repo=. clone=no
+ rescue:
+ - name: Bad git 5 # noqa: latest[git]
+ action: ansible.builtin.git repo=. clone=no
+ - name: Bad git 6 <-- 3rd
+ action: ansible.builtin.git repo=. clone=no
+ always:
+ - name: Bad git 7 # noqa: latest[git]
+ action: ansible.builtin.git repo=. clone=no
+ - name: Bad git 8 <-- 4th
+ action: ansible.builtin.git repo=. clone=no
diff --git a/examples/roles/foo.yml b/examples/roles/foo.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/foo.yml
diff --git a/examples/roles/hello/meta/argument_specs.yml b/examples/roles/hello/meta/argument_specs.yml
new file mode 100644
index 0000000..47bde78
--- /dev/null
+++ b/examples/roles/hello/meta/argument_specs.yml
@@ -0,0 +1,27 @@
+---
+# https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html#role-argument-validation
+argument_specs:
+ main:
+ short_description: The main entry point for the role.
+ description: "a longer description"
+ options:
+ my_app_int:
+ type: "int"
+ required: false
+ default: 42
+ description: "The integer value, defaulting to 42."
+ no_log: false
+
+ my_app_str:
+ type: "str"
+ required: true
+ description: "The string value"
+
+ alternate:
+ short_description: The alternate entry point for the my_app role.
+ options:
+ my_app_int:
+ type: "int"
+ required: false
+ default: 1024
+ description: "The integer value, defaulting to 1024."
diff --git a/examples/roles/hello/meta/main.yml b/examples/roles/hello/meta/main.yml
new file mode 100644
index 0000000..b15a998
--- /dev/null
+++ b/examples/roles/hello/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - role: bobbins
diff --git a/examples/roles/include_in_the_place/tasks/included_file.yml b/examples/roles/include_in_the_place/tasks/included_file.yml
new file mode 100644
index 0000000..8dd30a3
--- /dev/null
+++ b/examples/roles/include_in_the_place/tasks/included_file.yml
@@ -0,0 +1,4 @@
+---
+- name: included_file | Test Fixture
+ ansible.builtin.debug:
+ msg: "was found & included"
diff --git a/examples/roles/include_in_the_place/tasks/main.yml b/examples/roles/include_in_the_place/tasks/main.yml
new file mode 100644
index 0000000..4e0d500
--- /dev/null
+++ b/examples/roles/include_in_the_place/tasks/main.yml
@@ -0,0 +1,3 @@
+---
+- name: Include a task
+ ansible.builtin.include_tasks: included_file.yml
diff --git a/examples/roles/include_miss/tasks/main.yml b/examples/roles/include_miss/tasks/main.yml
new file mode 100644
index 0000000..7df4ff2
--- /dev/null
+++ b/examples/roles/include_miss/tasks/main.yml
@@ -0,0 +1,3 @@
+---
+- name: Include a missing file
+ ansible.builtin.include_tasks: tasks/noexist_file.yml
diff --git a/examples/roles/include_relative/tasks/included_file.yml b/examples/roles/include_relative/tasks/included_file.yml
new file mode 100644
index 0000000..ef81833
--- /dev/null
+++ b/examples/roles/include_relative/tasks/included_file.yml
@@ -0,0 +1,4 @@
+---
+- name: included_file | Sample debug task
+ ansible.builtin.debug:
+ msg: "was found & included"
diff --git a/examples/roles/include_relative/tasks/main.yml b/examples/roles/include_relative/tasks/main.yml
new file mode 100644
index 0000000..de69255
--- /dev/null
+++ b/examples/roles/include_relative/tasks/main.yml
@@ -0,0 +1,7 @@
+---
+# ansible allow paths relative to role directory
+- name: 1st include
+ ansible.builtin.include_tasks: tasks/included_file.yml
+# relative to the current file, same effect as previous line
+- name: 2nd include
+ ansible.builtin.include_tasks: included_file.yml
diff --git a/examples/roles/invalid-name/tasks/main.yaml b/examples/roles/invalid-name/tasks/main.yaml
new file mode 100644
index 0000000..228dca3
--- /dev/null
+++ b/examples/roles/invalid-name/tasks/main.yaml
@@ -0,0 +1,4 @@
+---
+- name: Foo
+ ansible.builtin.debug:
+ msg: foo
diff --git a/examples/roles/invalid_due_syntax/tasks/main.yml b/examples/roles/invalid_due_syntax/tasks/main.yml
new file mode 100644
index 0000000..b029f9c
--- /dev/null
+++ b/examples/roles/invalid_due_syntax/tasks/main.yml
@@ -0,0 +1,2 @@
+---
+- name: Fixture for testing syntax-check[specific] on roles
diff --git a/examples/roles/invalid_due_to_meta/meta/main.yml b/examples/roles/invalid_due_to_meta/meta/main.yml
new file mode 100644
index 0000000..c389d74
--- /dev/null
+++ b/examples/roles/invalid_due_to_meta/meta/main.yml
@@ -0,0 +1,10 @@
+---
+galaxy_info:
+ standalone: true
+ role_name: invalid-due-to-meta # <-- invalid role name
+ author: foo
+ description: foo
+ license: MIT
+ platforms:
+ - name: AIX
+ min_ansible_version: "2.7"
diff --git a/examples/roles/invalid_due_to_meta/tasks/main.yaml b/examples/roles/invalid_due_to_meta/tasks/main.yaml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/invalid_due_to_meta/tasks/main.yaml
diff --git a/examples/roles/invalid_meta_schema/meta/main.yml b/examples/roles/invalid_meta_schema/meta/main.yml
new file mode 100644
index 0000000..c8ea8e2
--- /dev/null
+++ b/examples/roles/invalid_meta_schema/meta/main.yml
@@ -0,0 +1,9 @@
+---
+galaxy_info:
+ standalone: true
+ author: foo
+ description: false # <-- schema fail as string is expected
+ license: XXX
+ platforms:
+ - name: AIX
+ min_ansible_version: "2.7"
diff --git a/examples/roles/invalid_requirements_schema/meta/requirements.yml b/examples/roles/invalid_requirements_schema/meta/requirements.yml
new file mode 100644
index 0000000..41a70af
--- /dev/null
+++ b/examples/roles/invalid_requirements_schema/meta/requirements.yml
@@ -0,0 +1,3 @@
+---
+# this should fail validation
+foo: bar
diff --git a/examples/roles/invalud_meta_schema b/examples/roles/invalud_meta_schema
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/invalud_meta_schema
diff --git a/examples/roles/loop_var_prefix/tasks/fail.yml b/examples/roles/loop_var_prefix/tasks/fail.yml
new file mode 100644
index 0000000..a349330
--- /dev/null
+++ b/examples/roles/loop_var_prefix/tasks/fail.yml
@@ -0,0 +1,46 @@
+---
+# 5 expected loop-var-prefix failures at 3, 9, 19, 26, 33
+- name: fail | That should trigger loop-var-prefix
+ ansible.builtin.debug:
+ var: item
+ loop:
+ - foo
+ - bar
+- name: fail | That should fail due to wrong prefix
+ ansible.builtin.debug:
+ var: zz_item
+ loop:
+ - foo
+ - bar
+ loop_control:
+ loop_var: zz_item
+- name: fail | That should fail due to wrong prefix
+ ansible.builtin.debug:
+ var: zz_item
+ with_items:
+ - foo
+ - bar
+ loop_control:
+ loop_var: zz_item
+- name: fail | Using a block
+ block:
+ - name: fail | That should also not pass
+ ansible.builtin.debug:
+ var: item
+ loop:
+ - apples
+ - oranges
+ rescue:
+ - name: fail | That should also not pass
+ ansible.builtin.debug:
+ var: item
+ loop:
+ - avocados
+ - kiwis
+ always:
+ - name: fail | That should also not pass
+ ansible.builtin.debug:
+ var: item
+ loop:
+ - bananas
+ - muscats
diff --git a/examples/roles/loop_var_prefix/tasks/pass.yml b/examples/roles/loop_var_prefix/tasks/pass.yml
new file mode 100644
index 0000000..328c0a7
--- /dev/null
+++ b/examples/roles/loop_var_prefix/tasks/pass.yml
@@ -0,0 +1,30 @@
+---
+# 0 expected loop-var-prefix failures
+- name: pass | That should pass
+ ansible.builtin.debug:
+ var: loop_var_prefix_item
+ loop:
+ - foo
+ - bar
+ loop_control:
+ loop_var: loop_var_prefix_item
+- name: pass | Using a block
+ block:
+ - name: pass | That should also pass
+ ansible.builtin.debug:
+ var: loop_var_prefix_item
+ loop:
+ - foo
+ - bar
+ loop_control:
+ loop_var: loop_var_prefix_item
+- name: pass | Using alternative double underline prefix
+ block:
+ - name: pass | That should also pass
+ ansible.builtin.debug:
+ var: __some_item
+ loop:
+ - foo
+ - bar
+ loop_control:
+ loop_var: __some_item
diff --git a/examples/roles/meta_categories_as_list/meta/main.yml b/examples/roles/meta_categories_as_list/meta/main.yml
new file mode 100644
index 0000000..d96d6d8
--- /dev/null
+++ b/examples/roles/meta_categories_as_list/meta/main.yml
@@ -0,0 +1,4 @@
+---
+galaxy_info:
+ galaxy_tags: ["database", "my s q l", "MYTAG"]
+ categories: ["networking", "posix"]
diff --git a/examples/roles/meta_incorrect_fail/meta/main.yml b/examples/roles/meta_incorrect_fail/meta/main.yml
new file mode 100644
index 0000000..af61655
--- /dev/null
+++ b/examples/roles/meta_incorrect_fail/meta/main.yml
@@ -0,0 +1,12 @@
+# Fixture for meta-incorrect
+---
+galaxy_info: # <-- 4x meta-incorrect
+ author: your name
+ description: your description
+ company: your company (optional)
+ license: license (GPLv2, CC-BY, etc)
+ min_ansible_version: "2.12"
+ platforms:
+ - name: EL
+ versions:
+ - "7"
diff --git a/examples/roles/meta_no_tags_galaxy_info/meta/main.yml b/examples/roles/meta_no_tags_galaxy_info/meta/main.yml
new file mode 100644
index 0000000..827ee5d
--- /dev/null
+++ b/examples/roles/meta_no_tags_galaxy_info/meta/main.yml
@@ -0,0 +1,2 @@
+---
+galaxy_tags: ["database", "my s q l", "MYTAG"]
diff --git a/examples/roles/meta_no_tags_valid/meta/main.yml b/examples/roles/meta_no_tags_valid/meta/main.yml
new file mode 100644
index 0000000..9f76929
--- /dev/null
+++ b/examples/roles/meta_no_tags_valid/meta/main.yml
@@ -0,0 +1,4 @@
+---
+galaxy_info:
+ galaxy_tags: ["database", "my s q l", "MYTAG"]
+ categories: "my_category_not_in_a_list"
diff --git a/examples/roles/meta_noqa/meta/main.yml b/examples/roles/meta_noqa/meta/main.yml
new file mode 100644
index 0000000..eceb660
--- /dev/null
+++ b/examples/roles/meta_noqa/meta/main.yml
@@ -0,0 +1,8 @@
+---
+galaxy_info: # noqa: meta-incorrect
+ standalone: true
+ author: your-name
+ description: missing min_ansible_version and platforms. author default not changed
+ license: MIT
+ min_ansible_version: "2.10"
+ platforms: []
diff --git a/examples/roles/meta_tags_no_list/meta/main.yml b/examples/roles/meta_tags_no_list/meta/main.yml
new file mode 100644
index 0000000..6f18d13
--- /dev/null
+++ b/examples/roles/meta_tags_no_list/meta/main.yml
@@ -0,0 +1,3 @@
+---
+galaxy_info:
+ galaxy_tags: "database"
diff --git a/examples/roles/meta_tags_not_a_string/meta/main.yml b/examples/roles/meta_tags_not_a_string/meta/main.yml
new file mode 100644
index 0000000..21f3045
--- /dev/null
+++ b/examples/roles/meta_tags_not_a_string/meta/main.yml
@@ -0,0 +1,4 @@
+---
+galaxy_info:
+ galaxy_tags: [False, "database", "my s q l", "MYTAG"]
+ categories: "networking"
diff --git a/examples/roles/meta_video_links_fail/meta/main.yml b/examples/roles/meta_video_links_fail/meta/main.yml
new file mode 100644
index 0000000..f3c42f3
--- /dev/null
+++ b/examples/roles/meta_video_links_fail/meta/main.yml
@@ -0,0 +1,27 @@
+# Test fixture for mete-video-links test
+---
+galaxy_info:
+ standalone: true
+ author: foo
+ description: bar
+ license: MIT
+ min_ansible_version: "2.12"
+ platforms:
+ - name: EL
+ versions:
+ - "9"
+ # https://github.com/ansible/galaxy/blob/devel/galaxy/importer/loaders/role.py
+ video_links:
+ - url: https://www.youtube.com/watch?v=aWmRepTSFKs&feature=youtu.be
+ title: Proper format
+ - url: https://drive.google.com/file/d/1spYR51l8SqQqvAhSdZE7/view
+ title: Check for VIDEO_REGEXP validity and break
+ - https://www.youtube.com/watch?v=aWmRepTSFKs&feature=youtu.be
+ - my_bad_key: https://www.youtube.com/watch?v=aWmRepTSFKs&feature=youtu.be
+ title: This has a bad key
+ - url: www.acme.com/vid
+ title: Bad format of url
+ # https://github.com/ansible/galaxy/blob/devel/galaxy/importer/loaders/role.py#L303
+ cloud_platforms:
+ - amazon
+ - azure
diff --git a/examples/roles/meta_video_links_pass/meta/main.yml b/examples/roles/meta_video_links_pass/meta/main.yml
new file mode 100644
index 0000000..55e19c8
--- /dev/null
+++ b/examples/roles/meta_video_links_pass/meta/main.yml
@@ -0,0 +1,13 @@
+---
+galaxy_info:
+ author: foo
+ description: bar
+ license: MIT
+ min_ansible_version: "2.12"
+ platforms:
+ - name: EL
+ versions:
+ - "9"
+ video_links:
+ - url: https://youtu.be/S49_fX47UJA
+ title: Proper format
diff --git a/examples/roles/more_complex/handlers/main.yml b/examples/roles/more_complex/handlers/main.yml
new file mode 100644
index 0000000..1476749
--- /dev/null
+++ b/examples/roles/more_complex/handlers/main.yml
@@ -0,0 +1,3 @@
+---
+- name: Restart service using command
+ command: service bar restart
diff --git a/examples/roles/more_complex/tasks/main.yml b/examples/roles/more_complex/tasks/main.yml
new file mode 100644
index 0000000..62880a6
--- /dev/null
+++ b/examples/roles/more_complex/tasks/main.yml
@@ -0,0 +1,9 @@
+---
+- name: Test bad command
+ action: command mkdir blah
+
+- name: Test bad command v2
+ command: mkdir blah
+
+- name: Test bad local command
+ local_action: shell touch foo
diff --git a/examples/roles/role_for_no_same_owner/tasks/fail.yml b/examples/roles/role_for_no_same_owner/tasks/fail.yml
new file mode 100644
index 0000000..9c872b2
--- /dev/null
+++ b/examples/roles/role_for_no_same_owner/tasks/fail.yml
@@ -0,0 +1,77 @@
+---
+- name: fail | Block
+ block:
+ - name: fail | Synchronize-in-block
+ ansible.posix.synchronize:
+ src: dummy
+ dest: dummy
+
+- name: fail | Synchronize
+ ansible.posix.synchronize:
+ src: dummy
+ dest: dummy
+
+- name: fail | Nested-block
+ block:
+ - name: fail | Synchronize
+ block:
+ - name: fail | Synchronize-in-deep-block
+ ansible.posix.synchronize:
+ src: dummy
+ dest: dummy
+ rescue:
+ - name: fail | Synchronize-in-rescue
+ ansible.posix.synchronize:
+ src: dummy
+ dest: dummy
+ always:
+ - name: fail | Synchronize-in-always
+ ansible.posix.synchronize:
+ src: dummy
+ dest: dummy
+
+- name: fail | Unarchive-bz2
+ ansible.builtin.unarchive:
+ src: "{{ file }}.tar.bz2"
+ dest: dummy
+
+- name: fail | Unarchive delegated
+ ansible.builtin.unarchive:
+ src: "{{ file }}.tar.bz2"
+ dest: dummy
+ delegate_to: localhost
+
+- name: fail | Unarchive delegated-src-no-string
+ ansible.builtin.unarchive:
+ src: 4432
+ dest: dummy
+ delegate_to: localhost
+
+- name: fail | Unarchive-gz
+ ansible.builtin.unarchive:
+ src: "{{ file }}.tar.gz"
+ dest: dummy
+
+- name: fail | Unarchive-tar
+ ansible.builtin.unarchive:
+ src: "{{ file }}.tar"
+ dest: dummy
+
+- name: fail | Unarchive-xz
+ ansible.builtin.unarchive:
+ src: "{{ file }}.tar.xz"
+ dest: dummy
+
+- name: fail | Unarchive-zip
+ ansible.builtin.unarchive:
+ src: "{{ file }}.zip"
+ dest: dummy
+ extra_opts:
+ - -X
+
+- name: fail | Unarchive-zip-same-owner
+ ansible.builtin.unarchive:
+ src: "{{ file }}.zip"
+ dest: dummy
+ extra_opts:
+ - -X
diff --git a/examples/roles/role_for_no_same_owner/tasks/pass.yml b/examples/roles/role_for_no_same_owner/tasks/pass.yml
new file mode 100644
index 0000000..3af914b
--- /dev/null
+++ b/examples/roles/role_for_no_same_owner/tasks/pass.yml
@@ -0,0 +1,32 @@
+---
+- name: pass | Synchronize-delegate
+ ansible.posix.synchronize:
+ src: dummy
+ dest: dummy
+ delegate_to: localhost
+
+- name: pass | Synchronize-no-same-owner
+ ansible.posix.synchronize:
+ src: dummy
+ dest: dummy
+ owner: false
+ group: false
+
+- name: pass | Unarchive-no-same-owner
+ ansible.builtin.unarchive:
+ src: "{{ file }}.tar.gz"
+ dest: dummy
+ extra_opts:
+ - --no-same-owner
+
+- name: pass | Unarchive-remote-src
+ ansible.builtin.unarchive:
+ src: "{{ file }}.tar.gz"
+ dest: dummy
+ extra_opts:
+ - --no-same-owner
+
+- name: pass | Unarchive-unknown-file-ending
+ ansible.builtin.unarchive:
+ src: "{{ file }}"
+ dest: dummy
diff --git a/examples/roles/role_with_task_inclusions/tasks/imported_tasks.yml b/examples/roles/role_with_task_inclusions/tasks/imported_tasks.yml
new file mode 100644
index 0000000..5b1257e
--- /dev/null
+++ b/examples/roles/role_with_task_inclusions/tasks/imported_tasks.yml
@@ -0,0 +1,3 @@
+---
+# this task is missing a name (name[missing])
+- ansible.builtin.ping:
diff --git a/examples/roles/role_with_task_inclusions/tasks/included_tasks.yml b/examples/roles/role_with_task_inclusions/tasks/included_tasks.yml
new file mode 100644
index 0000000..5b1257e
--- /dev/null
+++ b/examples/roles/role_with_task_inclusions/tasks/included_tasks.yml
@@ -0,0 +1,3 @@
+---
+# this task is missing a name (name[missing])
+- ansible.builtin.ping:
diff --git a/examples/roles/role_with_task_inclusions/tasks/main.yml b/examples/roles/role_with_task_inclusions/tasks/main.yml
new file mode 100644
index 0000000..46bc212
--- /dev/null
+++ b/examples/roles/role_with_task_inclusions/tasks/main.yml
@@ -0,0 +1,10 @@
+---
+- name: Include 1
+ ansible.builtin.include_tasks: included_tasks.yml
+- name: Include 2
+ ansible.builtin.import_tasks: imported_tasks.yml
+- name: Include 3
+ ansible.builtin.include_tasks:
+ file: included_tasks.yml
+ apply:
+ tags: some_tag
diff --git a/examples/roles/subfolder/1st_role/tasks/main.yml b/examples/roles/subfolder/1st_role/tasks/main.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/subfolder/1st_role/tasks/main.yml
diff --git a/examples/roles/subfolder/2nd_role/tasks/main.yml b/examples/roles/subfolder/2nd_role/tasks/main.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/subfolder/2nd_role/tasks/main.yml
diff --git a/examples/roles/subfolder/3rd_role/tasks/main.yml b/examples/roles/subfolder/3rd_role/tasks/main.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/subfolder/3rd_role/tasks/main.yml
diff --git a/examples/roles/subfolder/other_role/tasks/main.yml b/examples/roles/subfolder/other_role/tasks/main.yml
new file mode 100644
index 0000000..b4d7f48
--- /dev/null
+++ b/examples/roles/subfolder/other_role/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- name: Foo
+ debug:
+ msg: "Hello!"
diff --git a/examples/roles/template_lookup/files/a_file b/examples/roles/template_lookup/files/a_file
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/template_lookup/files/a_file
diff --git a/examples/roles/template_lookup/tasks/main.yml b/examples/roles/template_lookup/tasks/main.yml
new file mode 100644
index 0000000..db2e490
--- /dev/null
+++ b/examples/roles/template_lookup/tasks/main.yml
@@ -0,0 +1,10 @@
+---
+# Place tasks in a block as templates are not rendered for top-level tasks
+# in roles. Specifically, in `play_children()` of src/ansiblelint/utils.py,
+# tasks in blocks go through `delegate_map['block']`, while top-level tasks
+# in a role is not handled by `delegate_map`.
+# Ref: https://github.com/ansible/ansible-lint/blob/v5.0.12/src/ansiblelint/utils.py#L305
+- block:
+ - name: Bug demo
+ ansible.builtin.debug:
+ msg: '{{ lookup("file", "a_file") }}'
diff --git a/examples/roles/template_lookup_missing/tasks/main.yml b/examples/roles/template_lookup_missing/tasks/main.yml
new file mode 100644
index 0000000..fc0542c
--- /dev/null
+++ b/examples/roles/template_lookup_missing/tasks/main.yml
@@ -0,0 +1,7 @@
+---
+# See comments in `examples/roles/template_lookup/tasks/main.yml`
+# for why the task is in a block.
+- block:
+ - name: Bug demo
+ ansible.builtin.debug:
+ msg: '{{ lookup("file", "a_file") }}'
diff --git a/examples/roles/test-role/meta/requirements.yml b/examples/roles/test-role/meta/requirements.yml
new file mode 100644
index 0000000..8e7fccc
--- /dev/null
+++ b/examples/roles/test-role/meta/requirements.yml
@@ -0,0 +1,3 @@
+---
+roles: []
+collections: []
diff --git a/examples/roles/test-role/molecule/default/include-import-role.yml b/examples/roles/test-role/molecule/default/include-import-role.yml
new file mode 100644
index 0000000..7dcd59e
--- /dev/null
+++ b/examples/roles/test-role/molecule/default/include-import-role.yml
@@ -0,0 +1,6 @@
+---
+- name: Fixture for test_run_playbook test
+ gather_facts: false
+ hosts: all
+ roles:
+ - role: test-role
diff --git a/examples/roles/test-role/tasks/main.yml b/examples/roles/test-role/tasks/main.yml
new file mode 100644
index 0000000..8e5402f
--- /dev/null
+++ b/examples/roles/test-role/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- name: Shell instead of command
+ ansible.builtin.shell:
+ cmd: echo hello world
diff --git a/examples/roles/test-role/tasks/world.yml b/examples/roles/test-role/tasks/world.yml
new file mode 100644
index 0000000..3f3fd3e
--- /dev/null
+++ b/examples/roles/test-role/tasks/world.yml
@@ -0,0 +1,3 @@
+---
+- command: # noqa: fqcn
+ cmd: echo this is a task without a name # noqa: no-free-form
diff --git a/examples/roles/valid-due-to-meta/meta/main.yml b/examples/roles/valid-due-to-meta/meta/main.yml
new file mode 100644
index 0000000..32fc400
--- /dev/null
+++ b/examples/roles/valid-due-to-meta/meta/main.yml
@@ -0,0 +1,10 @@
+---
+galaxy_info:
+ standalone: true
+ role_name: valid_due_to_meta
+ author: foo
+ description: foo
+ license: MIT
+ platforms:
+ - name: Fedora
+ min_ansible_version: "2.7"
diff --git a/examples/roles/valid-due-to-meta/tasks/debian/main.yml b/examples/roles/valid-due-to-meta/tasks/debian/main.yml
new file mode 100644
index 0000000..6fa48c2
--- /dev/null
+++ b/examples/roles/valid-due-to-meta/tasks/debian/main.yml
@@ -0,0 +1,2 @@
+# This empty task file is here to test that roles with tasks organized in subdirectories
+# are handled correctly by ansible-lint.
diff --git a/examples/roles/valid-due-to-meta/tasks/main.yaml b/examples/roles/valid-due-to-meta/tasks/main.yaml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/roles/valid-due-to-meta/tasks/main.yaml
diff --git a/examples/roles/var_naming_pattern/.ansible-lint b/examples/roles/var_naming_pattern/.ansible-lint
new file mode 100644
index 0000000..d6dc161
--- /dev/null
+++ b/examples/roles/var_naming_pattern/.ansible-lint
@@ -0,0 +1,2 @@
+---
+var_naming_pattern: "^[a-z][a-z0-9_]*[a-z0-9]__[a-z][a-z0-9_]*[a-z0-9]$"
diff --git a/examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml b/examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml
new file mode 100644
index 0000000..23113eb
--- /dev/null
+++ b/examples/roles/var_naming_pattern/tasks/cacheable_set_fact.yml
@@ -0,0 +1,5 @@
+---
+- name: cacheable_set_fact | Using set_fact with cacheable
+ ansible.builtin.set_fact:
+ var_naming_pattern_fact: bar
+ cacheable: true
diff --git a/examples/roles/var_naming_pattern/tasks/include_task_with_vars.yml b/examples/roles/var_naming_pattern/tasks/include_task_with_vars.yml
new file mode 100644
index 0000000..5151cd3
--- /dev/null
+++ b/examples/roles/var_naming_pattern/tasks/include_task_with_vars.yml
@@ -0,0 +1,13 @@
+---
+- name: include_task_with_vars | Foo
+ ansible.builtin.include_tasks: ../tasks/included-task-with-vars.yml
+ vars:
+ var_naming_pattern_foo: bar
+
+- name: include_task_with_vars | Foo
+ ansible.builtin.include_role:
+ name: bobbins
+ vars:
+ bobbins_foo: bar
+ # ^ this is valid because for include/import, the prefix should be of the
+ # included role and from of the current role.
diff --git a/examples/roles/var_naming_pattern/tasks/main.yml b/examples/roles/var_naming_pattern/tasks/main.yml
new file mode 100644
index 0000000..896a7f2
--- /dev/null
+++ b/examples/roles/var_naming_pattern/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- name: Foobar
+ ansible.builtin.set_fact:
+ var_naming_pattern__namespace: "foo"