Bug 1821024 - Cloud init ssh authorized keys is not applied on the imported VM
Summary: Cloud init ssh authorized keys is not applied on the imported VM
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Console Kubevirt Plugin
Version: 4.2.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: 4.5.0
Assignee: Tomas Jelinek
QA Contact: Ilanit Stein
Depends On:
Blocks: 1821753
TreeView+ depends on / blocked
Reported: 2020-04-05 13:15 UTC by Ilanit Stein
Modified: 2020-07-13 17:25 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: The VM wizard did not generate the cloud-init in correct format. Consequence: If the cloud-init configuration was used in the wizard, it was not applyed on the VM Fix: corrected the format generated by the wizard Result: the cloud-init configuration provided in the VM wizard is applyed on the VM.
Clone Of:
: 1821753 (view as bug list)
Last Closed: 2020-07-13 17:25:33 UTC
Target Upstream Version:

Attachments (Terms of Use)
VM_yaml_file_screen_shot (16.03 KB, image/png)
2020-04-05 13:15 UTC, Ilanit Stein
no flags Details

System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2020:2409 None None None 2020-07-13 17:25:56 UTC

Description Ilanit Stein 2020-04-05 13:15:36 UTC
Created attachment 1676404 [details]

Description of problem:
Import a RHEL7.6 VM that has cloud-init package installed, and cloud-init service enabled,
In the Import VM dialog, cloud init screen fill this custom script:

-     path: "/tmp/test.txt"  
      content: Here is a line.

Import the VM, and then start the VM.
The file was not created on the VM, as expected, according to the provided custom script.

In the VM yaml file the cloudInitNoCloud section is in the attached cloud-init-in-yaml.png 

Version-Release number of selected component (if applicable):

Comment 1 Ilanit Stein 2020-04-05 14:51:46 UTC
This bug was initially reported in Bug 1786350, and was separated to this current bug.

Comment 2 Marek Libra 2020-04-06 11:48:54 UTC
With patch [1] applied, I followed:

- create Fedora 29 VM with cloud-init hostname and ssh_authorized_keys set via form in the UI
- and subsequently see /home/fedora/.ssh/authorized_keys to be filled with the key (so IIUC, this issue is fixed)

- turn off the VM
- edit VM's YAML to contain following:
       - cloudInitNoCloud:
            userData: |
              name: default
              hostname: my-host
              password: fedora
              chpasswd: { expire: False }
                - path: "/tmp/test.txt"
                  content: Here is a line.
                - >-
          name: cloudinitdisk
- once the VM is started, I can still see proper content in the authorized_keys file, same as the expected content in the `/tmp/test.txt` file.

- Custom script entered by the UI form works as well (means: is executed).

So far I did not try on rhel-7.6 since I have difficulties to get the image. Will keep trying. 
I did not try within the v2v flow but the behavior should be the same in this part.

Ilanit, can you please confirm that this is the expected behavior?
And verify for both create and import RHEL-7.6 flows, please?

[1] https://github.com/openshift/console/pull/4923

Comment 3 Marek Libra 2020-04-06 12:16:52 UTC
Update: I have just succeeded with the steps above on RHEL 7.6 too

The only thing missing to be tested is v2v Import flow but the code is shared with the Create VM flow.

Comment 8 Ilanit Stein 2020-04-08 07:14:33 UTC
Based on Marek's verification, for cloud-init, both by form fill with ssh key, and custom script, in VM creation,
moving bug to verified.

Comment 9 errata-xmlrpc 2020-07-13 17:25:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


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