cloud-config should support some method for passing scripts

Asked by Scott Moser on 2010-03-19

Binary package hint: cloud-init

Gustavo asked if there was a way to put scripts to run into cloud-config. At the current point there is no easy way to get the same functionality entirely within cloud-config of user-data like:
  echo hello world

There are 2 ways to accomplish this, but possibly less than ideal:
a.) use multi-part mime, one section for cloud-config, one for #!/bin/sh
b.) use runcmd with 'sh -c':
      - [ sh, -c, echo "=========hello world'=========" ]
        - sh
        - -c
        - |
          echo hi

Question information

English Edit question
Ubuntu cloud-init Edit question
No assignee Edit question
Solved by:
Scott Moser
Last query:
Last reply:
Scott Moser (smoser) said : #1
Scott Moser (smoser) said : #2

I think I've found a suitable solution with the same function as the attached patch, but utilizing only 'runcmd'. See the attachment.

Scott Moser (smoser) said : #3

I'm marking this "won't fix" . The functionality is currently easily available with 'runcmd'. For implementation, see the following cloud-config:

 - &alphabet |
   echo "======= $(date) ${0##*/} ========"
   echo "hello ${1}"
   echo "abcdefghijk..."

 - [ sh, -c, *alphabet, "say-the-alphabet", "scott" ]

Scott Moser (smoser) said : #4

Turning this into a question.

Question: Can I include scripts inside cloud-config syntax?
Answer: Yes, by using runcmd this can easily be accomplished.

Scott Moser (smoser) said : #5

See above for solution