Browse Source

fix "'dict object' has no attribute 'ActiveState'" when unit is not active

Fabian Peter Hammerle 2 years ago
parent
commit
5c446f1f73
1 changed files with 4 additions and 1 deletions
  1. 4 1
      tasks/main.yml

+ 4 - 1
tasks/main.yml

@@ -20,10 +20,13 @@
       {{ "restarted" if (systemd_unit_state is not defined
                             or systemd_unit_state != "stopped")
                          and _config_file.changed
+                         and 'ActiveState' in _unit.status
                          and _unit.status.ActiveState == "active"
          else systemd_unit_state | default(omit) }}
   when: >-
     _config_file.changed
     or systemd_unit_enabled is defined
     or systemd_unit_state is defined
-    or (_config_file.changed and systemd_unit.status.ActiveState == "active")
+    or (_config_file.changed
+        and 'ActiveState' in _unit.status
+        and systemd_unit.status.ActiveState == "active")