Skip to content

Instantly share code, notes, and snippets.

@ogavrisevs
Created June 5, 2015 07:14
Show Gist options
  • Save ogavrisevs/4119307f9a9a7598e19f to your computer and use it in GitHub Desktop.
Save ogavrisevs/4119307f9a9a7598e19f to your computer and use it in GitHub Desktop.
Ansible URI module with POST fails
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> REMOTE_MODULE uri method=PUT url=http://localhost:9200/_snapshot/s3_backups_grafana
<127.0.0.1> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/xxxxx/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=2222 -o IdentityFile="/Users/xxxxx/.vagrant.d/insecure_private_key" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 127.0.0.1 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196 && echo $HOME/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196'
<127.0.0.1> PUT /var/folders/_1/pg5y8ygn4gdbcyxhw1x6lhxw0000gn/T/tmpgpjvIl TO /home/vagrant/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196/uri
<127.0.0.1> EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/xxxxx/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=2222 -o IdentityFile="/Users/xxxxx/.vagrant.d/insecure_private_key" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 127.0.0.1 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=ovwmjpzbidikxfbscjwlywedbnwyqvyh] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-ovwmjpzbidikxfbscjwlywedbnwyqvyh; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196/uri; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196/ >/dev/null 2>&1'"'"''
failed: [elastic] => (item={'indice': 'grafana-dash', 'name': 'grafana'}) => {"failed": true, "item": {"indice": "grafana-dash", "name": "grafana"}, "parsed": false}
BECOME-SUCCESS-ovwmjpzbidikxfbscjwlywedbnwyqvyh
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196/uri", line 2045, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196/uri", line 403, in main
resp, content, dest = uri(module, url, dest, user, password, body, method, dict_headers, redirects, socket_timeout)
File "/home/vagrant/.ansible/tmp/ansible-tmp-1433428044.88-119207179644196/uri", line 302, in uri
resp, content = h.request(url, method=method, body=body, headers=headers)
File "/usr/lib/python2.6/site-packages/httplib2/__init__.py", line 1605, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/lib/python2.6/site-packages/httplib2/__init__.py", line 1353, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/lib/python2.6/site-packages/httplib2/__init__.py", line 1290, in _conn_request
conn.request(method, request_uri, body, headers)
File "/usr/lib64/python2.6/httplib.py", line 914, in request
self._send_request(method, url, body, headers)
File "/usr/lib64/python2.6/httplib.py", line 954, in _send_request
self.send(body)
File "/usr/lib64/python2.6/httplib.py", line 759, in send
self.sock.sendall(str)
File "<string>", line 1, in sendall
TypeError: sendall() argument 1 must be string or buffer, not dict
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/oskars/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 102: Applying options for *
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 2537
debug3: mux_client_request_session: session request sent
debug1: mux_client_request_session: master session id: 2
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 0
Shared connection to 127.0.0.1 closed.
- name: add backup endpopints on AWS.s3
uri:
url: "http://localhost:{{ elasticsearch_port }}/_snapshot/s3_backups_{{ item.name}}"
method: PUT
body: "{{ elasticsearch_s3_backup_set_snapshot_body | to_json }}"
HEADER_Content-Type: "application/json"
status_code: 200
with_items: elasticsearch_backup_indices
when: elasticsearch_backup == "true"
- name: add beckup endpopints on AWS.s3
uri:
url: "http://localhost:{{ elasticsearch_port }}/_snapshot/s3_backups_{{ item.name}}"
method: PUT
body: "{
\"type\": \"s3\",
\"settings\": {
\"bucket\": \"{{ elasticsearch_s3_bucket }}\",
\"region\": \"eu-west-1\",
\"access_key\": \"{{ elasticsearch_s3_access_key }}\",
\"secret_key\": \"{{ elasticsearch_s3_secret_key }}\"
}
}"
status_code: 200
body_format: json
return_content: yes
with_items: elasticsearch_backup_indices
when: elasticsearch_backup == "true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment