Team,
Я пытаюсь l oop над пакетами со всех возвращенных хостов и удалить их.
, но получаю ошибку. не уверен, что мой l oop прав? вытаскиваю стручки с kubectl на узле.
вывод:
ok: [node0117d] => {
00:11:05 "kos_pod": {
00:11:05 "changed": true,
00:11:05 "cmd": "kubectl get pods -n kos-vdiskplugin --no-headers --field-selector spec.nodeName=node0117d | grep -E kos-vdiskplugin-'[[:alnum:]]{5}' -o -w",
00:11:05 "stdout": "kos-vdiskplugin-fps5b",
00:11:05 "stdout_lines": [
00:11:05 "kos-vdiskplugin-fps5b"
00:11:05 ]
00:11:05 }
00:11:05 }
00:11:05 ok: [node0118d] => {
00:11:05 "kos_pod": {
00:11:05 "changed": true,
00:11:05 "cmd": "kubectl get pods -n kos-vdiskplugin --no-headers --field-selector spec.nodeName=node0118d | grep -E kos-vdiskplugin-'[[:alnum:]]{5}' -o -w",
00:11:05 "stderr_lines": [],
00:11:05 "stdout": "kos-vdiskplugin-dz794",
00:11:05 "stdout_lines": [
00:11:05 "kos-vdiskplugin-dz794"
00:11:05 ]
00:11:05 }
00:11:05 }
задача:
- name: "fetch kos pod on node"
shell: "kubectl get pods -n kos-vdiskplugin --no-headers --field-selector spec.nodeName={{ inventory_hostname }} | grep -E kos-vdiskplugin-'[[:alnum:]]{5}' -o -w"
register: kos_pod
delegate_to: localhost
become: false
- debug:
var: kos_pod
- name: "Delete kos pod on node"
command: kubectl delete pod -n kos-vdiskplugin "{{ item }}"
delegate_to: localhost
become: false
with_items: "{{ kos_pod.stdout }}"`
ошибка вывода:
fatal: [node0117d -> localhost]: FAILED! => {"changed": true, "cmd": ["kubectl", "delete", "pod", "-n", "kos-vdiskplugin", "{stderr_lines:", "[],", "uchanged:", "True,", "uend:", "u2020-04-30 07:11:05.177457,", "failed:", "False,", "ustdout:", "ukos-vdiskplugin-fps5b,", "ucmd:", "ukubectl get pods -n kos-vdiskplugin --no-headers --field-selector spec.nodeName=node0117d | grep -E kos-vdiskplugin-'[[:alnum:]]{5}' -o -w,", "urc:", "0,", "ustart:", "u2020-04-30 07:11:04.319947,", "ustderr:", "u,", "udelta:", "u0:00:00.857510,", "stdout_lines:", "[ukos-vdiskplugin-fps5b]}"], "delta": "0:00:02.972829", "end": "2020-04-30 07:11:08.369804", "msg": "non-zero return code", "rc": 1, "start": "2020-04-30 07:11:05.396975", "stderr": "Error from server (NotFound): pods \"{stderr_lines:\" not found\nError from server (NotFound): pods \"[],\" not found\nError from server (NotFound): pods \"uchanged:\" not found\nError from server (NotFound): pods \"True,\" not found\nError from server (NotFound): pods \"uend:\" not found\nError from server (NotFound): pods \"u2020-04-30 07:11:05.177457,\" not found\nError from server (NotFound): pods \"failed:\" not found\nError from server (NotFound): pods \"False,\" not found\nError from server (NotFound): pods \"ustdout:\" not found\nError from server (NotFound): pods \"ukos-vdiskplugin-fps5b,\" not found\nError from server (NotFound): pods \"ucmd:\" not found\nError from server (NotFound): pods \"ukubectl get pods -n kos-vdiskplugin --no-headers --field-selector spec.nodeName=node0117d | grep -E kos-vdiskplugin-'[[:alnum:]]{5}' -o -w,\" not found\nError from server (NotFound): pods \"urc:\" not found\nError from server (NotFound): pods \"0,\" not found\nError from server (NotFound): pods \"ustart:\" not found\nError from server (NotFound): pods \"u2020-04-30 07:11:04.319947,\" not found\nError from server (NotFound): pods \"ustderr:\" not found\nError from server (NotFound): pods \"u,\" not found\nError from server (NotFound): pods \"udelta:\" not found\nError from server (NotFound): pods \"u0:00:00.857510,\" not found\nError from server (NotFound): pods \"stdout_lines:\" not found\nError from server (NotFound): pods \"[ukos-vdiskplugin-fps5b]}\" not found", "stderr_lines": ["Error from server (NotFound): pods \"{stderr_lines:\" not found", "Error from server (NotFound): pods \"[],\" not found", "Error from server (NotFound): pods \"uchanged:\" not found", "Error from server (NotFound): pods \"True,\" not found", "Error from server (NotFound): pods \"uend:\" not found", "Error from server (NotFound): pods \"u2020-04-30 07:11:05.177457,\" not found", "Error from server (NotFound): pods \"failed:\" not found", "Error from server (NotFound): pods \"False,\" not found", "Error from server (NotFound): pods \"ustdout:\" not found", "Error from server (NotFound): pods \"ukos-vdiskplugin-fps5b,\" not found", "Error from server (NotFound): pods \"ucmd:\" not found", "Error from server (NotFound): pods \"ukubectl get pods -n kos-vdiskplugin --no-headers --field-selector spec.nodeName=node0117d | grep -E kos-vdiskplugin-'[[:alnum:]]{5}' -o -w,\" not found", "Error from server (NotFound): pods \"urc:\" not found", "Error from server (NotFound): pods \"0,\" not found", "Error from server (NotFound): pods \"ustart:\" not found", "Error from server (NotFound): pods \"u2020-04-30 07:11:04.319947,\" not found", "Error from server (NotFound): pods \"ustderr:\" not found", "Error from server (NotFound): pods \"u,\" not found", "Error from server (NotFound): pods \"udelta:\" not found", "Error from server (NotFound): pods \"u0:00:00.857510,\" not found", "Error from server (NotFound): pods \"stdout_lines:\" not found", "Error from server (NotFound): pods \"[ukos-vdiskplugin-fps5b]}\" not found"], "stdout": "", "stdout_lines": []}