[ansible-project] how to wait for a windows machine to come up after rebooting?

2016-04-15 Thread Sharwari Phadnis
I am trying to reboot a windows machine and I want to wait for it come up. 
I tried the following playbook:

---
- hosts: windows
  tasks: 
 - name: Reboot windows
   raw: shutdown /r /f 

 - name: ping windows machine until it comes up
   action: win_ping
   register: result
   until: result.rc == 0
   retries: 30
   delay: 20
 
But, it is not working somehow. Is there any other way I can reboot the 
windows 10 machine and wait for it come up ?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/821e0104-2dc6-4691-bc1f-f2438ab40ec0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Run .exe on windows command prompt

2016-04-08 Thread Sharwari Phadnis
Did you find any solution for this? If you've please help, I'm facing the 
same issue.

On Tuesday, January 19, 2016 at 3:54:37 PM UTC+5:30, Balaji Chandrababu 
wrote:
>
> Hi Dimitri,
>
> I'm trying to do pretty much the same with our own installer.
>
> This is what i have got in the playbook.
>
> Example:
> - name: Install ZoneSense and Niva latest version
>   raw: 'C:\Temp\ZoneSense 16.0.0.343.exe /S'
>
> I tried other options as well: raw: '"C:\Temp\ZoneSense 16.0.0.343.exe" 
> /S' and raw: "C:\\Temp\\ZoneSense 16.0.0.343.exe /S"
>
> But none of them seems to work. It fails with the following error:
>
>
> fatal: [uk-lon01-cs08.mirriad.corp]: FAILED! => {"changed": false, 
> "failed": true, "invocation": {"module_args": {"_raw_params": 
> "\"C:TempZoneSense 16.0.0.343.exe\" /S"}, "module_name": "raw"}, 
> "rc": 1, "stderr": "#< CLIXML\r\n http://schemas.microsoft.com/powershell/2004/04\";>At 
> line:1 char:39_x000D__x000A_+ \"C:TempZoneSense 
> 16.0.0.343.exe\" /S_x000D__x000A_+   
> ~_x000D__x000A_You must provide a value 
> expression following the '/' operator._x000D__x000A_At 
> line:1 char:39_x000D__x000A_+ \"C:TempZoneSense 
> 16.0.0.343.exe\" /S_x000D__x000A_+   
> ~_x000D__x000A_Unexpected token 'S' in 
> expression or statement._x000D__x000A_+ CategoryInfo 
>  : ParserError: (:) [], 
> ParentContainsErrorRecordException_x000D__x000A_+ 
> FullyQualifiedErrorId : ExpectedValueExpression_x000D__x000A_ S=\"Error\"> _x000D__x000A_", "stdout": "", "stdout_lines": []}
>
> Please let me know how to workaround this.
>
> Thanks,
> Balaji
>
> On Monday, 28 September 2015 20:57:34 UTC+1, Dimitri Yioulos wrote:
>>
>> Try the raw command without any quotes, as in raw: 
>> D:\builds\router\bin\wrapper.exe.  The following worked for me, and 
>> installed vlc on a test win2k8 box:
>>
>> ---
>>
>> - hosts: all
>>   gather_facts: false
>>
>>   tasks:
>> - name: installing app ...
>>   raw: c:\temp\vlc-2.2.1-win32.exe /S
>>
>> On Monday, September 28, 2015 at 8:32:49 AM UTC-4, Jugal Porwal wrote:
>>>
>>> Hi,
>>>
>>> I want to run a .exe on windows command prompt from my centos control 
>>> node. The command is as follows :
>>>
>>> wrapper.exe  -t wrapper.conf
>>>
>>> Initially i tried to atleast run the .exe without any args using my 
>>> following playbook :
>>>
>>> ---
>>> - hosts: windows
>>>   tasks:
>>> - name: Register as a service
>>>   raw: 'D:\builds\router\bin\wrapper.exe'
>>>
>>>
>>>
>>> But i got the following error:
>>>
>>> fatal: [192.168.199.94]: FAILED! => {"changed": false, "failed": true, 
>>> "rc": 1, "stderr": "#< CLIXML\r\n>> http://schemas.microsoft.com/powershell/2004/04\";>>> S=\"Error\">D:_x0008_uilds : The term 'D:_x0008_uilds' is not recognized as 
>>> the name of a cmdlet, _x000D__x000A_function, script 
>>> file, or operable program. Check the spelling of the name, or 
>>> _x000D__x000A_if a path was included, verify that the 
>>> path is correct and try again._x000D__x000A_At line:1 
>>> char:1_x000D__x000A_+ D:_x0008_uilds_x000D__x000A_>> S=\"Error\">+ _x000D__x000A_+ 
>>> CategoryInfo  : ObjectNotFound: (D:_x0008_uilds:String) [], 
>>> CommandNot _x000D__x000A_   
>>> FoundException_x000D__x000A_+ 
>>> FullyQualifiedErrorId : CommandNotFoundException_x000D__x000A_>> S=\"Error\"> _x000D__x000A_outer_x0008_in\\wrapper.exe 
>>> : The module 'outer_x0008_in' could not be loaded. For more 
>>> _x000D__x000A_information, run 'Import-Module 
>>> outer_x0008_in'._x000D__x000A_At line:2 
>>> char:1_x000D__x000A_+ 
>>> outer_x0008_in\\wrapper.exe_x000D__x000A_>> S=\"Error\">+ _x000D__x000A_
>>> + CategoryInfo  : ObjectNotFound: 
>>> (outer_x0008_in\\wrapper.exe:String) 
>>> [] _x000D__x000A_   , 
>>> CommandNotFoundException_x000D__x000A_>> S=\"Error\">+ FullyQualifiedErrorId : 
>>> CouldNotAutoLoadModule_x000D__x000A_>> S=\"Error\"> _x000D__x000A_", "stdout": "", "stdout_lines": []}
>>>
>>>
>>> Is it achievable what i'm trying to do?
>>>
>>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/98c14d68-a0a0-45a5-8122-147e816116a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How to create a service on a windows 10 machine?

