| #cloud-config | |
| write_files: | |
| - path: /root/hello-world.txt | |
| content: | | |
| #!/bin/bash | |
| username=XXXXXX | |
| APIkey=XXXXXX | |
| dc=hkg | |
| container=dn-container | |
| file=xyz.tar.gz | |
| token() { | |
| token=`curl -s "https://identity.api.rackspacecloud.com/v2.0/tokens" -X POST \ | |
| -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"'$username'", "apiKey":"'$APIkey'"}}}' \ | |
| -H "Content-Type: application/json" | python -m json.tool | sed -n '/expires/{n;p;}' |sed -e 's/^.*"id": "\(.*\)",/\1/'` | |
| echo "Your API Token is ----> $token" > /root/token.txt | |
| } | |
| token | |
| Output (in cloud server): | |
| root@test-server:~# cat hello-world.txt | |
| username=XXXXXX | |
| APIkey=XXXXXX | |
| dc=hkg | |
| container=dn-container | |
| file=xyz.tar.gz | |
| token() { | |
| token=`curl -s "https://identity.api.rackspacecloud.com/v2.0/tokens" -X POST undefined | |
| -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"'$username'", "apiKey":"'$APIkey'"}}}' undefined | |
| -H "Content-Type: application/json" | python -m json.tool | sed -n '/expires/{n;p;}' |sed -e 's/^.*"id": "undefined(.*undefined)",/undefined1/'` | |
| echo "Your API Token is ----> $token" > /root/token.txt | |
| } | |
| token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment