API : Creating and managinf MAchine

I am trying to manage MAAS with Ansible by uri module : GET/POST.
I know there is a maas cli ou Maas libraries available but they are not realy usefull to automation . and My team would like to own our solution really simply .

We find the way to create a machine

  • name: POST create machine
    url: “http://xx.xx.xx.xx:5240/MAAS/api/2.0/machines/
    method: POST
    body_format: json
    body: “{{ lookup(‘file’,‘machine_create.json’) }}”
    Authorization: OAuth oauth_consumer_key=“xxxxx”,oauth_token=“xxxxx”,oauth_signature_method=“PLAINTEXT”,oauth_timestamp=“1952448470”,oauth_nonce="{{ nonce_value }}",oauth_version=“1.0”,oauth_signature="%26xxxxxx"
    Content-Type: “application/json”
    use_proxy: no

here the json : machine_create.json
“architecture”: “amd64/generic”,
“mac_addresses”: “14:18:77:6b:00:00”,
“domain”: “maas”,
“pool”: “Project1”,
“hostname”: “maxou-srv02”,
“power_type”: “redfish”,
“power_parameters_power_user”: “USER”,
“power_parameters_power_pass”: “PASS”,
“skip_networking”: “False”,
“commission”: “False”,
“zone”: “eu-west-0-a”,

The machine is create , but we don t find the way to assign in network part of the machine the Fabric and the dhcp mode .

Network ›

Name MAC Link speed Fabric DHCP SR-IOV
eth0 14:18:77:6b:00:00 0 Mbps Unknown No DHCP No

The APi documentation dont help so much, we see that most of the solution is to use a module or the MAASCLI, but we don t want this. in our environment , and for automation is not really the best way.
On internet we don t found so much exemple or people who try this with API… ( ok perhaps there is a good reason and people use maas cli or personnel python development…)


1 Like