I am doing this task

- name: Register evercam-media local commit hash
  local_action:
    shell
    chdir={{local_media_dir}}
    git log --pretty='{"sha":"%h", "author_name":"%an", 
"author_name":"%ae", "unix_timestamp":"%at", "subject":"%s", "branch":"%d"}' 
| head -1
  register: local_commit_info


- set_fact:
    commit: "{{ local_commit_info.stdout }}"


which creates such as

changed: [media.evercam.io -> localhost] => {
    "changed": true, 
    "cmd": "git log --pretty='{\"sha\":\"%h\", \"author_name\":\"%an\", 
\"author_name\":\"%ae\", \"unix_timestamp\":\"%at\", \"subject\":\"%s\", 
\"branch\":\"%d\"}' | head -1", 
    "delta": "0:00:00.005962", 
    "end": "2019-12-11 19:24:54.788804", 
    "invocation": {
        "module_args": {
            "_raw_params": "git log --pretty='{\"sha\":\"%h\", 
\"author_name\":\"%an\", \"author_name\":\"%ae\", 
\"unix_timestamp\":\"%at\", \"subject\":\"%s\", \"branch\":\"%d\"}' | head 
-1", 
            "_uses_shell": true, 
            "argv": null, 
            "chdir": "/home/junaid/evercam/evercam-server", 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "stdin_add_newline": true, 
            "strip_empty_ends": true, 
            "warn": true
        }
    }, 
    "rc": 0, 
    "start": "2019-12-11 19:24:54.782842", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "{\"sha\":\"aca4ef2\", \"author_name\":\"Junaid Farooq\", 
\"author_name\":\"[email protected]\", \"unix_timestamp\":\"1576042588\", 
\"subject\":\"Merge pull request #1240 from evercam/delete_timelapse\", 
\"branch\":\" (HEAD -> master, origin/master, origin/HEAD)\"}", 
    "stdout_lines": [
        "{\"sha\":\"aca4ef2\", \"author_name\":\"Junaid Farooq\", 
\"author_name\":\"[email protected]\", \"unix_timestamp\":\"1576042588\", 
\"subject\":\"Merge pull request #1240 from evercam/delete_timelapse\", 
\"branch\":\" (HEAD -> master, origin/master, origin/HEAD)\"}"
    ]
}
Read vars_file 'common-vars.yml'
Read vars_file 'media-vars.yml'
Read vars_file '../private_vars_media.yml'


TASK [media : set_fact] 
*******************************************************************************************************************************************************************************************
task path: /home/junaid/evercam/evercam-devops/ansible/media/tasks/hotcode.
yml:8
ok: [media.evercam.io] => {
    "ansible_facts": {
        "commit": {
            "author_name": "[email protected]", 
            "branch": " (HEAD -> master, origin/master, origin/HEAD)", 
            "sha": "aca4ef2", 
            "subject": "Merge pull request #1240 from 
evercam/delete_timelapse", 
            "unix_timestamp": "1576042588"
        }
    }, 
    "changed": false
}
All I want to do is to send the commit to a URL as a post request.

I am doing this way

- uri: 
    url: "http://www.myapi.com/create";
    method: POST
    return_content: yes
    body_format: json
    HEADER_Content-Type: "application/json"
    body: "{{ commit }}"

But I am getting error such as

fatal: [media.evercam.io]: FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "HEADER_Content-Type": "application/json", 
            "body": {
                "author_name": "[email protected]", 
                "branch": " (HEAD -> master, origin/master, origin/HEAD)", 
                "sha": "aca4ef2", 
                "subject": "Merge pull request #1240 from 
evercam/delete_timelapse", 
                "unix_timestamp": "1576042588"
            }, 
            "body_format": "json", 
            "method": "POST", 
            "return_content": true, 
            "url": "http://www.myapi.com/create";
        }
    }, 
    "msg": "Unsupported parameters for (uri) module: HEADER_Content-Type 
Supported parameters include: attributes, backup, body, body_format, 
client_cert, client_key, content, creates, delimiter, dest, directory_mode, 
follow, follow_redirects, force, force_basic_auth, group, headers, 
http_agent, method, mode, owner, regexp, remote_src, removes, 
return_content, selevel, serole, setype, seuser, src, status_code, timeout, 
unix_socket, unsafe_writes, url, url_password, url_username, use_proxy, 
validate_certs"
}



Can you point where I am wrong? I also tried Just using curl which didn't 
work as well?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/19253269-f7e9-48f3-835d-d24ca73a2218%40googlegroups.com.

Reply via email to