Kiv*_*iva 32 ansible ansible-playbook
我在远程主机上生成带有ansible的文件,在这一代之后,我想在另一个任务中读取这些文件.
我找不到任何模块用ansible读取远程文件(查找似乎只在本地主机上).
你知道这样的模块吗?
谢谢
编辑:
这是我的用例:
我生成ssh密钥,然后将其添加到github.这些键是由var文件中的对象设置的,所以我像这样循环生成它:
tasks:
- name: Create ssh key
user:
name: "{{sshConfigFile.user}}"
generate_ssh_key: yes
ssh_key_file: ".ssh/{{item.value.file}}"
state: present
with_dict: "{{sshConfiguration}}"
Run Code Online (Sandbox Code Playgroud)
它工作得很好但是如何读取这些键通过API将其发送到github?
dan*_*y74 64
使用--diff标志运行(在目标文件更改时输出diff).
ansible-playbook --diff server.yaml
Run Code Online (Sandbox Code Playgroud)
或啜饮它..
- name: Slurp hosts file
slurp:
src: /etc/hosts
register: slurpfile
- debug: msg="{{ slurpfile['content'] | b64decode }}"
Run Code Online (Sandbox Code Playgroud)
hel*_*loV 14
正如您所说,所有查找都在localhost上.但是所有这些都可以通过使用shell和远程完成register.你能告诉你到底想要做什么吗?只是一个例子.
- shell: cat "{{remote_file}}"
register: data
- shell: ......
with_xxxx:
Run Code Online (Sandbox Code Playgroud)
小智 6
您可以尝试"获取"模块,该模块将密钥文件检索到目标路径localhost:
fetch:
src: ".ssh/{{item.value.file}}"
dest:"/tmp/ssh_keys/{{item.value.file}}"
flat: yes
with_dict: "{{sshConfiguration}}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38251 次 |
| 最近记录: |