I'm using Ansible to purchase a domain name using the namecheap.com api.
Here is a example of the playbook.
- name: Purchase Domain Name
local_action: >
uri url=https://api.sandbox.namecheap.com/xml.response
method=GET body="{{ namecheap_purchase_domain_name }}"
status_code=200
HEADER_Content-Type="application/x-www-form-urlencoded"
register: domain_name_purchase
- debug: msg="{{ domain_name_purchase }}"
The output looks like this:
ok: [162.243.95.241] => {"cache_control": "private", "changed": false,
"content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<ApiResponse
Status=\"OK\" xmlns=\"http://api.namecheap.com/xml.response\">\r\n <Errors
/>\r\n <Warnings />\r\n
<RequestedCommand>namecheap.domains.getList</RequestedCommand>\r\n
<CommandResponse Type=\"namecheap.domains.getList\">\r\n
<DomainGetListResult>\r\n <Domain ID=\"33320\"
Name=\"asdfasdfasdfasdfasdfasdfasdfjk123.com\" User=\"username\"
Created=\"11/19/2013\" Expires=\"11/19/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"33321\" Name=\"avd.com\" User=\"username\"
Created=\"11/19/2013\" Expires=\"11/19/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"33319\" Name=\"domain.com\" User=\"username\"
Created=\"11/19/2013\" Expires=\"11/19/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"33318\" Name=\"domain.com\" User=\"username\"
Created=\"11/19/2013\" Expires=\"11/19/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"33322\" Name=\"domain11.com\" User=\"username\"
Created=\"11/19/2013\" Expires=\"11/19/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"33323\" Name=\"domain 13.com\" User=\"username\"
Created=\"11/19/2013\" Expires=\"11/19/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"32804\" Name=\"domain.com\" User=\"username\"
Created=\"11/01/2013\" Expires=\"11/02/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"32805\" Name=\"domain3.com\" User=\"username\"
Created=\"11/01/2013\" Expires=\"11/02/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"32806\" Name=\"domain 4.com\" User=\"username\"
Created=\"11/01/2013\" Expires=\"11/02/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
<Domain ID=\"33316\" Name=\"domain5.com\" User=\"username\"
Created=\"11/19/2013\" Expires=\"11/19/2014\" IsExpired=\"false\"
IsLocked=\"false\" AutoRenew=\"false\" WhoisGuard=\"NOTPRESENT\" />\r\n
</DomainGetListResult>\r\n <Paging>\r\n
<TotalItems>10</TotalItems>\r\n <CurrentPage>1</CurrentPage>\r\n
<PageSize>20</PageSize>\r\n </Paging>\r\n </CommandResponse>\r\n
<Server>WEB1-SANDBOX1</Server>\r\n
<GMTTimeDifference>--5:00</GMTTimeDifference>\r\n
<ExecutionTime>0.096</ExecutionTime>\r\n</ApiResponse>", "content_length":
"2478", "content_location":
"https://api.sandbox.namecheap.com/xml.response", "content_type":
"text/xml; charset=utf-8", "date": "Wed, 20 Nov 2013 02:06:37 GMT", "item":
"", "redirected": false, "server": "Microsoft-IIS/7.0", "status": 200,
"x_aspnet_version": "4.0.30319", "x_powered_by": "ASP.NET"}
I'm interested in the XML inside the 'content' container. Is there any way
to query this output so I know if the purchase was successful or not
--
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].
For more options, visit https://groups.google.com/groups/opt_out.