curl playbook

1,089 views
Skip to first unread message

GBANE FETIGUE

unread,
Jul 21, 2016, 4:44:38 PM7/21/16
to Ansible Project
Hi guys,
I am running an ansible playbook that supposed to return an apllication ID that I am having some issue; here the playbook

- action: shell curl --basic -u admin:admin -F file=/etc/ansible/playbooks/ms3-samples.zip -F name=ms3-samples -F version=2.0 --header "Content-Type:multipart/form-data" "http://52.73.56.141:8080/mmc-console-3.6.2/api/repository"
  register: upload
- debug: var=upload

After running here is the result:

PLAY [mmc] *********************************************************************

TASK [setup] *******************************************************************
ok: [ip-172-31-61-191.ec2.internal]



#- name: post to cons
TASK [command] *****************************************************************


changed: [ip-172-31-61-191.ec2.internal]
 [WARNING]: Consider using get_url or uri module rather than running curl


TASK [debug] *******************************************************************
ok: [ip-172-31-61-191.ec2.internal] => {
    "upload": {
        "changed": true,
        "cmd": "curl --basic -u admin:admin -F file=/etc/ansible/playbooks/@ms3-samples.zip -F name=ms3-samples -F version=2.0 --header \"Content-Type:multipart/form-data\" \"http://52.73.56.141:8080/mmc-console-3.6.2/api/repository\"",
        "delta": "0:00:00.088039",
        "end": "2016-07-21 20:38:47.715591",
        "rc": 0,
        "start": "2016-07-21 20:38:47.627552",
        "stderr": "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r100   411    0    30  100   381    362   4601 --:--:-- --:--:-- --:--:--  4646",
        "stdout": "Specify a valid file to upload",
        "stdout_lines": [
            "Specify a valid file to upload"
        ],
        "warnings": [
            "Consider using get_url or uri module rather than running curl"
        ]
    }
}

PLAY RECAP *********************************************************************
ip-172-31-61-191.ec2.internal : ok=3    changed=1    unreachable=0    failed=0

It's telling me that Specify a valid file to upload" I don't know why the file is ms3-sample.zip. any ideas.

Kai Stian Olstad

unread,
Jul 22, 2016, 2:21:14 AM7/22/16
to ansible...@googlegroups.com
On 21.07.2016 22:44, GBANE FETIGUE wrote:
> - action: shell curl --basic -u admin:admin -F
> file=/etc/ansible/playbooks/ms3-samples.zip -F name=ms3-samples -F
> version=2.0 --header "Content-Type:multipart/form-data"
> "http://52.73.56.141:8080/mmc-console-3.6.2/api/repository"
> register: upload
> - debug: var=upload

This task will run on the host and not the control machine.


> After running here is the result:
>
So in your case the file need to be on the host
ip-172-31-61-191.ec2.internal, I'm guessing that's not the case and the
file is on you control machine.


> It's telling me that Specify a valid file to upload" I don't know why
> the
> file is ms3-sample.zip. any ideas.

If the file is on the control machine you'll need to run the task on the
localhost,
two ways to achieve that depending on the coding style you like.

- local_action: shell curl --basic -u admin:admin -F
file=/etc/ansible/playbooks/ms3-samples.zip -F name=ms3-samples -F
version=2.0 --header "Content-Type:multipart/form-data"
"http://52.73.56.141:8080/mmc-console-3.6.2/api/repository"
register: upload

or

- shell: curl --basic -u admin:admin -F
file=/etc/ansible/playbooks/ms3-samples.zip -F name=ms3-samples -F
version=2.0 --header "Content-Type:multipart/form-data"
"http://52.73.56.141:8080/mmc-console-3.6.2/api/repository"
register: upload
delegate_to: localhost

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages