我试图开始使用ansible,而我当前的项目正在部署一个Graylog集群。我在AWS中运营,需要处理动态库存。我想我错过了我的playbooks和获得组变量中定义的变量的动态实例之间的链接。
这是我的目录结构。 https://pastebin.com/cuNH4bzX
这是我的tag_Application_graylog文件https://pastebin.com/Vw0cbnZq
当我在播放目录中时,我能够使用该标记连接到实例。
ubuntu@ip-10-128-0-86:~/deployments/plays$ ansible -m ping tag_Application_graylog
ec2_justin_graylog01_dev | SUCCESS => {
"changed": false,
"failed": false,
"ping": "pong"
}
ec2_justin_graylog02_dev | SUCCESS => {
"changed": false,
"failed": false,
"ping": "pong"
}
当我尝试运行游戏时,我收到以下错误。
TASK [elastic.elasticsearch : os-specific vars] *******************************************************************************************************************************************************************
task path: /home/ubuntu/deployments/roles/elastic.elasticsearch/tasks/main.yml:2
ok: [ec2_justin_graylog01_dev] => {"ansible_facts": {"default_file": "/etc/default/elasticsearch", "es_home": "/usr/share/elasticsearch", "java": "{% if es_java is defined %}{{es_java}}{% else %}openjdk-8-jre-headless{% endif %}"}, "ansible_included_var_files": ["/home/ubuntu/deployments/roles/elastic.elasticsearch/vars/Debian.yml"], "changed": false, "failed": false}
ok: [ec2_justin_graylog02_dev] => {"ansible_facts": {"default_file": "/etc/default/elasticsearch", "es_home": "/usr/share/elasticsearch", "java": "{% if es_java is defined %}{{es_java}}{% else %}openjdk-8-jre-headless{% endif %}"}, "ansible_included_var_files": ["/home/ubuntu/deployments/roles/elastic.elasticsearch/vars/Debian.yml"], "changed": false, "failed": false}
TASK [elastic.elasticsearch : fail] *******************************************************************************************************************************************************************************
task path: /home/ubuntu/deployments/roles/elastic.elasticsearch/tasks/elasticsearch-parameters.yml:3
fatal: [ec2_justin_graylog01_dev]: FAILED! => {"changed": false, "failed": true, "msg": "es_instance_name must be specified and cannot be blank"}
fatal: [ec2_justin_graylog02_dev]: FAILED! => {"changed": false, "failed": true, "msg": "es_instance_name must be specified and cannot be blank"}
to retry, use: --limit @/home/ubuntu/deployments/plays/graylog.retry
PLAY RECAP ********************************************************************************************************************************************************************************************************
ec2_justin_graylog01_dev : ok=6 changed=0 unreachable=0 failed=1
ec2_justin_graylog02_dev : ok=6 changed=0 unreachable=0 failed=1
因为' es_instance_name'在我的小组变量中定义,我认为他们没有被读入。
我用来从play文件夹中运行playbook的命令。
ansible-playbook -vv graylog.yml
命令的完整输出。 https://pastebin.com/NxNFVbBG
graylog.yml的内容https://pastebin.com/Liq8qCDi
任何帮助都会很棒。
答案 0 :(得分:0)
发现了这个问题。
https://github.com/ansible/ansible/issues/16878
基本上,group_vars需要是该游戏的相邻文件夹。所以我需要将我的游戏提升到一个级别,或者将组var文件夹降低到一个级别。
根据发布的最佳做法,我将我的游戏提升了一个级别。
https://docs.ansible.com/ansible/latest/playbooks_best_practices.html#content-organization