Need help with cloud init

Hi all,

I am new to this field. I am trying to install ansible, clone the git repo which holds a
playbook and run the playbooks through cloud-init user data script on ubuntu host deploy through maas. I also want to know how I can automate the API calls for a new machine provisioning.

It would be great if someone could provide a raw yml script to understand the process.

Thank you!

Hi,

  1. the usual way to run a playbook is during deployment is through curtin. Any reason for doing it through cloud-init?
  2. the CLI is just a wrapper for the MAAS REST API, so any operation you can do through the CLI can be automated by an external agent calling the API.

You can use curtin write_files to write your script to a file in the host, and then use late_commands to execute this script.

write_files:
  bash_script:
    path: /root/script.sh
    content: |
      #!/bin/bash
      echo blabla
      ... very long bash script
    permissions: '0755'

late_commands:
  00-cmd: ["curtin", "in-target", "--", "/bin/bash", "/root/script.sh"]

see https://maas.io/docs/snap/3.0/ui/custom-machine-setup#heading--curtin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.