2016-04-08 Thread Sharwari Phadnis
I am trying to create a service of type kernel on a remote windows 10 
machine from a linux ansible controller machine. To create a service I'm 
using *sc create* *type=kernel binpath=c:\path * command. 

Ansible playbook for creating a service:
- hosts: windows
  tasks:
 - name: Create temp service
   raw: sc create temp type=kernel binpath=c:\path\


And I'm getting the following error:

TASK [Create temp service on windows] 

fatal: [10.x.x.x]: FAILED! => {"changed": false, "failed": true, "rc": 1, 
"stderr": "#< CLIXML\r\nhttp://schemas.microsoft.com/powershell/2004/04\ 
">System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first 
use.0-1-1Completed-1 
Set-Content : A positional parameter 
cannot be found that accepts argument 'type=kernel'._x000D__x000A_At line:1 char:1_x000D__x000A_+ sc create 
temp type=kernel binpath=c:\\windows\\ ..._x000D__x000A_+ 
~_x000D__x000A_+ CategoryInfo  : InvalidArgument: (:) 
[Set-Content], ParameterBindingException_x000D__x000A_+ FullyQualifiedErrorId : 
PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand_x000D__x000A_ _x000D__x000A_", "stdout": "", "stdout_lines": []}



What could be the exact reason? Or is there any other of creating a service 
on a windows machine?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8cf9a0ae-91f0-4b1b-a871-51725ab9eb0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How to create a service on a windows 10 machine?

2016-04-08 Thread Sharwari Phadnis
I am trying to create a service of type kernel on a remote windows 10 
machine from a linux ansible controller machine. To create a service I'm 
using *sc create* *type=kernel binpath=c:\path * command. 

Ansible playbook for creating a service:
- hosts: windows
  tasks:
 - name: Create temp service
   raw: sc create temp type=kernel binpath=c:\path\


And I'm getting the following error:

TASK [Create temp service on windows] 

fatal: [10.110.80.127]: FAILED! => {"changed": false, "failed": true, "rc": 
1, "stderr": "#< CLIXML\r\nhttp://schemas.microsoft.com/powershell/2004/04\ 
">System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first 
use.0-1-1Completed-1 
Set-Content : A positional parameter 
cannot be found that accepts argument 'type=kernel'._x000D__x000A_At line:1 char:1_x000D__x000A_+ sc create 
temp type=kernel binpath=c:\\windows\\ ..._x000D__x000A_+ 
~_x000D__x000A_+ CategoryInfo  : InvalidArgument: (:) 
[Set-Content], ParameterBindingException_x000D__x000A_+ FullyQualifiedErrorId : 
PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand_x000D__x000A_ _x000D__x000A_", "stdout": "", "stdout_lines": []}



What could be the exact reason? Or is there any other of creating a service 
on a windows machine?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/da401159-4827-4831-bb0d-a1f97f67ad8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] how to create a service on a windows 10 machine?

2016-04-08 Thread Sharwari Phadnis
I am trying to create a service of type kernel on a remote windows 10 
machine from a linux ansible controller machine. To create a service I'm 
using *sc create* *type=kernel binpath=c:\path * command. 

Ansible playbook for creating a service:
- hosts: windows
  tasks:
 - name: Create temp service
   raw: sc create temp type=kernel binpath=c:\path\


And I'm getting the following error:

TASK [Create temp service on windows] 

fatal: [10.110.80.127]: FAILED! => {"changed": false, "failed": true, "rc": 
1, "stderr": "#< CLIXML\r\nhttp://schemas.microsoft.com/powershell/2004/04\ 
">System.Management.Automation.PSCustomObjectSystem.Object1Preparing modules for first 
use.0-1-1Completed-1 
Set-Content : A positional parameter 
cannot be found that accepts argument 'type=kernel'._x000D__x000A_At line:1 char:1_x000D__x000A_+ sc create 
gijane type=kernel binpath=c:\\windows\\ ..._x000D__x000A_+ 
~_x000D__x000A_+ CategoryInfo  : InvalidArgument: (:) 
[Set-Content], ParameterBindingException_x000D__x000A_+ FullyQualifiedErrorId : 
PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand_x000D__x000A_ _x000D__x000A_", "stdout": "", "stdout_lines": []}



What could be the exact reason? Or is there any other of creating a service 
on a windows machine?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0599ce64-33fa-44fd-a4c0-d0d6f5836746%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Send payload using uri module

2015-10-20 Thread Sharwari Phadnis
Yes, I tried that. It worked.

Thanks.
On 21-Oct-2015 9:48 am, "Igor Cicimov" 
wrote:

> Well first of all if you check the module docs
> http://docs.ansible.com/ansible/uri_module.html you can see that
> body_format was introduced in ansible 2.0 so you can't use it in 1.9.1
>
> It also shows an example of supplying the json file to the body parameter
> that looks much cleaner than what you are trying to do:
>
> body: "{{ lookup('file','issue.json') }}"
>
> Have you tried that?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/pUJfN9RL-NA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/53fde8bb-cca0-43aa-b464-8c6e6ad1bf9f%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJ3p3kp%2B97YfUiaWzR1WjFSeLOsp5--fLnDVMJjbpbcRpvnHmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Can't send JSON code using uri module

2015-10-18 Thread Sharwari Phadnis
 

I am trying to send a JSON payload using uri module through body parameter. 
The variables {{ network-name }} and and {{ IP1 }} are imported from 
config.yml. 

I have defined body in vars. The json code which I am trying to print is 
getting created properly using (debug: var={{ body | to_json}}). But, the 
output which I am redirecting to the dest file is showing errors. What 
could be the reason that the JSON payload is not getting sent at the 
destination url.


Here's the ansible playbook:



---
- hosts: localhost
  connection: local
  vars_files:
- config.yml
  vars:
body:
  id: 100
  network: 
name: "{{ network-name }}"
net_list:
  - link_id: 1
  - type: abc
  vlan: "10"
  profile: switch

  tasks:
- debug: var="{{ body | to_json }}"
- name: Run POST command
  uri:
url: "https://{{ IP1 }}/url/to/dest 
"
method: POST
body: "{{ body | to_json }}"
user: "abc"
password: "xyz"
HEADER_Content-Type: "application/json"
force_basic_auth: yes
return_content: yes
dest: /url/to/dest/file
   

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/85d514c4-68a4-4ab1-8d1d-3d9f9300abc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Variable substitution in uri module

2015-10-15 Thread Sharwari Phadnis
Hi,
   I'd explain my problem clearly, I have a same type of example as yours.

vars:
my_var: hello_world

  tasks:
- uri:
url: https://localhost/api/v1/
method: POST
body: jsoncode='{ "name": "test", "var": "{{ my_var }}", 
"location": "usa" }'
HEADER_Content-Type: "application/json"
status_code: 201
validate_certs: no
user: admin
password: password

Here, I replaced : with = and provided "" to the my_var variable. It's not 
giving any error but when I redirect the output of the request to a file. 
It gives the following  error message:

{
  "error_code" : 220,
  "module_name" : "common-services",
  "error_message" : "Could not read JSON: Unrecognized token 'jsoncode': 
was expecting 'null', 'true', 'false' or NaN\\n at [Source: 
org.apache.catalina.connector.CoyoteInputStream@29d4dd6e; line: 1, column: 
7]; nested exception is com.fasterxml.jackson.core.JsonParseException: 
Unrecognized token 'jsoncode': was expecting 'null', 'true', 'false' or 
NaN\\n at [Source: org.apache.catalina.connector.CoyoteInputStream@29d4dd6e; 
line: 1, column: 7 




Correct me if I am going wrong. Thanks in advance.



On Thursday, October 15, 2015 at 9:19:49 PM UTC+5:30, 
mic...@networktocode.com wrote:
>
> Hi Sharwari,
>
> This is the key fix, changing from colon syntax to equal sign syntax:
>
> - name: Create an instance
>   ec2: >
> state=present
> image="{{ ami_base_image_id }}"
> instance_type=t1.micro
> group="{{ instance_security_groups }}"
> key_name="{{ environment_public_ssh_key_name }}"
> vpc_subnet_id="{{ environment_vpc_public_subnet_az1_id }}"
> user_data="{{ lookup('template', '../templates/user_data.json') }}"
> assign_public_ip=yes
> wait=yes
> wait_timeout=600
> region="{{ vpc_region }}"
> aws_access_key="{{ aws_access_key }}"
> aws_secret_key="{{ aws_secret_key }}"
>   register: new_instance
>   when: environment_instance is not defined
>
> On Thursday, October 15, 2015 at 5:59:41 AM UTC-4, Sharwari Phadnis wrote:
>>
>> HI, I am facing the same problem. I went through the link which  you've 
>> posted but couldn't find the exact solution. Could you please post the 
>> solution which you've tried?
>>
>> On Saturday, October 3, 2015 at 1:15:51 AM UTC+5:30, 
>> mic...@networktocode.com wrote:
>>>
>>> I solved the problem after a lot of digging. In case it's of use to 
>>> anyone else: https://github.com/ansible/ansible/issues/7005
>>>
>>> On Thursday, October 1, 2015 at 4:02:29 PM UTC-4, 
>>> mic...@networktocode.com wrote:
>>>>
>>>> Hi all,
>>>>
>>>> Similar to 
>>>> https://groups.google.com/forum/#!topic/ansible-project/ba5PPAgYGXc 
>>>> but slightly different.
>>>>
>>>> I am trying to use variable substitution like so, putting the variable 
>>>> my_var in the body parameter, which should be a json string:
>>>>
>>>> vars:
>>>>   my_var: hello_world
>>>>
>>>> tasks:
>>>>   - uri:
>>>>   url: https://localhost/api/v1/
>>>>   method: POST
>>>>   body: '{ "name": "test", "var": "{{ my_var }}", "location": 
>>>> "usa" }'
>>>>   HEADER_Content-Type: "application/json"
>>>>   status_code: 201
>>>>   validate_certs: no
>>>>   user: admin
>>>>   password: password
>>>>
>>>> I get this error (stacktrace with a TypeError: unhashable type):
>>>>
>>>> TASK: [uri ] 
>>>> **
>>>> failed: [localhost] => {"failed": true, "parsed": false}
>>>> Traceback (most recent call last):
>>>>   File 
>>>> "/Users/mzb/.ansible/tmp/ansible-tmp-1443729077.78-98124067847188/uri", 
>>>> line 2067, in 
>>>> main()
>>>>   File 
>>>> "/Users/mzb/.ansible/tmp/ansible-tmp-1443729077.78-981240

[ansible-project] Re: Variable substitution in uri module

2015-10-15 Thread Sharwari Phadnis
HI, I am facing the same problem. I went through the link which  you've 
posted but couldn't find the exact solution. Could you please post the 
solution which you've tried?

On Saturday, October 3, 2015 at 1:15:51 AM UTC+5:30, 
mic...@networktocode.com wrote:
>
> I solved the problem after a lot of digging. In case it's of use to anyone 
> else: https://github.com/ansible/ansible/issues/7005
>
> On Thursday, October 1, 2015 at 4:02:29 PM UTC-4, mic...@networktocode.com 
> wrote:
>>
>> Hi all,
>>
>> Similar to 
>> https://groups.google.com/forum/#!topic/ansible-project/ba5PPAgYGXc but 
>> slightly different.
>>
>> I am trying to use variable substitution like so, putting the variable 
>> my_var in the body parameter, which should be a json string:
>>
>> vars:
>>   my_var: hello_world
>>
>> tasks:
>>   - uri:
>>   url: https://localhost/api/v1/
>>   method: POST
>>   body: '{ "name": "test", "var": "{{ my_var }}", "location": 
>> "usa" }'
>>   HEADER_Content-Type: "application/json"
>>   status_code: 201
>>   validate_certs: no
>>   user: admin
>>   password: password
>>
>> I get this error (stacktrace with a TypeError: unhashable type):
>>
>> TASK: [uri ] 
>> **
>> failed: [localhost] => {"failed": true, "parsed": false}
>> Traceback (most recent call last):
>>   File 
>> "/Users/mzb/.ansible/tmp/ansible-tmp-1443729077.78-98124067847188/uri", 
>> line 2067, in 
>> main()
>>   File 
>> "/Users/mzb/.ansible/tmp/ansible-tmp-1443729077.78-98124067847188/uri", 
>> line 419, in main
>> resp, content, dest = uri(module, url, dest, user, password, body, 
>> method, dict_headers, redirects, socket_timeout, validate_certs)
>>   File 
>> "/Users/mzb/.ansible/tmp/ansible-tmp-1443729077.78-98124067847188/uri", 
>> line 312, in uri
>> resp, content = h.request(url, method=method, body=body, 
>> headers=headers)
>>   File "/Library/Python/2.7/site-packages/httplib2/__init__.py", line 
>> 1609, in request
>> (response, content) = self._request(conn, authority, uri, 
>> request_uri, method, body, headers, redirections, cachekey)
>>   File "/Library/Python/2.7/site-packages/httplib2/__init__.py", line 
>> 1351, in _request
>> (response, content) = self._conn_request(conn, request_uri, method, 
>> body, headers)
>>   File "/Library/Python/2.7/site-packages/httplib2/__init__.py", line 
>> 1273, in _conn_request
>> conn.request(method, request_uri, body, headers)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>>  
>> line 973, in request
>> self._send_request(method, url, body, headers)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>>  
>> line 1007, in _send_request
>> self.endheaders(body)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>>  
>> line 969, in endheaders
>> self._send_output(message_body)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>>  
>> line 833, in _send_output
>> self.send(message_body)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py",
>>  
>> line 805, in send
>> self.sock.sendall(data)
>>   File 
>> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py",
>>  
>> line 229, in sendall
>> v = self.send(data[count:])
>> TypeError: unhashable type
>>
>> If I don't use quotes around the variable substition, like this:
>>
>>   vars:
>> my_var: hello_world
>>
>>   tasks:
>> - uri:
>> url: https://localhost/api/v1/
>> method: POST
>> body: '{ "name": "test", "var": {{ my_var }}, "location": 
>> "usa" }'
>> HEADER_Content-Type: "application/json"
>> status_code: 201
>> validate_certs: no
>> user: admin
>> password: password
>>
>> then, I get this error (No JSON type could be decoded):
>>
>> failed: [localhost] => {"allow": "GET, POST, HEAD, OPTIONS", 
>> "connection": "close", "content": "{\"detail\": \"JSON parse error - No 
>> JSON object could be decoded\"}", "content_type": "application/json", 
>> "date": "Thu, 01 Oct 2015 19:50:56 GMT", "failed": true, "json": {"detail": 
>> "JSON parse error - No JSON object could be decoded"}, "redirected": false, 
>> "server": "Apache/2.4.7 (Ubuntu)", "status": 400, "transfer_encoding": 
>> "chunked", "vary": "Accept,Cookie", "x_api_time": "0.001s"}
>> msg: Status code was not [201]
>>
>> Any ideas? Thanks in advance!
>>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email 

