Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Yonggie opened this issue Aug 21, 2023 · 7 comments
Assignees

Comments

@Yonggie
Copy link
Contributor

Yonggie commented Aug 21, 2023

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
@paulbaogang
Copy link
Contributor

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

@Yonggie
Copy link
Contributor Author

Yonggie commented Aug 22, 2023

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

@paulbaogang
Copy link
Contributor

安装个2.9.x版本的试下

@Yonggie
Copy link
Contributor Author

Yonggie commented Aug 23, 2023

安装个2.9.x版本的试下

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

@Yonggie
Copy link
Contributor Author

Yonggie commented Aug 23, 2023

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

@Yonggie
Copy link
Contributor Author

Yonggie commented Aug 23, 2023

群友给的方法是修改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
Copy link
Contributor Author

Yonggie commented Sep 27, 2023

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

目标机器参数:
图片

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants