From 64732fe43ff0b86c49b5864bffde7c55cf5e45b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Wed, 3 Apr 2024 12:35:49 +0200 Subject: [PATCH] add systemctl get-default as acceptable command (#4087) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- examples/playbooks/rule-command-instead-of-module-pass.yml | 4 ++++ src/ansiblelint/rules/command_instead_of_module.py | 1 + src/ansiblelint/schemas/__store__.json | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/playbooks/rule-command-instead-of-module-pass.yml b/examples/playbooks/rule-command-instead-of-module-pass.yml index d354225be2..2fbc5c2ad3 100644 --- a/examples/playbooks/rule-command-instead-of-module-pass.yml +++ b/examples/playbooks/rule-command-instead-of-module-pass.yml @@ -22,6 +22,10 @@ ansible.builtin.command: systemctl show-environment changed_when: false + - name: Get systemd runlevel + ansible.builtin.command: systemctl get-default + changed_when: false + - name: Set systemd runlevel ansible.builtin.command: systemctl set-default multi-user.target changed_when: false diff --git a/src/ansiblelint/rules/command_instead_of_module.py b/src/ansiblelint/rules/command_instead_of_module.py index 351b57aa2e..2492aa760e 100644 --- a/src/ansiblelint/rules/command_instead_of_module.py +++ b/src/ansiblelint/rules/command_instead_of_module.py @@ -72,6 +72,7 @@ class CommandsInsteadOfModulesRule(AnsibleLintRule): "git": ["branch", "log", "lfs", "rev-parse"], "systemctl": [ "--version", + "get-default", "kill", "set-default", "set-property", diff --git a/src/ansiblelint/schemas/__store__.json b/src/ansiblelint/schemas/__store__.json index 26e586fe89..607366939c 100644 --- a/src/ansiblelint/schemas/__store__.json +++ b/src/ansiblelint/schemas/__store__.json @@ -24,7 +24,7 @@ "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json" }, "meta": { - "etag": "e04a9e9c210c666c744dfe9ebf1ca1f4e95e71bd16995514b9c3a56186e66c98", + "etag": "54b5e8c779eb0959619335dcb4d04824bbe0036e5f2bf50b581ea5ed77fd2644", "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta.json" }, "meta-runtime": {