How to re-run cloud-init without reboot

后端 未结 4 1583
南方客
南方客 2021-01-30 22:52

I am using openstack to create a VM using \'nova boot\' command. My image is cloud-init enabled. I pass a --user-data script which is a bash shell format for cloud-init to run d

相关标签:
4条回答
  • 2021-01-30 23:20

    Since this keeps popping up in search results, what works for me:

    1. Delete semaphores in /var/lib/cloud/instances/i-xxxxxxx/sem. Cloud-init will not re-run if these files are present.

    2. Edit /var/lib/cloud/instances/i-xxxxxxxx/scripts/part-001. This is your user-data script.

    3. Execute only the user scripts module of cloud-init. This will not re-download user data but execute the already downloaded (and now, modified) script from step 2.

      sudo /usr/bin/cloud-init single -n cc_scripts_user

    0 讨论(0)
  • 2021-01-30 23:23

    The commands have been updated so to re-run you need to clean out the existing config:

    sudo cloud-init clean
    

    Then re-run it using the init directive:

    sudo cloud-init init
    

    Beware: things like ssh host keys maybe regenerated.

    0 讨论(0)
  • 2021-01-30 23:27

    Updated: on recent versions:

    sudo cloud-init clean
    

    Then re-run it using the init directive:

    sudo cloud-init init
    
    0 讨论(0)
  • 2021-01-30 23:28

    To run the packages module of cloud-config part of cloud-init, you can run

    # cloud-init-cfg all config
    

    To run the runcmd module of cloud-config part of cloud-init, you can run

    # cloud-init-cfg all final
    
    0 讨论(0)
提交回复
热议问题