Compare commits

..

2 Commits

Author SHA1 Message Date
06f7400e61 this is better 2025-09-15 14:58:36 +00:00
05950028a8 add interpreter_python var 2025-09-15 14:58:27 +00:00
2 changed files with 8 additions and 8 deletions

View File

@@ -2,3 +2,4 @@
inventory = inventory.yml
private_key_file = ~/.ssh/default-key
host_key_checking = False
interpreter_python = auto_silent

View File

@@ -14,13 +14,12 @@
prompt: "State of service"
private: no
tasks:
- name: Check if service exists
shell: systemctl list-units --type=service --all | grep -o "{{ service }}"
register: status
ignore_errors: true
- name: Change state of service
systemd:
- name: Gather service facts
ansible.builtin.service_facts:
- name: Manage service if present
ansible.builtin.systemd:
name: "{{ service }}"
enabled: "{{ enable }}"
enabled: "{{ enable | bool }}"
state: "{{ state }}"
when: status.stdout == "{{ service }}"
when: service in ansible_facts.services