rackspace / gophercloud

A Go SDK for OpenStack. IN FEATURE FREEZE. See Issue #592
http://gophercloud.io
Other
456 stars 185 forks source link

UserData does not work without ConfigDrive in the Rackspace cloud #641

Open gislifreyr opened 6 years ago

gislifreyr commented 6 years ago

For the UserData option to work, when creating a server in the RackSpace cloud, the ConfigDrive option has to be set to 'true'.

This does not work:

userData := `#cloud-config

    runcmd:
     - touch /root/testing`

server, err := servers.Create(client, servers.CreateOpts{
        Name: "test",
        ImageRef: image,
        FlavorRef: flavor,
        UserData: []byte(userData),
    }).Extract()

This works:

userData := `#cloud-config

    runcmd:
     - touch /root/testing`

server, err := servers.Create(client, servers.CreateOpts{
        Name: "test",
        ImageRef: image,
        FlavorRef: flavor,
        UserData: []byte(userData),
        ConfigDrive: true,
    }).Extract()

Possibly it should be checking if UserData is set and then setting ConfigDrive to true if it is.