cloud-config should support some method for passing scripts
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:
#!/bin/sh
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':
runcmd:
- [ sh, -c, echo "=========hello world'=========" ]
-
- sh
- -c
- |
#!/bin/sh
echo hi
Question information
- Language:
- English Edit question
- Status:
- Solved
- Assignee:
- No assignee Edit question
- Solved by:
- Scott Moser
- Solved:
- 2010-03-26
- Last query:
- 2010-03-26
- Last reply:
- 2010-03-19
This question was originally filed as bug #541907.
Scott Moser (smoser) said : | #1 |
Scott Moser (smoser) said : | #2 |
Hm...
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:
#cloud-config
foobar:
- &alphabet |
#!/bin/sh
echo "======= $(date) ${0##*/} ========"
echo "hello ${1}"
echo "abcdefghijk..."
runcmd:
- [ 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