我试图获取工作节点的IP地址和主机名并将其写入主/根/主机文件。收到错误,失败!=> {"msg": "'dict object' 没有属性 'stdout'"}
- name: set glusterfs device in hostfile
shell: echo "{{ name }} glusterfs_devices='[ "/dev/abcd" ]'"
register: opt_gluster
when: type == "worker"
- name: add glusterfs
lineinfile:
dest: /root/hosts
line: "{{item}}"
insertafter: EOF
with_items:
- "{{ opt_gluster.stdout }}"
when: type == "master"
{"msg": "'dict object' has no attribute 'stdout'"}
我认为问题出在 when 语句
- name: add glusterfs
lineinfile:
dest: /root/hosts
line: "{{item}}"
insertafter: EOF
with_items:
- "{{ opt_gluster.stdout }}"
when: type == "master"
我认为它缺少一个
when: type == "master" and opt_gluster.stdout is defined
因为当你在一个节点上时,谁不会成为worker
opt_gluster不会有一个标准输出,因为它正在跳过。
此致敬意