FATE icon indicating copy to clipboard operation
FATE copied to clipboard

AnsibleFATE离线部署出现AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined.

Open Yonggie opened this issue 1 year ago • 7 comments

Describe the bug官方网站下载的离线部署包,是1.11.2的最新版。通过文档前置操作部署三方文档,进行操作。

在deploy时,会出现ansible.errors.AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined.,导致部署失败。

详细日志:

PLAY [fate] ********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [192.168.1.182]
ok: [192.168.1.183]
ok: [192.168.1.177]

TASK [check : Warning(deploy):] ************************************************
skipping: [192.168.1.177]
skipping: [192.168.1.183]
skipping: [192.168.1.182]

TASK [check : mkdir(deploy): base dir] *****************************************
ok: [192.168.1.177]
ok: [192.168.1.183]
ok: [192.168.1.182]

TASK [check : mkdir(deploy): tools dir] ****************************************
ok: [192.168.1.177]
ok: [192.168.1.183]
ok: [192.168.1.182]

TASK [check : untar(deploy): deploy.tar.gz] ************************************
ok: [192.168.1.182]
ok: [192.168.1.183]
ok: [192.168.1.177]

TASK [check : update(deploy): check.sh] ****************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined. 'ansible_ssh_host' is undefined
fatal: [192.168.1.177]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined. 'ansible_ssh_host' is undefined"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined. 'ansible_ssh_host' is undefined
fatal: [192.168.1.183]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined. 'ansible_ssh_host' is undefined"}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined. 'ansible_ssh_host' is undefined
fatal: [192.168.1.182]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'ansible_ssh_host' is undefined. 'ansible_ssh_host' is undefined"}

NO MORE HOSTS LEFT *************************************************************

PLAY RECAP *********************************************************************
192.168.1.177              : ok=4    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0   
192.168.1.182              : ok=4    changed=0    unreachable=0    failed=1    skipped=1    rescued=0    ignored=0   
192.168.1.183              : ok=4    changed=0    unreachable=0    failed=1    skipped=1    rescued=0 

Desktop (please complete the following information):

  • OS: CentOS

Yonggie avatar Aug 21 '23 09:08 Yonggie

ansible版本是多少?低会有问题,需要2.9.x

paulbaogang avatar Aug 22 '23 07:08 paulbaogang

ansible版本是多少?低会有问题,需要2.9.x

你好,使用的是2.15.2

ansible --version
ansible [core 2.15.2]
  config file = /root/Downloads/AnsibleFATE_1.11.2_release_offline/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/anaconda3/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /root/anaconda3/bin/ansible
  python version = 3.9.13 (main, Aug 25 2022, 23:26:10) [GCC 11.2.0] (/root/anaconda3/bin/python)
  jinja version = 3.1.2
  libyaml = True

Yonggie avatar Aug 22 '23 07:08 Yonggie

安装个2.9.x版本的试下

paulbaogang avatar Aug 22 '23 08:08 paulbaogang

安装个2.9.x版本的试下

不好意思,core=2.15.2是不是已经比2.9高了?

Yonggie avatar Aug 23 '23 01:08 Yonggie

你好,在社区群里多人都遇到了这个问题,并非个例。 363584a4c104240e440b36238e2e306

Yonggie avatar Aug 23 '23 01:08 Yonggie

群友给的方法是修改project_path/enviroments/prod/hosts中的[fate]组:

render后原文:

# 前面省略
ansible_become_method=sudo
ansible_become_user=root
ansible_become_pass=
[deploy_check]
[fate]
192.168.1.177 
192.168.1.183
192.168.1.182

手动加入 ansible ssh host变量,改成

ansible_become_method=sudo
ansible_become_user=root
ansible_become_pass=
[deploy_check]
[fate]
192.168.1.177 ansible_ssh_host=192.168.1.177
192.168.1.183 ansible_ssh_host=192.168.1.183
192.168.1.182 ansible_ssh_host=192.168.1.182

是不是官方要检查下render是否漏了什么?或者是教程有问题,要再加点东西?

Yonggie avatar Aug 23 '23 02:08 Yonggie

你好,使用了2.9.x的ansible,会有如下报错: ansible的日志: 图片

目标机器参数: 图片

Yonggie avatar Sep 27 '23 06:09 Yonggie