I tried to find a way to print both an API request and response to a log file. But Ansible URI module does not provide the request data.
Does anyone know any mechanism to print the request and response to file in Ansible?
example:
name: update cms
uri:
url: '{{ cms_api.msg }}'
method: POST
body_format: json
body:
api_password: "{{ api_password }}"
name: "{{ item.Name }}"
ip_address: "{{ item.IPAddress }}"
subnet_mask: "{{ item.SubnetMask }}"
router: "{{ item.Router }}"
ip_range: "{{ item.IPAddresses }}"
options: "{{ item.Options }}"
pool_name: "{{ item.PoolName}}"
validate_certs: no
return_content: yes
register: dhcp_subnet_response
loop: "{{ ip_addrs_1.list }}"
delegate_to: localhost
I need to print above request and response both to a file. Since this api calling as a loop, I need to print request|response both for each request.