4

I have a local_action the I would like to split in multiple lines.

  - 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
Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83

2 Answers2

9

The task is defined using shorthand syntax. The same result could be achieved by using the regular syntax and delegate_to parameter, like this:

- 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
Henrik Pingel
  • 9,380
  • 2
  • 28
  • 39
3

The solution is to use module parameter with the original action name:

  - 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
Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83