我試圖在AWS Centos實例中創建glusterfs卷副本以創建角色。我成功創建卷並安裝glusterfs。我試圖使用這個topic建議在主機組的每臺機器上運行「gluster peer probe」。 我有劇本跑跑「glusterfs」的角色在主機組:如何在條件爲「when」的情況下使用Ansible主機組運行Glusterfs-cli命令「peer probe」
[Server]
devserver1.net ansible_user=ec2-user ansible_ssh_private_key_file=/some.pem
devserver2.net ansible_user=ec2-user ansible_ssh_private_key_file=/some.pem
我想要現在在角色運行「gluster同行探頭......」的時候,這個主機組的spesific主機中運行此任務。像這樣:
- name: gluster peer probe in server1
shell: gluster peer probe {{ stackName }}server2.net
when: "'{{ stackName }}server1.net' == {{ inventory_hostname }}"
- name: gluster peer probe in server2
shell: gluster peer probe {{ stackName }}server1.net
when: "'{{ stackName }}server2.net' == {{ inventory_hostname }}"
StackName是預定義的庫存「開發」變量的劇本。
它失敗,錯誤:
FAILED! => {"failed": true, "msg": "The conditional check '{{ stackName }} server1.net in inventory_hostname' failed. The error was: error while evaluating conditional ({{ stackName }}server1.net in inventory_hostname): 'server1' is undefined\n\nThe error appears to have been in 'ansible/roles/glusterfs/tasks/main.yml': line 69, 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: gluster peer probe from server1\n^here\n"}
任何暗示我可怎麼辦呢?或者我在這裏做錯了什麼?