status-im / infra-role-nim-waku

Ansible role for Nim-Waku node configuration
https://github.com/status-im/nim-waku
3 stars 9 forks source link

"Extract the node key from file" fails if file was generated previously and not set by variable #15

Closed yakimant closed 1 year ago

yakimant commented 1 year ago

Exmplae:

ansible-playbook ansible/main.yml --limit boot-01.do-ams3.shards.test --tags "nim-waku" -i ansible/inventory/test -v
...
TASK [nim-waku : Generate random node key] ***********************************************************************
skipping: [boot-01.do-ams3.shards.test] => {
    "changed": false,
    "false_condition": "not key_file.stat.exists and nim_waku_node_key is not defined\n",
    "skip_reason": "Conditional result was False"
}

TASK [nim-waku : Save generate node key to file] *****************************************************************
skipping: [boot-01.do-ams3.shards.test] => {
    "changed": false,
    "false_condition": "not key_file.stat.exists",
    "skip_reason": "Conditional result was False"
}

TASK [nim-waku : Load existing node key from file] ***************************************************************
skipping: [boot-01.do-ams3.shards.test] => {
    "changed": false,
    "false_condition": "key_generation.skipped is not defined and nim_waku_node_key is not defined\n",
    "skip_reason": "Conditional result was False"
}

TASK [nim-waku : Extract the node key from file] *****************************************************************
fatal: [boot-01.do-ams3.shards.test]: FAILED! => {}

MSG:

The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'content'. 'dict object' has no attribute 'content'

The error appears to be in '/Users/status/.ansible/roles/nim-waku/tasks/nodekey.yml': line 39, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Extract the node key from file
  ^ here

Load is skipped wrongly, because generation is skipped. Maybe it should be the opposite? If generation is skipped - load from file.

https://github.com/status-im/infra-role-nim-waku/blob/75fa7e483cacccb482c99afddc7de3c25fb8a1fc/tasks/nodekey.yml#L31-L37

yakimant commented 1 year ago

If file didn't exist it also fails:

fatal: [store-01.ac-cn-hongkong-c.shards.test]: FAILED! => {}

MSG:

The conditional check 'key_generation.skipped and nim_waku_node_key is not defined
' failed. The error was: error while evaluating conditional (key_generation.skipped and nim_waku_node_key is not defined
): 'dict object' has no attribute 'skipped'. 'dict object' has no attribute 'skipped'

The error appears to be in '/Users/status/work/infra-role-nim-waku/tasks/nodekey.yml': line 39, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

- name: Extract the node key from file
  ^ here