fanuelsen / ansible

10 stars 5 forks source link

[Wait for update to finish.] 'dict object' has no attribute 'json' #1

Closed ITfromHell closed 1 year ago

ITfromHell commented 1 year ago

Hi, thanks for sharing your TrueNAS Update play. I gave it a try and its doing the update from 22.12.0 to 22.12.1 and the reboot. But when waiting for the reboot, there comes an error up:

TASK [Checks if there is an update available from update server.] ***************************************************************************************************************
ok: [localhost]

TASK [Downloads (if not already in cache) and apply an update.] *****************************************************************************************************************
ok: [localhost]

TASK [Wait for update to finish.] ***********************************************************************************************************************************************
FAILED - RETRYING: Wait for update to finish. (20 retries left).
FAILED - RETRYING: Wait for update to finish. (19 retries left).
FAILED - RETRYING: Wait for update to finish. (18 retries left).
FAILED - RETRYING: Wait for update to finish. (17 retries left).
**fatal: [localhost]: FAILED! => {"msg": "The conditional check 'truenas_reboot_required.json.status == 'REBOOT_REQUIRED'' failed. The error was: error while evaluating conditional (truenas_reboot_required.json.status == 'REBOOT_REQUIRED'): 'dict object' has no attribute 'json'"}**

PLAY RECAP **********************************************************************************************************************************************************************
localhost                  : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  

My assumption would be: its rebooting automatically an then there is no json result anymore, which thows an error at the check

I checked out this and found a hint to solve this there: https://github.com/ansible/ansible/issues/54561#issuecomment-477775545

Its bringing in a default value, when to original isnt available, so because of this, at "Wait for update to finish."

- until: "truenas_reboot_required.json.status == 'REBOOT_REQUIRED'"
+  until: (truenas_reboot_required.json|default(dict(status=WAITING))).status == 'REBOOT_REQUIRED'

Because my update was done already, could you validate my suggest at your environment?

fanuelsen commented 1 year ago

From your versioning it seems that you run Truenas Scale? If so i have not tested this with scale, i built this for Truenas Core. That may throw some errors. We could probably make it work on both versions. I'm running scale in my homelab, so i can do some testing there.

ITfromHell commented 1 year ago

yes, sorry to say, its TrueNAS Scale

fanuelsen commented 1 year ago

We are probably gonna implement TrueNAS Scale in our production environment so it would be beneficial for us to make this work seamlessly on both versions.

fanuelsen commented 1 year ago

Did you upgrade from Angelfish to Bluefin?

I deployed a virtual truenas scale angelfish and updated it to bluefin and it worked without any modifications.

`PLAY [localhost] *** 10:26:40

TASK [update-truenas-api] ** 10:26:40

included: /tmp/awx_7559_hcgwnu9l/project/task.yml for localhost

TASK [Checks if there is an update available from update server.] ** 10:26:40

ok: [localhost]

TASK [Downloads (if not already in cache) and apply an update.] **** 10:26:44 ok: [localhost] TASK [Wait for update to finish.] ** 10:26:45

FAILED - RETRYING: Wait for update to finish. (30 retries left). FAILED - RETRYING: Wait for update to finish. (29 retries left). FAILED - RETRYING: Wait for update to finish. (28 retries left). FAILED - RETRYING: Wait for update to finish. (27 retries left). FAILED - RETRYING: Wait for update to finish. (26 retries left). ok: [localhost]

TASK [Reboot host] ***** 10:29:30

ok: [localhost]

TASK [Returns whether the system completed boot and is ready to use.] ** 10:29:31

FAILED - RETRYING: Returns whether the system completed boot and is ready to use. (30 retries left). FAILED - RETRYING: Returns whether the system completed boot and is ready to use. (29 retries left).

ok: [localhost]

PLAY RECAP ***** 10:30:48

localhost : ok=6 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 `

ITfromHell commented 1 year ago

I updated from Bluefin 22.12.0 to Bluefin 22.12.1

fanuelsen commented 1 year ago

Do you know where i can download an earlier version of bluefin i can try with?

ITfromHell commented 1 year ago

I investigated this link: https://download.truenas.com/TrueNAS-SCALE-Bluefin/22.12.0/TrueNAS-SCALE-22.12.0.iso You can browse thru the version here: https://download.truenas.com/

I see at your output, you are doing this via AWX? I just used a "normal" Ansible v2.10.17 installation

fanuelsen commented 1 year ago

I managed to reproduce your error code when using bluefin 22.12.0 and updating to 22.12.1. When i used the code you supplied it worked! Thanks for bringing this to my attention. I also tested that it still worked on TrueNAS Core.