Is it possible to commission + deploy with a single CLI command?

I’m currently importing a bunch of machines into MAAS, and I’m finding that I’m running a batch of “machines create” commands, then waiting around for them to be ready, then setting them to deploy. It’d be nice to eliminate the “waiting around” step.

Is there a way to run a single command that commissions and then immediately deploys a specified OS if commissioning succeeds?

Thanks.

Hey there,

Nope, that’s not possible.

Thanks. If this post can be easily flipped to a feature request that would be nice. If not, I won’t lose sleep over it.

You could just make a script that does both and call said script. Basically, a wrapper script for maas command.

I suppose I could, yes. It’d have to have the ability to keep track of all the machines that I want to reboot in parallel, and check them each every few seconds to see if the machine has finished turning off before turning it back on. And it would have to translate from hostname ranges to MAAS system IDs to make it as usable as using the web UI (or the rpower command from xCAT, which is what I’m used to). So it’s doable, but we’ll see if I have enough ambition to do it. :slight_smile:

Being able to send a reset or soft reboot command to the power types that are capable of it (e.g. IPMI) seems more straightforward. Hmm… yeah… a script using ipmitool would be much easier to write, and could use the warm and cold reset commands directly, though it’d be more difficult to keep everything secure doing it that way.

You can pull all the info needed (passwords, system names, etc) from maas, so there are no secrets in your script.
Also, you could use things like parallel or xargs (which can run things in parallel) to run things in parallel. Separate workers for each node. The workers end when their task is done.
I often background workers using ‘&’ and then have a wait in the script until they are all done. You can even add timeout wherever/as needed.

For a long time we’ve been calling maas $PROFILE ... commands within our scripts, and we are now starting to migrate to Ansible for a bit more control. Here is some sample code handling the timing of deployments, in our cased called from our rackd machine. I imagine it wouldn’t be too hard to prefix it with commissioning code.

- name: Deploy the host
  delegate_to: localhost
  ansible.builtin.shell: >
    ./scripts/maas-scripts/deploy-machine-maas.sh -n {{ inventory_hostname }} -d {{ maas_distro | default('focal') }}
  when: ( ( commission_status.stdout is defined ) and ( commission_status.stdout == "Ready" ) ) or ( ( ( initial_machine_status.stdout != "Deployed" ) and ( initial_machine_status.stdout != "Deploying" ) ) and ( setup_hosts_skip_provision | bool ) )
  register: deploy_output

- name: "Every 30 seconds for up to 20 minutes, check if the machine has finished deploying"
  delegate_to: localhost
  ansible.builtin.shell: >
    maas {{ lookup('env', 'USER') }} machines read hostname={{ inventory_hostname }} | jq -r '.[].status_name'
  register: deploy_status
  when:
    - initial_machine_status.stdout != "Deployed"
    - deploy_output is defined
  until: deploy_status.stdout == 'Deployed' or deploy_status.stdout == 'Failed deployment'
  retries: 40
  delay: 30
  failed_when: ( deploy_status.stdout == 'Failed deployment' ) or ( deploy_status.stdout == 'Failed commissioning' )