-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create the task-values[name-word-misspelled] rule
The convention 'Do not use abbreviations in task names.' will be enforced by this new rule. The regular expression used underneath the split_words method treats a hyphened word as separate words. For example, the word libvirt-ro would be split into libvirt and ro words. Hence, why the dictionary.txt file may appear to contain abbreviations. Also, the words loaded into the dictionary.txt file are case-insensitive because I want to use 'en' language dictionary.
- Loading branch information
Showing
8 changed files
with
153 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ repos: | |
additional_dependencies: | ||
- ansible-core ==2.17.0 | ||
- jmespath ==1.0.1 | ||
- pyspellchecker ==0.8.1 | ||
|
||
- repo: https://github.com/adrienverge/yamllint.git | ||
rev: v1.35.1 | ||
|
@@ -45,6 +46,14 @@ repos: | |
additional_dependencies: | ||
- [email protected] | ||
|
||
- id: gendict.py | ||
name: gendict.py | ||
entry: ./scripts/gendict.py | ||
language: python | ||
additional_dependencies: | ||
- ansible-lint ==24.9.0 | ||
- pyspellchecker ==0.8.1 | ||
|
||
- repo: https://github.com/gitleaks/gitleaks.git | ||
rev: v8.18.3 | ||
hooks: | ||
|
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,95 @@ | ||
admin | ||
ansible_user | ||
api | ||
apt's | ||
apt_inst | ||
apt_pkg | ||
aptsources | ||
arptables | ||
authorized_keys | ||
bgp | ||
br_netfilter | ||
ca | ||
calicoctl | ||
cfg | ||
cni | ||
conf | ||
containerd | ||
crds | ||
cri | ||
cronjobs | ||
csrs | ||
debian | ||
dhcp | ||
dns | ||
dnsmasq | ||
dotfile | ||
ebtables | ||
en_us | ||
etcd | ||
etcdctl | ||
fail2ban | ||
foo | ||
glibc's | ||
gpg | ||
grub_cmdline_linux_default | ||
haproxy | ||
homelab | ||
hostname | ||
ifnames | ||
init | ||
inode | ||
inventory_hostname | ||
ip6tables | ||
iptables | ||
irc | ||
k8s_controller | ||
k8s_first_controller | ||
k8s_ha_controller | ||
k8s_worker | ||
keepalived | ||
kube | ||
kube_apiservers | ||
kubeadm | ||
kubeconfig | ||
kubectl | ||
kubelet | ||
kubelets | ||
kubernetes | ||
kubernetes's | ||
kvm | ||
libexec | ||
libvirt | ||
libvirtd | ||
lockdown | ||
locpath | ||
logind | ||
namespace | ||
networkd | ||
nginx | ||
nodeport | ||
pam_access | ||
permitrootlogin | ||
poseidon | ||
poseidon_ingress_nginx_node_http_port | ||
python3 | ||
qemu | ||
readyz | ||
resolv | ||
ro | ||
schedulable | ||
sigterm | ||
sshd | ||
systemd | ||
tarball | ||
tigera | ||
tmux | ||
udev | ||
uri | ||
userland | ||
utf | ||
vrrp | ||
weechat | ||
weechat's | ||
whoami | ||
x86_64 |
This file was deleted.
Oops, something went wrong.
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
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,29 @@ | ||
#!/usr/bin/env python3 | ||
"""Creates the Ansible tasks' name dictionary.""" | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
from ansiblelint.config import Options | ||
from ansiblelint.rules import RulesCollection | ||
from ansiblelint.runner import Runner | ||
from ansiblelint.utils import get_lintables, task_in_list | ||
from spellchecker import SpellChecker # type: ignore # spellchecker stubs don't exist | ||
|
||
spell_checker, unknown_words = SpellChecker(), set() | ||
for lintable in Runner( | ||
*get_lintables(Options()), rules=RulesCollection([Path("./rules")]) | ||
).lintables: | ||
if lintable.kind in ["handlers", "tasks", "playbook"]: | ||
for task in task_in_list(lintable.data, lintable, lintable.kind): | ||
if task.name: | ||
for unknown_word in spell_checker.unknown( | ||
spell_checker.split_words(task.name) | ||
): | ||
unknown_words.add(unknown_word) | ||
|
||
with open(Path("./docs/dictionary.txt"), "w") as file: | ||
for unknown_word in sorted(unknown_words): | ||
file.write(f"{unknown_word}\n") | ||
|
||
sys.exit(0) |