如何在多行中拆分 ansible local_action

Mir*_*ici 4 ansible ansible-playbook

我有一个 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
Run Code Online (Sandbox Code Playgroud)

Hen*_*gel 9

任务是使用 定义的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
Run Code Online (Sandbox Code Playgroud)