[ansible-project] Concatenate strings and variables.

2015-10-15 Thread Sharwari Phadnis
I want to concat strings and variables imported from a yml file. For 
example:

---
- hosts: localhost
  vars_files:
  - config.yml
  tasks:
 - uri: 
  url: "https://url/to/dest/server";
  method: POST
  body: '{"key1":"value1","key2":"value2" }'
  user: "abc"
  password: "xyz"
  return_content: yes
  HEADER_Content-Type: "application/json"


In the value1 field I want to substitute a variable {{var1}}="12234" which 
is imported from config.yml. So how can I substitute it?

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2310dd01-37ee-4a27-a494-103e38a2d978%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Send payload using uri module

2015-10-14 Thread Sharwari Phadnis
---
- hosts: localhost
  tasks:
- uri:
  url: https://url/to/the/dest/server 
<https://10.110.80.101/api/v1/host-switch-profiles>
  method: POST
  user: admin
  password: default
  force_basic_auth: yes
  body: '{JSON payload}'
  body_format: json
  register: payloadop

- name: Print command output
  action: command echo item
  with_items: payloadop.stdout

On Wednesday, October 14, 2015 at 4:42:12 PM UTC+5:30, David Karban wrote:
>
> Hi, 
>
> please send that one task here, so we can see what you are actually doing, 
> it will help to understand, thanks.
>
> David Karban
> Linux server specialist/Specialista na správu linuxových serverů
> www.karban.eu
>
> 2015-10-14 13:05 GMT+02:00 Sharwari Phadnis  >:
>
>> So, to send payload  body parameter could be used?
>>
>> On Wednesday, October 14, 2015 at 4:33:29 PM UTC+5:30, David Karban wrote:
>>>
>>> Hi, 
>>>
>>> this error usually means problem in indentation, body souhld be two 
>>> spaces deeper I guess. But cannot be sure, as you have not sent your task 
>>> here :).
>>>
>>> David Karban
>>> Linux server specialist/Specialista na správu linuxových serverů
>>> www.karban.eu
>>>
>>> 2015-10-14 12:59 GMT+02:00 Sharwari Phadnis :
>>>
>>>> I am trying to *send a payload(in JSON)* to a destination mentioned in 
>>>> the URL. For this purpose I am using* uri module and POST method*. How 
>>>> can I send it using uri module? I am using ansible* version 1.9.1* and 
>>>> when I tried to use *body parameter* for uri module it shows the 
>>>> following error:* body is not a legal parameter in an Ansible task or 
>>>> handler*. 
>>>>
>>>> -- 
>>>> 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 ansible-proje...@googlegroups.com.
>>>> To post to this group, send email to ansible...@googlegroups.com.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/ansible-project/a396f9dd-370d-44d9-9a21-149901848f88%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/ansible-project/a396f9dd-370d-44d9-9a21-149901848f88%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> -- 
>> 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 ansible-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/e211196d-372b-4ffd-af3b-f87899b69a82%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/e211196d-372b-4ffd-af3b-f87899b69a82%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/de532f69-a521-4b28-a215-32689a55e907%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Send payload using uri module

