On CentOS 7 I am using cloud-init to spin off a droplet using the DigitalOCean API which requires yaml formatting.
I got most parts working fine, but struggle on escaping the commands running at 'runcmd' below:
#!/bin/sh
set -e # Stop on first error
curl -X POST http://ift.tt/1miSDzD \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer '$api_key'' \
-d '{
"name":"'$droplet_name'",
"region":"'$region'",
"size":"'$size'",
"image":"'$image'",
"ssh_keys":'$root_ssh_pub_key',
"backups":false,
"ipv6":false,
"private_networking":false,
"user_data":"
#cloud-config
users:
- name: SomeUser
groups: wheel
shell: /bin/bash
ssh-authorized-keys:
- ssh-dss AAAABBBBCCCCDDDDD...
runcmd:
- sed -i -e '$aAllowUsers SomeUser' /etc/ssh/sshd_config
- sed -i -e '/PermitRootLogin/s/^.*$/PermitRootLogin no/' /etc/ssh/sshd_config
- service sshd restart
"}'
The errors I receive are:
curl: (6) Could not resolve host: no
curl: (3) [globbing] unmatched close brace/bracket in column 63
Aucun commentaire:
Enregistrer un commentaire