Root Password on Provision Request


#1

Hi guys !

I’m trying to provision an instance from the API.
This is working normally, I can create provision requests, but when I try to set the root password, i’ve problems, how to set it?

On https://github.com/ManageIQ/manageiq_docs/blob/master/api/appendices/provision_attributes.adoc we can see it’s an attribute of Custom Attributes, then i’ve try to set it on ems_custom_attributes and miq_custom_attributes.

This have no effects, the root password wasn’t set.

I think it not the right way, how I can set a root password for a Vm on a provision request?

Thank in advance !


#2

@bdunne Can you please help out here.


#3

Hi @alex-lairan,

What kind of provision are you doing?
If, for example, you are provisioning an Openstack instance and using cloud-init to customize the instance, you will also need to select the cloud-init customization template that you want to use. You can use variables in the customization template to dynamically build the cloud-init based on inputs from the provision request.

Example cloud-init customization template:

chpasswd:
  list: |
    root:<%= MiqPassword.decrypt(evm[:root_password]) %>

Hope that helps,
Brandon


#4

Hi @bdunne,

I’m provisioning an AWS provider.

This is my Request:

{
    "template_fields": {
        "guid": "MYGUID"
    },

    "vm_fields": {
        "vm_name": "foo",
        "instance_type": 1
    },
    "ems_custom_attributes": {
        "root_password":"foo"
    },
    "requester": {
        "owner_first_name": "foo",
        "owner_last_name": "bar",
        "owner_email": "foo@bar.com"
    }
}

This is what is stored on Manageiq

{

    "href": "https://manageiq_url/api/provision_requests/68",
    "id": ​68,
    "description": "Provision from [CentOS Linux 7] to [foo]",
    "approval_state": "pending_approval",
    "type": "MiqProvisionRequest",
    "created_on": "2016-03-08T09:47:43Z",
    "updated_on": "2016-03-08T09:47:52Z",
    "requester_id": ​2,
    "requester_name": "User",
    "request_type": "template",
    "request_state": "pending",
    "message": "Request was not auto-approved for the following reasons: (Requested VMs 1 limit is 0) ",
    "status": "Ok",
    "options": 

{

    "use_pre_dialog": false,
    "request_type": "template",
    "owner_email": "foo@bar.com",
    "miq_request_dialog_name": "miq_provision_amazon_dialogs_template",
    "customize_enabled": 
[

    "disabled"

],
"owner_first_name": "API",
"owner_last_name": "API",
"vm_tags": 
[

    ​62

],
"placement_auto": 
[

    true,
    ​1

],
"placement_availability_zone": 
[

    null,
    null

],
"cloud_network": 
[

    null,
    null

],
"cloud_subnet": 
[

    null,
    null

],
"security_groups": 
[

    null,
    null

],
"floating_ip_address": 
[

    null,
    null

],
"number_of_vms": 
[

    ​1,
    "1"

],
"src_vm_id": 
[

    ​14,
    "CentOS Linux 7"

],
"vm_name": "foo",
"schedule_type": 
[

    "immediately",
    "Immediately on Approval"

],
"schedule_time": "2016-03-09T09:47:43.466+00:00",
"retirement": 
[

    ​0,
    "Indefinite"

],
"retirement_warn": 
[

    ​604800,
    "1 Week"

],
"instance_type": 
[

    ​1,
    "t2.micro: T2 Micro"

],
"guest_access_key_pair": 
[

    null,
    null

],
"monitoring": 
[

    "basic",
    "Basic"

],
"addr_mode": 
[

    "dhcp",
    "DHCP"

],
"src_vm_nics": [ ],
"src_vm_lans": [ ],
"src_ems_id": 

        [
            ​1,
            "LBN_SD_LAB"
        ],
        "auto_approve": false,
        "ws_values": { },
        "ws_ems_custom_attributes": { },
        "ws_miq_custom_attributes": { },
        "requester_group": "EvmGroup-super_administrator"
    },
    "userid": "api",
    "source_id": ​14,
    "source_type": "VmOrTemplate",
    "tenant_id": ​1

}

But when I didn’t see root_password on response nor on UI.

Thank for your help.


#5

@alex-lairan I don’t see any customization template specified, so there will be no cloud-init sent to the provider for the instance being launched.


#6

Thank @bdunne, but what are customization template?

Does it’s ‘additional values’ argument?

"additional_values": {
    "root_password":"foo"
}

Because I don’t see any informations on my provision request.

On https://github.com/ManageIQ/manageiq_docs/blob/master/api/reference/provision_requests.adoc we don’t have informations for root_password, how can I set it?

Here ( https://github.com/ManageIQ/manageiq_docs/blob/master/api/appendices/provision_attributes.adoc ) we can see it’s a Custom Attributes

Thank in advance !


#7

@alex-lairan You can find customization templates under Infrastructure / PXE. @alongoldboim is adding an example script for cloud-init in this PR. You should be able to see this if you try provisioning using the dialogs.


#8

Hello @bdunne

How can I provide a provision dialogs with credentials on an provision request?

I don’t understand why you tell me to find customization templates under Infrastructure / PXE.

Azure and Amazon have different credentials fields.

Thanks for your answer !


#9

@alex-lairan,

Does Amazon EC2 allow to set root password of a VM while provisioning? I guess, it work based on keys, right?