2015-10-14 Thread Sharwari Phadnis
 

---
- hosts: localhost
  tasks:
- uri:
  url: https://url/to/the/dest/server 
<https://10.110.80.101/api/v1/host-switch-profiles>
  method: POST
  user: admin
  password: default
  force_basic_auth: yes
  body: '{JSON payload}'
  body_format: json
  register: payloadop

- name: Print command output
  action: command echo item
  with_items: payloadop.stdout


On Wednesday, October 14, 2015 at 4:35:41 PM UTC+5:30, Sharwari Phadnis 
wrote:
>
> So, to send payload  body parameter could be used?
>
> On Wednesday, October 14, 2015 at 4:33:29 PM UTC+5:30, David Karban wrote:
>>
>> Hi, 
>>
>> this error usually means problem in indentation, body souhld be two 
>> spaces deeper I guess. But cannot be sure, as you have not sent your task 
>> here :).
>>
>> David Karban
>> Linux server specialist/Specialista na správu linuxových serverů
>> www.karban.eu
>>
>> 2015-10-14 12:59 GMT+02:00 Sharwari Phadnis :
>>
>>> I am trying to *send a payload(in JSON)* to a destination mentioned in 
>>> the URL. For this purpose I am using* uri module and POST method*. How 
>>> can I send it using uri module? I am using ansible* version 1.9.1* and 
>>> when I tried to use *body parameter* for uri module it shows the 
>>> following error:* body is not a legal parameter in an Ansible task or 
>>> handler*. 
>>>
>>> -- 
>>> 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 ansible-proje...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/a396f9dd-370d-44d9-9a21-149901848f88%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/ansible-project/a396f9dd-370d-44d9-9a21-149901848f88%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a60131dc-9590-43f4-ae25-4ea839d18833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Send payload using uri module

