Skip to content

Commit

Permalink
Merge pull request #463 from Checkmk/breaking/align-var-naming-rules
Browse files Browse the repository at this point in the history
Align variable names with new standards
  • Loading branch information
robin-checkmk committed Nov 24, 2023
2 parents 49bd439 + c5bc4bb commit d2c3368
Show file tree
Hide file tree
Showing 122 changed files with 1,803 additions and 1,788 deletions.
2 changes: 1 addition & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exclude_paths:
# requirements, like avoiding python identifiers. To disable add `var-naming`
# to skip_list.
# var_naming_pattern: "^[a-z_][a-z0-9_]*$"
var_naming_pattern: "^checkmk_(server|agent)_.*$"
var_naming_pattern: "^checkmk_(server|agent|var)_.*$"

use_default_rules: true
# Load custom rules from this specific folder
Expand Down
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ There are different approaches to the module options, depending on the nature of

It is possible to implement an alias for a module option. This should be used rather carefully to not clutter the options. However, they can be an option, if one is uncertain how to name an option, or to deprecate an option, before actually removing it. If in doubt, feel free to ask for review in your PR.

### Roles
The following are guidelines to keep in mind, when changing roles.
### Roles and Playbooks
The following are guidelines to keep in mind, when creating or changing roles and playbooks.
- Variables
- Use snake case (`snake_case_variable`)
- Name variables after their purpose.
- `checkmk_server_foo` for a server role variable
- `checkmk_agent_bar` for a agent role variable
- `checkmk_var_bat` for general variables
- Do not prefix the variable with an underscore ( `_` )
- Tags
- When tagging roles, separate single words with dashes (`my-custom-tag`)
- When tagging roles or playbooks, separate single words with dashes (`my-custom-tag`)

## Tests
We strive to provide the best possible quality with this collection, hence we have implemented tests, that verify different aspects of code quality.
Expand Down
135 changes: 67 additions & 68 deletions playbooks/demo/downtimes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,49 @@
tasks:
- name: "Create folders."
folder:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
path: "{{ item.path }}"
name: "{{ item.name }}"
state: "present"
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_folders }}"
loop: "{{ checkmk_var_folders }}"

- name: "Create hosts."
host:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ inventory_hostname }}"
folder: "{{ checkmk_folder_path }}"
folder: "{{ checkmk_var_folder_path }}"
attributes:
site: "{{ site }}"
site: "{{ checkmk_var_site }}"
ipaddress: 127.0.0.1
state: "present"
delegate_to: localhost

- name: "Activate changes on site."
activation:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
force_foreign_changes: 'true'
sites:
- "{{ site }}"
- "{{ checkmk_var_site }}"
delegate_to: localhost
run_once: true # noqa run-once[task]

- name: "Downtime 1 - on services with relative timestamps"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
comment: downtime 1 - on services with relative timestamps
start_after:
Expand All @@ -67,10 +67,10 @@

- name: "Downtime 2 - on services with absolute timestamps"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
comment: downtime 2 - on services with absolute timestamps
start_time: "2024-03-25T20:39:28Z"
Expand All @@ -82,10 +82,10 @@

- name: "Downtime 3 - on services without timestamps"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
comment: downtime 3 - on services without timestamps
service_descriptions:
Expand All @@ -97,10 +97,10 @@

- name: "Downtime 4 - on host with relative times"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
comment: downtime 4 - on host with relative timestamps
start_after:
Expand All @@ -113,10 +113,10 @@

- name: "Downtime 5 - on host with absolute timestamps"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
comment: downtime 5 - on host with absolute timestamps
start_time: "2024-03-25T20:39:28Z"
Expand All @@ -125,27 +125,27 @@

- name: "Downtime 6 - on host without timestamps"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
comment: downtime 6 - on host without timestamps
delegate_to: localhost

- name: "Pause to review changes."
ansible.builtin.pause:
prompt: |
"Feel free to review the changes in your Checkmk site: {{ site }}."
"Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}."
"Press <Enter> to continue."
when: not run_unattended | bool
when: not checkmk_var_run_unattended | bool

- name: "Downtime delete 1 - service downtimes"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
service_descriptions:
- "Check_MK"
Expand All @@ -155,54 +155,53 @@

- name: "Downtime delete 2 - host downtimes"
downtime:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
host_name: "{{ inventory_hostname }}"
state: absent
delegate_to: localhost

- name: "Pause to review changes."
ansible.builtin.pause:
prompt: |
"Feel free to review the changes in your Checkmk site: {{ site }}."
"Feel free to review the changes in your Checkmk site: {{ checkmk_var_site }}."
"Press <Enter> to continue."
when: not run_unattended | bool
when: not checkmk_var_run_unattended | bool

- name: "Delete Hosts."
host:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
name: "{{ inventory_hostname }}"
folder: "{{ checkmk_folder_path }}"
folder: "{{ checkmk_var_folder_path }}"
state: "absent"
delegate_to: localhost

- name: "Delete folders."
folder:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
path: "{{ item.path }}"
name: "{{ item.name }}"
state: "absent"
register: testout
delegate_to: localhost
run_once: true # noqa run-once[task]
loop: "{{ checkmk_folders }}"
loop: "{{ checkmk_var_folders }}"

- name: "Activate changes on site."
activation:
server_url: "{{ server_url }}"
site: "{{ site }}"
automation_user: "{{ automation_user }}"
automation_secret: "{{ automation_secret }}"
server_url: "{{ checkmk_var_server_url }}"
site: "{{ checkmk_var_site }}"
automation_user: "{{ checkmk_var_automation_user }}"
automation_secret: "{{ checkmk_var_automation_secret }}"
force_foreign_changes: 'true'
sites:
- "{{ site }}"
- "{{ checkmk_var_site }}"
delegate_to: localhost
run_once: true # noqa run-once[task]
Loading

0 comments on commit d2c3368

Please sign in to comment.