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 inventory = inventory.yml
private_key_file = ~/.ssh/default-key private_key_file = ~/.ssh/default-key
host_key_checking = False host_key_checking = False
interpreter_python = auto_silent

View File

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