Skip to content

Commit

Permalink
Prepare fixtures for upcoming name[play] rule (#2302)
Browse files Browse the repository at this point in the history
Related: #2295
  • Loading branch information
ssbarnea committed Aug 16, 2022
1 parent 39c077a commit 603bf4d
Show file tree
Hide file tree
Showing 34 changed files with 117 additions and 71 deletions.
4 changes: 2 additions & 2 deletions examples/playbooks/become.transformed.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: all

- name: Fixture
hosts: all
tasks:
- name: Clone content repository
ansible.builtin.git:
Expand Down
4 changes: 2 additions & 2 deletions examples/playbooks/become.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: all

- name: Fixture
hosts: all
tasks:
- name: Clone content repository
ansible.builtin.git:
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/blockincludes.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
vars:
varset: varset
tasks:
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/blockincludes2.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: webservers
- name: Fixture
hosts: webservers
vars:
varset: varset
tasks:
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/common-include-1.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture for test_files_not_scanned_twice
hosts: localhost
gather_facts: false
tasks:
- name: Some include
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/common-include-2.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
gather_facts: false
tasks:
- name: Some include
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/contains_secrets.transformed.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
vars:
plain: hello123
# spell-checker: disable-next-line
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/contains_secrets.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
vars:
plain: hello123
# spell-checker: disable-next-line
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/custom_module.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
gather_facts: false
tags:
- "{{ foo }}"
Expand Down
4 changes: 2 additions & 2 deletions examples/playbooks/example.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: webservers

- name: Fixture for test_example
hosts: webservers
vars:
old_school: 1.2.3
bracket: and close bracket
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/include-import-tasks-in-role.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- hosts: all
- name: Fixture
hosts: all
roles:
- role_with_task_inclusions
4 changes: 2 additions & 2 deletions examples/playbooks/include-in-block.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: all

- name: Fixture
hosts: all
tasks:
- ansible.builtin.include_tasks: tasks/include-in-block-inner.yml
4 changes: 2 additions & 2 deletions examples/playbooks/lots_of_warnings.transformed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Enough to exceed typical stdout buffering size and thus to show the need for
# catching IOError (EPIPE) errors.

- hosts: webservers

- name: Fixture
hosts: webservers
tasks:
- name: Executing git through command
action: ansible.builtin.command git clone blah
Expand Down
4 changes: 2 additions & 2 deletions examples/playbooks/lots_of_warnings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Enough to exceed typical stdout buffering size and thus to show the need for
# catching IOError (EPIPE) errors.

- hosts: webservers

- name: Fixture
hosts: webservers
tasks:
- name: Executing git through command
action: ansible.builtin.command git clone blah
Expand Down
4 changes: 2 additions & 2 deletions examples/playbooks/nomatchestest.transformed.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: whatever

- name: Fixture
hosts: whatever
tasks:
- name: Hello world
action: debug msg="Hello!" # noqa: fqcn-builtins
Expand Down
4 changes: 2 additions & 2 deletions examples/playbooks/nomatchestest.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- hosts: whatever

- name: Fixture
hosts: whatever
tasks:
- name: Hello world
action: debug msg="Hello!" # noqa: fqcn-builtins
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/playbook-imported.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
connection: local
gather_facts: false
tasks:
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/rule-only-builtins.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture for examples/playbooks/rule-only-builtins.yml
hosts: localhost
tasks:
- name: Sysctl
# while next module is mocked in our config, we still want to see that
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/task-has-name-success.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: all
- name: Play for testing name[missing] rule
hosts: all
tasks:
- name: This task has a name
ansible.builtin.command: echo "Hello World"
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/task-name-lowercase.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: all
- name: Fixture for src/ansiblelint/rules/name.py::test_rule_name_lowercase
hosts: all
tasks:
- name: this task has a name is not correctly capitalized
ansible.builtin.command: echo "Hello World"
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/taskimports.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
vars:
varset: tasks/simple_task.yml
tasks:
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/taskincludes.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
- name: Fixture
hosts: localhost
vars:
varset: tasks/simple_task.yml
tasks:
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/unicode.transformed.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: all
- name: Fixture
hosts: all
tasks:
# cspell:disable-next-line
- name: Some тест
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/unicode.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: all
- name: Fixture
hosts: all
tasks:
# cspell:disable-next-line
- name: Some тест
Expand Down
3 changes: 2 additions & 1 deletion examples/playbooks/valid_with_alt_extension.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# Used to validate that we also accept .yaml extension on playbooks
- hosts: localhost
- name: Fixture
hosts: localhost
tasks:
- ansible.builtin.debug: # <-- should notify about missing 'name'
msg: hello!
6 changes: 4 additions & 2 deletions src/ansiblelint/rules/command_instead_of_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@


FAIL_PLAY = """---
- hosts: localhost
- name: Fixture
hosts: localhost
tasks:
- name: Shell no pipe
ansible.builtin.shell: echo hello
Expand All @@ -48,7 +49,8 @@
"""

SUCCESS_PLAY = """---
- hosts: localhost
- name: Fixture
hosts: localhost
tasks:
- name: Shell with pipe
ansible.builtin.shell: echo hello | true # noqa: risky-shell-pipe
Expand Down
39 changes: 26 additions & 13 deletions test/rules/test_nested_jinja_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: One-level nesting
ansible.builtin.set_fact:
Expand All @@ -45,7 +46,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: One-level multiline nesting
ansible.builtin.set_fact:
Expand All @@ -60,7 +62,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Two-level nesting
ansible.builtin.set_fact:
Expand All @@ -72,7 +75,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Two-level multiline nesting
ansible.builtin.set_fact:
Expand All @@ -88,7 +92,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Five-level wild nesting
ansible.builtin.set_fact:
Expand All @@ -100,7 +105,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Five-level wild multiline nesting
ansible.builtin.set_fact:
Expand All @@ -121,7 +127,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Non-nested example
ansible.builtin.set_fact:
Expand All @@ -133,7 +140,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Multiline non-nested example
ansible.builtin.set_fact:
Expand All @@ -147,7 +155,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Nesting far from each other
ansible.builtin.set_fact:
Expand All @@ -159,7 +168,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Multiline nesting far from each other
ansible.builtin.set_fact:
Expand All @@ -174,7 +184,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Nesting close to each other
ansible.builtin.set_fact:
Expand All @@ -186,7 +197,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Multiline nesting close to each other
ansible.builtin.set_fact:
Expand All @@ -201,7 +213,8 @@
"playbook.yml",
"""\
---
- hosts: all
- name: Fixture
hosts: all
tasks:
- name: Print curly braces
ansible.builtin.debug:
Expand Down
3 changes: 2 additions & 1 deletion test/test_ansiblesyntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

PB_WITH_NULL_TASKS = """\
---
- hosts: all
- name: Fixture for test_null_tasks
hosts: all
tasks:
"""

Expand Down

0 comments on commit 603bf4d

Please sign in to comment.