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

ucd-aws ignores #!/bin/bash and #cloud-config #54

Open
m1keil opened this issue Oct 22, 2021 · 0 comments
Open

ucd-aws ignores #!/bin/bash and #cloud-config #54

m1keil opened this issue Oct 22, 2021 · 0 comments

Comments

@m1keil
Copy link

m1keil commented Oct 22, 2021

According to the docs:

If the user-data starts with #!, it is assumed that the user-data is a generic shell script, and cloud-init will attempt to execute the data as a script

When testing this:

$ curl http://169.254.169.254/latest/user-data
#!/bin/bash

touch /tmp/USERDATA_WAS_HERE

ucd-aws logs shows:

$ sudo journalctl -b -u ucd-aws
-- Journal begins at Fri 2021-10-22 02:02:16 UTC, ends at Fri 2021-10-22 02:05:50 UTC. --
systemd[1]: Starting micro-config-drive job for AWS...
[3.268514] micro-config-drive version: 45
[3.268635] userdata: Looking for shebang file /var/lib/cloud/aws-user-data
[3.268675] userdata: Shebang found #cloud-config
[3.268682] Parsing user data file /var/lib/cloud/aws-user-data
[3.269054] An error occurred while the yaml file was parsed.
...
systemd[1]: Finished micro-config-drive job for AWS.

The file looks like this:

$ sudo cat /var/lib/cloud/aws-user-data
#cloud-config
users:
  - name: clear
    groups: wheelnopw
ssh_authorized_keys:
  - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7VLvf7oKsafgenvyYVnnCHDqakHCtq/SpTzxniaMceh0QPNl8B78qqsJBgspvTNFbVSKLNeUbODQeeC9tgb11q1nvW7ZXZRSY0B957+VmCxGQ681X+YbeYM4RoipGLg1QruzjkLITcARar7tRfUP65WBRo8s5UhyqMwA1cYwLUPNL7OZAUkpOdMVF2wdmjVMGooY9S2JUztFYEnIDsEFeH12yzGkEM9W/d8gEpQDGus+aBgKRoABpqxlCZiEfL7y4Xlcu7YoC6UouqiGPdwz1iocyTH2iTkVio8b/AGVgkoo1WMFo/rGFHAPpuW4RcVcgfOby29BFmap28CYYlqRN msverdlik
#!/bin/bash

touch /tmp/USERDATA_WAS_HERE

It looks like the userdata supplied by the user is appended to some auto-generated userdata (probably by ucd?).

A similar problem occurs with #cloud-init. The entire userdata is appended to the end of /var/lib/cloud/aws-user-data.
So in order to run cloud-init style config, the user actually needs to avoid supplying any first line stanza:

curl http://169.254.169.254/latest/user-data
runcmd:
    - touch /home/clear/hello_world
@m1keil m1keil changed the title ucd-aws ignores #!/bin/bash ucd-aws ignores #!/bin/bash or #cloud-config Oct 22, 2021
@m1keil m1keil changed the title ucd-aws ignores #!/bin/bash or #cloud-config ucd-aws ignores #!/bin/bash and #cloud-config Oct 22, 2021
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

1 participant