-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add name[play] to highlight plays without name
From now on, we will be require plays to have names, same as task, as these are also displayed by Ansible and help documenting them. Related: #2171
- Loading branch information
Showing
8 changed files
with
84 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- hosts: localhost # <-- name[missing] | ||
tasks: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
--- | ||
- hosts: all | ||
- hosts: all # <-- name[missing] | ||
tasks: | ||
- ansible.builtin.command: echo "no name" # <-- 1 | ||
- ansible.builtin.command: echo "no name" # <-- name[missing] | ||
changed_when: false | ||
- name: "" # <-- 2 | ||
- name: "" # <-- name[missing] | ||
ansible.builtin.command: echo "empty name" | ||
changed_when: false | ||
- ansible.builtin.debug: # <-- 3 | ||
- ansible.builtin.debug: # <-- name[missing] | ||
msg: Debug without a name | ||
- ansible.builtin.meta: flush_handlers # <-- 4 | ||
- ansible.builtin.meta: flush_handlers # <-- name[missing] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
## name | ||
|
||
This rule identifies several problems related to task naming. This is important | ||
because these names are the primary way to identify executed tasks on console, | ||
logs or web interface. Their role is also to document what a task is supposed | ||
to do. | ||
This rule identifies several problems related to naming of tasks and plays. | ||
This is important because these names are the primary way to identify executed | ||
operations on console, logs or web interface. Their role is also to document | ||
what Ansible is supposed to do. | ||
|
||
- `name[missing]` - All tasks are required to have a name | ||
- `name[casing]` - All task names should start with a capital letter | ||
This rule can produce messages such: | ||
|
||
- `name[casing]` - All names should start with an uppercase letter. | ||
- `name[missing]` - All tasks should be named. | ||
- `name[play]` - All plays should be named. | ||
|
||
### Problematic code | ||
|
||
```yaml | ||
--- | ||
- ansible.builtin.command: touch /tmp/.placeholder | ||
- hosts: localhost | ||
tasks: | ||
- ansible.builtin.command: touch /tmp/.placeholder | ||
``` | ||
|
||
### Correct code | ||
|
||
```yaml | ||
--- | ||
- name: Create placeholder file | ||
ansible.builtin.command: touch /tmp/.placeholder | ||
- name: Play for creating playholder | ||
hosts: localhost | ||
tasks: | ||
- name: Create placeholder file | ||
ansible.builtin.command: touch /tmp/.placeholder | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters