Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runcmd doesn't seem to work properly #24

Open
markdryan opened this issue Nov 17, 2017 · 4 comments
Open

runcmd doesn't seem to work properly #24

markdryan opened this issue Nov 17, 2017 · 4 comments

Comments

@markdryan
Copy link
Contributor

I guess I must be doing something wrong, but I'm experiencing a weird problem on clearlinux 19110. I have a cloud init file with a runcmd section that looks like this.

runcmd:
 - systemctl start sshd
 - systemctl enable sshd

ucd is not running these commands correctly. It does

/bin/sh -c "systemctl start sshd systemctl enable sshd"

which fails. I'd expect it to do

/bin/sh -c "systemctl start sshd"
/bin/sh -c "systemctl enable sshd"

I don't really understand how the g_node stuff works but looking at the code

https://github.com/clearlinux/micro-config-drive/blob/master/src/ccmodules/runcmd.c#L52

It does seem like ucd concatenates all the commands in the runcmd section into one large string which it executes in one go, which is unlikely to work.

@ahkok
Copy link
Contributor

ahkok commented Nov 27, 2017

This is a YAML language / YAML parser issue, in essence. The yaml-to-glib parser we have has issues with arrays in this way.

As you can see from the examples, wrapping the commands in [] characters will define the arrays of words as separate lists properly:

https://github.com/clearlinux/micro-config-drive/blob/master/examples/runcmd.yaml

IOW, do this instead:

runcmd:
 - [ systemctl start sshd ]
 - [ systemctl enable sshd ]

As a side note, when it comes to services, you can always do this: https://github.com/clearlinux/micro-config-drive/blob/master/examples/service.yaml

@ahkok
Copy link
Contributor

ahkok commented Nov 27, 2017

Closing this as I think we'll keep the current behavior. Redoing the parser may be too much work.

@ahkok ahkok closed this as completed Nov 27, 2017
@markdryan
Copy link
Contributor Author

Thanks for the tip. I'll update my cloud-init files to use the service tag. I'm still a little worried about the bug though. From what I can tell you should be able to specify a string and not just an array of strings for each cmd. From http://cloudinit.readthedocs.io/en/latest/topics/modules.html#runcmd

Config schema:
runcmd: (array of (array of string)/(string))

Even in the example, not all the commands are wrapped in [],

https://github.com/clearlinux/micro-config-drive/blob/master/examples/runcmd.yaml#L6

Is udc processing this example correctly?

I've also found some other examples on the web where people aren't using arrays of arrays of string for runcmd, e.g.,

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

This issue might cause problems for people migrating their cloud-init files to work with udc. Is this behaviour documented somewhere?

@ahkok
Copy link
Contributor

ahkok commented Nov 28, 2017

It processes the example correctly by sheer coincidence, since there is only one example without []s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants