Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align variable names with new standards #463

Merged
merged 32 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
40aafec
Merge legacy.yml into Linux.yml.
robin-checkmk Aug 15, 2023
3b88c36
Generalize file management.
robin-checkmk Aug 15, 2023
9b2cdc0
Fix variable usage in names.
robin-checkmk Aug 15, 2023
dcb5056
Remove WIP file.
robin-checkmk Aug 15, 2023
77d6817
Rename variables for more clarity.
robin-checkmk Sep 12, 2023
028bf54
Merge branch 'devel' into feature/reorganize-agent-role
robin-checkmk Sep 12, 2023
ae8a1aa
Make agent port configurable.
robin-checkmk Sep 12, 2023
bc3801c
Merge branch 'feature/reorganize-agent-role' of github.com:Checkmk/an…
robin-checkmk Sep 12, 2023
2fe135f
Make agent port verification configurable.
robin-checkmk Sep 12, 2023
5e8a385
Update README and bugfix handler.
robin-checkmk Sep 12, 2023
2a08737
Update variable style guide.
robin-checkmk Oct 27, 2023
70d9f65
Standardize variables for playbooks.
robin-checkmk Oct 27, 2023
3a67470
Standardize variables for roles.
robin-checkmk Oct 27, 2023
210f16a
Standardize variables for tests.
robin-checkmk Oct 27, 2023
fe3a39a
Update ansible-lint configuration.
robin-checkmk Oct 27, 2023
f1d62a7
Extend roles standards to playbooks.
robin-checkmk Oct 27, 2023
e44df75
Bugfix linting action.
robin-checkmk Oct 27, 2023
f319d0c
Merge branch 'devel' into feature/reorganize-agent-role
robin-checkmk Oct 31, 2023
1736eff
Merge branch 'devel' into breaking/align-var-naming-rules
robin-checkmk Nov 9, 2023
1c69d63
Merge branch 'devel' into feature/reorganize-agent-role
robin-checkmk Nov 9, 2023
5c7a3f8
Update tests with aligned variable names.
robin-checkmk Nov 9, 2023
4f5747f
Fix server_url variable.
robin-checkmk Nov 9, 2023
d93dcdf
Clean up documentation.
robin-checkmk Nov 10, 2023
cebdc48
Merge branch 'breaking/align-var-naming-rules' into feature/reorganiz…
robin-checkmk Nov 10, 2023
690ea11
Merge pull request #413 from Checkmk/feature/reorganize-agent-role
robin-checkmk Nov 24, 2023
4019062
Fix linting findings.
robin-checkmk Nov 24, 2023
6b3c4fa
Add molecule to testing.sh.
robin-checkmk Nov 24, 2023
839627c
Fix molecule tests.
robin-checkmk Nov 24, 2023
7bee5c7
Improve module documentation.
robin-checkmk Nov 24, 2023
b1d0eb1
Fix variables in demo playbooks.
robin-checkmk Nov 24, 2023
2acf859
Fix variables in integration tests.
robin-checkmk Nov 24, 2023
c5bc4bb
Cleanup modules documentation.
robin-checkmk Nov 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading