Should be #cloud-config file be run after the first creation or only after the first reboot? (RancherOS)

Posted January 24, 2018 4.3k views

I’m using terraform to buld the server, and it does work correctly after the first reboot, but after creation it doesn’t work. What the script is trying to do is to start a rancher service. LIke I said if I reboot the server the rancher service comes up perfectly, but it isn’t coming up after the box is first created.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

The cloud-config file should be run on first boot. Though with RancherOS, there is an important caveat that can sometimes catch people up. From the Rancher docs:

When using runcmd, RancherOS will wait for all commands to complete before starting Docker. As a result, any docker run command should not be placed under runcmd. Instead, the /etc/rc.local script can be used. RancherOS will not wait for commands in this script to complete, so you can use the wait-for-docker command to ensure that the Docker daemon is running before performing any docker run commands.

So if the service depends on Docker, it’s possible that it’s not available yet. Though as it comes up after a reboot, there could be another issue here. Could you share your actual script or an example demonstrating the same behavior? It would help narrow down the problem.

  • Thank you for the quick reply. I’m not actually using runcmd, but that is good to know.
    Here is the full cloud-init file:

          image: rancher/server
          restart: always
            - 8080:8080

    Like you said, a lot of the reasons I could see for it not starting don’t make as much sense because it does work after I reboot!

    Thanks again.

    • @neil323125 I had a hunch, and it looks like it was right! On first boot, it might take some time as the rancher/server image needs to be pulled down from Docker Hub. I created a new RancherOS Droplet using that config. At first, it seemed as if I had reproduced your issue, but after waiting for awhile longer the Racher UI became available on port 8080.

      • Interesting, I did wait quite a long time but perhaps not long enough or some glitch. Thanks for trying to reproduce, I’m just doing exactly the same thing with CoreOS to see what that did. Thanks @asb I appreciate it, I’ll give it another whirl.