versions
ansible version: 2.10.4
system version: CentOS7.9
kernel version: 3.10.0-1160.11.1.el7.x86_64
bug errorswhen I use the ansible-playbook ,the yml file is below:- name: List images
shell: ls /tmp/images
register: lists
-
name: show lists
debug:
var: lists.stdout_lines -
name: Load docker images
shell:
chdir: /tmp/images
cmd: docker load -i {{ item }}
with_items: “{{ lists.stdout_lines }}”
run command is : ansible-playbook -i hosts cluster.yml
until the loadimage.yml step have error
PLAY [nodes] **************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************
ok: [k8s003]
ok: [k8s001]
ok: [k8s002]
TASK [kubeadm : Copy rpm] *************************************************************************************************************************
ok: [k8s002]
ok: [k8s001]
ok: [k8s003]
TASK [kubeadm : Copy images] **********************************************************************************************************************
ok: [k8s002]
ok: [k8s001]
ok: [k8s003]
TASK [kubeadm : Copy k8sconf] *********************************************************************************************************************
ok: [k8s002]
ok: [k8s003]
ok: [k8s001]
TASK [kubeadm : Copy ipvs modules] ****************************************************************************************************************
ok: [k8s001]
ok: [k8s003]
ok: [k8s002]
TASK [kubeadm : Install rpm] **********************************************************************************************************************
changed: [k8s002]
changed: [k8s003]
changed: [k8s001]
TASK [kubeadm : Start kubelet.service] ************************************************************************************************************
ok: [k8s002]
ok: [k8s001]
ok: [k8s003]
TASK [kubeadm : modeprobe netfilter] **************************************************************************************************************
changed: [k8s002]
changed: [k8s001]
changed: [k8s003]
TASK [kubeadm : Load ipvs nodules] ****************************************************************************************************************
changed: [k8s002]
changed: [k8s001]
changed: [k8s003]
TASK [kubeadm : List images] **********************************************************************************************************************
changed: [k8s002]
changed: [k8s003]
changed: [k8s001]
TASK [kubeadm : show lists] ***********************************************************************************************************************
ok: [k8s001] => {
“lists.stdout_lines”: [
“coredns_1.7.0.tar”,
“etcd_3.4.13-0.tar”,
“kube-apiserver_v1.19.6.tar”,
“kube-controller-manager_v1.19.6.tar”,
“kube-proxy_v1.19.6.tar”,
“kube-scheduler_v1.19.6.tar”,
“pause_3.2.tar”
]
}
ok: [k8s002] => {
“lists.stdout_lines”: [
“coredns_1.7.0.tar”,
“etcd_3.4.13-0.tar”,
“kube-apiserver_v1.19.6.tar”,
“kube-controller-manager_v1.19.6.tar”,
“kube-proxy_v1.19.6.tar”,
“kube-scheduler_v1.19.6.tar”,
“pause_3.2.tar”
]
}
ok: [k8s003] => {
“lists.stdout_lines”: [
“coredns_1.7.0.tar”,
“etcd_3.4.13-0.tar”,
“kube-apiserver_v1.19.6.tar”,
“kube-controller-manager_v1.19.6.tar”,
“kube-proxy_v1.19.6.tar”,
“kube-scheduler_v1.19.6.tar”,
“pause_3.2.tar”
]
}
TASK [kubeadm : Load docker images] ***************************************************************************************************************
fatal: [k8s001]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/mnt/d/automation/kubegis/roles/kubeadm/tasks/loadimage.yml’: line 10, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Load docker images\n ^ here\n”}
fatal: [k8s002]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/mnt/d/automation/kubegis/roles/kubeadm/tasks/loadimage.yml’: line 10, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Load docker images\n ^ here\n”}
fatal: [k8s003]: FAILED! => {“msg”: “The task includes an option with an undefined variable. The error was: ‘item’ is undefined\n\nThe error appears to be in ‘/mnt/d/automation/kubegis/roles/kubeadm/tasks/loadimage.yml’: line 10, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Load docker images\n ^ here\n”}
PLAY RECAP ****************************************************************************************************************************************
k8s001 : ok=11 changed=4 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
k8s002 : ok=11 changed=4 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
k8s003 : ok=11 changed=4 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
help
please help me ? how to write right ?