我有一个 local_action,我想将其分成多行。
- name: Find geographical region of this server
local_action: uri url=http://locator/studio/{{ ansible_default_ipv4.address}} method=GET return_content=yes register=locator_output
答案1
该任务使用 定义shorthand syntax
。使用常规语法和delegate_to
参数可以实现相同的结果,如下所示:
- name: Find geographical region of this server
uri:
url: http://locator/studio/{{ ansible_default_ipv4.address}}
method: GET
return_content: yes
register: locator_output
delegate_to: localhost
答案2
解决方案是使用module
带有原始动作名称的参数:
- name: Find geographical region of this server
local_action:
module: uri
url: http://locator/studio/{{ ansible_default_ipv4.address}}
method: GET
return_content: yes
register: locator_output