Bug 2213449 - cloud-init fails when configuring both network and SSH key from the OpenShift console
Summary: cloud-init fails when configuring both network and SSH key from the OpenShift...
Keywords:
Status: NEW
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: User Experience
Version: 4.12.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Tal Nisan
QA Contact: Guohua Ouyang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-06-08 07:55 UTC by Dieter
Modified: 2023-07-18 09:57 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 2190439 0 unspecified NEW cloudInitConfigDrive yaml contains cloudInitNoCloud content 2023-08-01 19:14:01 UTC
Red Hat Issue Tracker CNV-29802 0 None None None 2023-06-12 21:13:24 UTC
Red Hat Knowledge Base (Solution) 7024905 0 None None None 2023-07-18 09:57:11 UTC

Internal Links: 2190439 2213073

Description Dieter 2023-06-08 07:55:27 UTC
# Description of problem:
When creating a virtual machine from the console, adding both network information and an SSH key via cloud-init does not work.

# How reproducible:
100%

# Steps to Reproduce:
1: From the console, create a RHEL9 VM using the template, customize virtual machine 
2: Add a secondary Network interface
3: Go to scripts => Edit cloudinit => "Add network data" => use
Ethernet name: eth1
IP addresses: 10.10.21.32/24
4: Authorized SSH Key => Edit and add a public key
5: Go to yaml and make changes to work around https://bugzilla.redhat.com/show_bug.cgi?id=2213073
6: Create virtual machine

A code snippet of the VirtualMachine I created: 
```
    spec:
      accessCredentials:
        - sshPublicKey:
            propagationMethod:
              configDrive: {}
            source:
              secret:
                secretName: rhel9-6hwr6fv1xm7axnm6-ssh-key-hsby3p
....
        - cloudInitConfigDrive:
            networkData: |
              network:
                version: 1
                config:
                  - type: physical
                    name: eth1
                    subnets:
                      - type: static
                        address: 10.10.21.32.24
            userData: |
              #cloud-config
              user: cloud-user
              password: cloud-user
              chpasswd:
                expire: false
```                
                

# Actual results:
Neither the cloud-user password, the SSH key or the networking was configured on the VM. (login does not work, and ping does not work)

# Expected results:
The static IP to be configured, and the password and SSH key for the cloud user to be set.
Note that when leaving out the network configuration, the SSH key and cloud user password is set correctly.

# Additional info:
OpenShift virt by default uses cloudInitNoCloud, but this get's changed to cloudInitConfigDrive when configuring the SSH keys. When looking at the documentation of using Config drive, I could not find any information related to network configuration (https://cloudinit.readthedocs.io/en/latest/reference/datasources/configdrive.html ). Maybe the issue is related to that.

Using cloudInitNoCloud rather than cloudInitConfigDrive and pasting the SSH key directly in the userData works for me. However, in this case the (public) SSH key is stored as clear text in the custom resource, rather than stored in a Kubernetes secret .

```                
        - cloudInitNoCloud:
            networkData: |
              network:
                version: 1
                config:
                  - type: physical
                    name: eth0
                    subnets:
                      - type: static
                        address: {{ host'] }}/24
                        gateway: {{ gateway }}
                        dns_nameservers: {{ dns }}
            userData: |
              #cloud-config
              user: cloud-user
              password: cloud-user
              chpasswd:
                expire: false
              hostname: {{ hostname }}
              ssh_authorized_keys:
                - {{ ssh_key }}
```


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