RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1266627 - Cloud-init reboot fail
Summary: Cloud-init reboot fail
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cloud-init
Version: 7.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Lars Kellogg-Stedman
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-09-25 21:54 UTC by Eric Jones
Modified: 2020-12-11 11:55 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-09-29 15:40:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Eric Jones 2015-09-25 21:54:02 UTC
Description of problem:
Trying to get system to reboot once cloud init script completes, it does not.

Version-Release number of selected component (if applicable):
Rhel 7.1
cloud init 0.7.6

How reproducible:
very

Steps to Reproduce:
1. Spin up vm with image of rhel 7.1 with flavor m3.large on https://control.os1.phx2.redhat.com/dashboard and add a basic cloud init script, including reboot option, to "Post-completion"
This is the simple cloud init, everything but the power_state works
--------------------------------
#cloud-config      
# vim:syntax=yaml
hostname: example
fqdn: example.example.com
manage_etc_hosts: false
debug: True
ssh_pwauth: True
disable_root: false
chpasswd:
  list: |
    root:redhat
    cloud-user:test
  expire: false
write_files:
  - path: /etc/sysconfig/docker-storage-setup
    permissions: 0644
    owner: root
    content: |
      DEVS=/dev/vdb
      VG=docker-vg
      SETUP_LVM_THIN_POOL=yes
power_state:
  delay: "+1"
  mode: reboot
  message: Bye Bye
  timeout: 10
runcmd:
- echo "MTU=1450" >> /etc/sysconfig/network-scripts/ifcfg-eth0
- service network restart
- echo 'StrictHostKeyChecking no' >> /etc/ssh/ssh_config
- echo 'UserKnownHostsFile /dev/null' >> /etc/ssh/ssh_config
- sed -i'.orig' -e's/without-password/yes/' /etc/ssh/sshd_config
- service sshd restart
---------------------------
2.log into the instance and run 'tail -f /var/log/cloud-init.log'

Actual results:
Writes the file and allows for ssh into the box, but does not reboot the machine.

Expected results:
Writes the file, allows for ssh into the box, and reboot the machine.

Additional info:
Am I simply using it incorrectly?
Is there a different place to check for debug?
Any kind of help with this, either pointing me to documentation of it in use or fixing the bug, would be great

Comment 2 Lars Kellogg-Stedman 2015-09-28 14:05:21 UTC
Are you use the RHEL guest image?  Or RHEL atomic?  Can you confirm that you've got cloud-init version cloud-init-0.7.6-2.el7.x86_64?

> Is there a different place to check for debug?

Like most services, you can see cloud-init logs with journalctl.  For example:

    journalctl -b | grep -i cloud

Comment 3 Lars Kellogg-Stedman 2015-09-28 14:43:52 UTC
All right, never mind those questions.

The power_state module is not enabled by default in /etc/cloud/cloud.cfg, which means you would need to enable it explicitly.  You have a few options:

1. You can pass a 'cloud_final_modules' configuration section, listing power_state_change *and any other modules you want to run during the final stage*, because this will replace the defaults in /etc/cloud/cloud.cfg.  For example:

    #cloud-config

    disable_root: false
    chpasswd:
      list: |
        root:redhat
      expire: false
    power_state:
      delay: "+1"
      mode: reboot
      message: Bye Bye
      timeout: 10
    cloud_final_modules:
      - rightscale_userdata
      - scripts-per-once
      - scripts-per-boot
      - scripts-per-instance
      - scripts-user
      - ssh-authkey-fingerprints
      - keys-to-console
      - phone-home
      - final-message
      - power_state_change
      
2. You can do it using a `runcmd` shell script instead:
    
    #cloud-config

    disable_root: false
    chpasswd:
      list: |
        root:redhat
      expire: false
    runcmd:
      - sleep 60 && reboot

Comment 4 Eric Jones 2015-09-28 15:14:52 UTC
(In reply to Lars Kellogg-Stedman from comment #3)
> All right, never mind those questions.
> 
> The power_state module is not enabled by default in /etc/cloud/cloud.cfg,
> which means you would need to enable it explicitly.  You have a few options:
> 
> 1. You can pass a 'cloud_final_modules' configuration section, listing
> power_state_change *and any other modules you want to run during the final
> stage*, because this will replace the defaults in /etc/cloud/cloud.cfg.  For
> example:
> 
>     #cloud-config
> 
>     disable_root: false
>     chpasswd:
>       list: |
>         root:redhat
>       expire: false
>     power_state:
>       delay: "+1"
>       mode: reboot
>       message: Bye Bye
>       timeout: 10
>     cloud_final_modules:
>       - rightscale_userdata
>       - scripts-per-once
>       - scripts-per-boot
>       - scripts-per-instance
>       - scripts-user
>       - ssh-authkey-fingerprints
>       - keys-to-console
>       - phone-home
>       - final-message
>       - power_state_change
>       
> 2. You can do it using a `runcmd` shell script instead:
>     
>     #cloud-config
> 
>     disable_root: false
>     chpasswd:
>       list: |
>         root:redhat
>       expire: false
>     runcmd:
>       - sleep 60 && reboot

I will give these a shot.

Thank you.

Comment 5 Eric Jones 2015-09-29 15:40:08 UTC
I failed to try the second one as the first worked immediately. Thank you! I am going to close this now, feel free to change the details as necessary.


Note You need to log in before you can comment on or make changes to this bug.