Accessing the metadata API?

Scott Moser scott.moser at
Wed Feb 1 18:54:42 UTC 2017

On Wed, 1 Feb 2017, Jim Tilander wrote:

> Hi,
> Is there some up to date information on how to access the metadata API?
> This seems woefully out of date and also incorrect:
> <>

Its actually still valid to my knowledge.  That is the api of information
available to nodes.  It just hasn't needed fixing since initially

> Looking at the apache access logs, there are different paths that are begin accessed.
> * Is there a stable API endpoint that one can call during deployment scripts?
> * Can one call the metadata API post deployment?
> * How are the nodes supposed to authenticate? I keep getting Forbidden replies.

A node will have credentials written into /etc/cloud/cloud.cfg.d/

$ ls /etc/cloud/cloud.cfg.d/*maas*

Cloud-init reads that information and has a small 'main' included to
demonstrate reading from it.  You may find that usefull in just poking
around.  I pulled trunk cloud-init as some changes have recently gone in
to make it more usable, but you could run it from the installed cloud-init
as well.

$ sudo cat /etc/cloud/cloud.cfg.d/90_dpkg_maas.cfg
# written by cloud-init debian package per preseed entries
# cloud-init/{maas-metadata-url,/maas-metadata-credentials}
  MAAS: {consumer_key: xxxxxxxxxxxxxxxxxx,
         metadata_url: '',
         token_key: xxxxxxxxxxxxxxxxxx,
         token_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}

$ git clone
$ cd cloud-init
$ python3 -m cloudinit.sources.DataSourceMAAS --help
usage: [-h] [--config file] [--ckey key] [--tkey key]
                         [--csec secret] [--tsec secret] [--apiver
                         {crawl,get,check-seed} ...

Interact with MAAS DS

optional arguments:
  -h, --help            show this help message and exit
  --config file         specify DS config file
  --ckey key            the consumer key to auth with
  --tkey key            the token key to auth with
  --csec secret         the consumer secret (likely '')
  --tsec secret         the token secret to auth with
  --apiver version      the apiver to use ( can be used)

    crawl               crawl the datasource
    get                 do a single GET of provided url
    check-seed          read and verify seed at url

$ sudo python3 -m cloudinit.sources.DataSourceMAAS check-seed
Used config in /etc/cloud/cloud.cfg.d/90_dpkg_maas.cfg.
Checking seed at
=== user-data ===
=== meta-data ===
{'instance-id': 'node-5f084de2-e92a-11e4-a5ac-00163e5b6994',
 'local-hostname': 'myname.maas',
 'public-keys': 'ssh-rsa AAAAB3Nza....HD smoser at host\n'}
=== vendor-data ===

More information about the Maas-devel mailing list