kubernetes-retired / cluster-api-bootstrap-provider-kubeadm

LEGACY REPO. NEW CODE IS https://github.com/kubernetes-sigs/cluster-api/tree/master/bootstrap/kubeadm
Apache License 2.0
62 stars 67 forks source link

Do not single-quote additional commands #201

Closed akutz closed 4 years ago

akutz commented 4 years ago

/kind bug

What steps did you take and what happened: Commands given to the cloud-init runcmd module are currently single-quoted:

runcmd:
  - 'hostname '{{ ds.meta_data.hostname }}''

This causes issues when strings inside the commands are themselves single-quoted. The above example should be emitted like so:

runcmd:
  - hostname '{{ ds.meta_data.hostname }}'

What did you expect to happen: The commands should not be quoted at all, per the cloud-init docs, ex:

#cloud-config

# run commands
# default: none
# runcmd contains a list of either lists or a string
# each item will be executed in order at rc.local like level with
# output to the console
# - runcmd only runs during the first boot
# - if the item is a list, the items will be properly executed as if
#   passed to execve(3) (with the first arg as the command).
# - if the item is a string, it will be simply written to the file and
#   will be interpreted by 'sh'
#
# Note, that the list has to be proper yaml, so you have to quote
# any characters yaml would eat (':' can be problematic)
runcmd:
 - [ ls, -l, / ]
 - [ sh, -xc, "echo $(date) ': hello world!'" ]
 - [ sh, -c, echo "=========hello world'=========" ]
 - ls -l /root
 # Note: Don't write files to /tmp from cloud-init use /run/somedir instead.
 # Early boot environments can race systemd-tmpfiles-clean LP: #1707222.
 - mkdir /run/mydir
 - [ wget, "http://slashdot.org", -O, /run/mydir/index.html ]
chuckha commented 4 years ago

Closing as a duplicate:

https://github.com/kubernetes-sigs/cluster-api-bootstrap-provider-kubeadm/issues/192

Will add a note about quoting there since some quoting is required as per the docs. Anything that YAML would get confused by needs quotes.