fixed kubectl_get_nodes_result.stdout error

os ubuntu  amd64 16.04 LTS
ansible 2.9.20
python version 2.7

```
 FAILED! => {"msg": "The conditional check 'item in kubectl_get_nodes_result.stdout' failed. The error was: error while evaluating conditional (item in kubectl_get_nodes_result.stdout): 'dict object' has no attribute 'stdout'\n\nThe error appears to be in '/home/rancher/.ansible/roles/xanmanning.k3s/tasks/teardown/drain-and-remove-nodes.yml': line 39, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: Ensure uninstalled nodes are removed\n      ^ here\n"}

```
This commit is contained in:
AnJia 2021-04-30 14:31:33 +08:00 committed by GitHub
parent 2432a7d25f
commit 91d456ccad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,7 @@
delegate_to: "{{ k3s_control_delegate }}"
run_once: true
when:
- kubectl_get_nodes_result.stdout is defined
- item in kubectl_get_nodes_result.stdout
- hostvars[item].k3s_state is defined
- hostvars[item].k3s_state == 'uninstalled'
@ -41,6 +42,7 @@
delegate_to: "{{ k3s_control_delegate }}"
run_once: true
when:
- kubectl_get_nodes_result.stdout is defined
- item in kubectl_get_nodes_result.stdout
- hostvars[item].k3s_state is defined
- hostvars[item].k3s_state == 'uninstalled'