我有一些我管理的旧设备,它正在运行VXWorks。我能够对它进行ssh操作并运行命令,但是命令和/或提示是不标准的。我想使用ansible来自动化我所做的一些任务。我不知道该使用哪个模块。
发布于 2020-12-19 02:10:07
是否有一种方法只需将ssh放入一个盒子中,并开始使用Ansible运行命令呢?
这就是Ansible的raw模块的目的:它是ssh <somehost> <somecommand>的最小包装器。
有办法通过scp/sftp下载文件吗?
如果远程系统支持scp或sftp,则可以在本地系统上运行适当的scp/sftp命令。例如,
- hosts: localhost
tasks:
- name: copy a file from the remote system
command: scp myserver:somefile.txt .我怎么才能得到原始输出。我运行的命令通常显示命令,我需要看到这些命令的输出。
在播放簿中运行命令时,可以对结果进行register,对于raw,注册变量的任务将具有包含命令输出的stdout和stderr属性。例如:
- hosts: myserver
gather_facts: false
tasks:
- name: demonstrate the raw module
raw: date
register: date
- debug:
var: date.stdout该剧本的产出将包括:
TASK [demonstrate the raw module] ************************************************************************************************************************************************************
changed: [myserver]
TASK [debug] *********************************************************************************************************************************************************************************
ok: [myserver] => {
"date.stdout": "Fri Dec 18 09:09:34 PM EST 2020\r\n"
}gather_facts: false部件非常重要,因为这样可以防止Ansible试图在目标主机上隐式运行setup模块。
https://stackoverflow.com/questions/65365240
复制相似问题