可以通过变量声明主机

问题描述 投票:1回答:1

所以我正在运行一个Ansible剧本,该剧本创建了一个服务器(使用terraform),并给出了将服务器的ip地址保存到变量中的信息。我想在给定的IP地址上执行另一个任务。如何声明新主机?

我尝试过:

- hosts: "{{ remotehost }}" tasks: - name: test lineinfile: path: /etc/environment line: test1234

我使用ansible-playbook variable.yaml --extra-vars='playbook=ip-address'运行剧本

ansible ansible-inventory
1个回答
0
投票
例如:

tasks: - name: another host execute command: ls -ltr delegate_to: "{{ remotehost }}"

服务器应具有与新主机一起使用的ssh连接

© www.soinside.com 2019 - 2024. All rights reserved.