← Back to team overview

cloud-init team mailing list archive

Re: Cloud-init not installing rpms (CentOS 6.5)

 

On Fri, 28 Mar 2014, justin@xxxxxxxxxxxxxx wrote:

> On 2014-03-28 21:18, Joshua Harlow wrote:
> > U should be able to put it in /etc/cloud/cloud.cfg.d/
> >
> > http://cloudinit.readthedocs.org/en/latest/topics/merging.html [2]
> > should help u with this I think.
> >
> > Let us know if all things go fine :)
>
> So far, managed to get it mostly working. :)
>
> Created a file:
>
>   /etc/cloud/cloud.cfg.d/01_rpm_packages.cfg
>
> Including just the missing option wasn't good
> enough:
>
>   cloud_config_modules:
>    - package-update-upgrade-install
>
> The yum update fires off, but the "runcmd" commands
> don't.  Which seem to mean the injected file was
> replacing the contents of that section, not merging it.
>
> Pretty straightforward to fix that though.  Adding the
> full section contents to the injected file works, with
> both the rpm package being installed and the commands
> being run:
>
>   cloud_config_modules:
>    - mounts
>    - locale
>    - set-passwords
>    - package-update-upgrade-install
>    - timezone
>    - puppet
>    - chef
>    - salt-minion
>    - mcollective
>    - disable-ec2-metadata
>    - runcmd

Right.  You have to specify the whole list in cloud-config mode.
Note, you don't have to "inject" that file, you could just have well have
put that cloud_config_modules portion inside cloud-config where you were
putting your 'runcmd'.

Also, if for some things, you could use the json patch mode
("#cloud-config-jsonp").  Its even worse documented than other parts of
cloud-init.   But essentially, if you have multi-part input, you can
modify the configuration via json-patch notation
(https://tools.ietf.org/html/rfc6902) .

> The last piece I need to figure out isn't playing ball
> though.  I'm trying to get a kernel update installed,
> with the VM rebooted, before the runcmd fires.
>
> This doesn't work:
>
>   #cloud-config
>   package_reboot_if_required: true
>   packages:
>    - git
>    - kernel
>
>   runcmd:
>    - echo 'complete' >> /tmp/my-cloud-config.log
>
> Nor this:
>
>   #cloud-config
>   package_update: true
>   package_upgrade: true
>   package_reboot_if_required: true
>   packages:
>    - git
>    - kernel
>
>   runcmd:
>    - echo 'complete' >> /tmp/my-cloud-config.log
>
> Is there a different module I should be including?

You were right, this module requires the packaging to give some indication
that a reboot is necessary.  (ie, create /var/run/reboot-required).  I'm
not sure if rhel/centos has anything like this or not.

Scott


Follow ups

References