2015-10-14 Thread Sharwari Phadnis
So, to send payload  body parameter could be used?

On Wednesday, October 14, 2015 at 4:33:29 PM UTC+5:30, David Karban wrote:
>
> Hi, 
>
> this error usually means problem in indentation, body souhld be two spaces 
> deeper I guess. But cannot be sure, as you have not sent your task here :).
>
> David Karban
> Linux server specialist/Specialista na správu linuxových serverů
> www.karban.eu
>
> 2015-10-14 12:59 GMT+02:00 Sharwari Phadnis  >:
>
>> I am trying to *send a payload(in JSON)* to a destination mentioned in 
>> the URL. For this purpose I am using* uri module and POST method*. How 
>> can I send it using uri module? I am using ansible* version 1.9.1* and 
>> when I tried to use *body parameter* for uri module it shows the 
>> following error:* body is not a legal parameter in an Ansible task or 
>> handler*. 
>>
>> -- 
>> 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 ansible-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/a396f9dd-370d-44d9-9a21-149901848f88%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/a396f9dd-370d-44d9-9a21-149901848f88%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e211196d-372b-4ffd-af3b-f87899b69a82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Send payload using uri module

2015-10-14 Thread Sharwari Phadnis
I am trying to *send a payload(in JSON)* to a destination mentioned in the 
URL. For this purpose I am using* uri module and POST method*. How can I 
send it using uri module? I am using ansible* version 1.9.1* and when I 
tried to use *body parameter* for uri module it shows the following error:* 
body is not a legal parameter in an Ansible task or handler*. 

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a396f9dd-370d-44d9-9a21-149901848f88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] shell command not getting executed on the remote node

2015-09-15 Thread Sharwari Phadnis
I want to add a linux bridge on a remote node having ubuntu 14.04 version. 
I wrote a playbook to do so, it is as following:







* hosts: ans#  user: sudo  tasks:- name: send and execute  
shell: /sbin/brctl addbr br11*I've used shell command to execute brctl on 
the remote node but, it is showing me the following error:

 FAILED! => {"changed": false, "failed": true, "msg": "Traceback (most 
recent call last):\r\n  File 
\"/home/sharwari/ansible-tmp/tmp/ansible-tmp-1442293860.85-278841567636677/command\",
 
line 1913, in \r\nmain()\r\n  File 
\"/home/sharwari/ansible-tmp/tmp/ansible-tmp-1442293860.85-278841567636677/command\",
 
line 90, in main\r\nmodule = CommandModule(argument_spec=dict())\r\n  
File 
\"/home/sharwari/ansible-tmp/tmp/ansible-tmp-1442293860.85-278841567636677/command\",
 
line 543, in __init__\r\nself._check_for_check_mode()\r\n  File 
\"/home/sharwari/ansible-tmp/tmp/ansible-tmp-1442293860.85-278841567636677/command\",
 
line 1079, in _check_for_check_mode\r\nfor (k,v) in 
self.params.iteritems():\r\nAttributeError: 'tuple' object has no attribute 
'iteritems'\r\nOpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014\r\ndebug1: Reading 
configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 
19: Applying options for *\r\ndebug1: auto-mux: Trying existing 
master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: 
mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: 
request forwardings: 0 local, 0 remote\r\ndebug3: 
mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: 
entering\r\ndebug3: mux_client_request_alive: done pid = 30220\r\ndebug3: 
mux_client_request_session: session request sent\r\ndebug1: 
mux_client_request_session: master session id: 2\r\ndebug3: 
mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received 
exit status from master 0\r\nShared connection to 10.117.81.185 
closed.\r\n", "parsed": false}




-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1cec932e-56a1-4e8a-b716-aaf8f2d79ea2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.