metalsmith.instance_config module

class metalsmith.instance_config.CloudInitConfig(ssh_keys=None, user_data=None)

Bases: metalsmith.instance_config.GenericConfig

Configuration of the target instance using cloud-init.

Compared to GenericConfig, this adds support for managing users.

Variables
  • ssh_keys – List of SSH public keys.

  • user_data – Cloud-init script as a dictionary.

  • users – Users to add on first boot.

add_user(name, admin=True, password_hash=None, sudo=False, **kwargs)

Add a user to be created on first boot.

Parameters
  • name – user name.

  • admin – whether to add the user to the admin group (wheel).

  • password_hash – user password hash, if password authentication is expected.

  • sudo – whether to allow the user sudo without password.

  • kwargs – other arguments to pass.

populate_user_data()

Get user data for this configuration.

Takes the custom user data and appends requested users to it.

Returns

user data as a string.

class metalsmith.instance_config.GenericConfig(ssh_keys=None, user_data=None)

Bases: object

Configuration of the target instance.

The information attached to this object will be passed via a configdrive to the instance’s first boot script (e.g. cloud-init).

This class represents generic configuration compatible with most first-boot implementations. Use CloudInitConfig for features specific to cloud-init.

Variables
  • ssh_keys – List of SSH public keys.

  • user_data – User data as a string.

generate(node, hostname=None)

Generate the config drive information.

Parameters
  • nodeNode object.

  • hostname – Desired hostname (defaults to node’s name or ID).

Returns

configdrive contents as a dictionary with keys:

meta_data

meta data dictionary

user_data

user data as a string

populate_user_data()

Get user data for this configuration.

Can be overridden to provide additional features.

Returns

user data as a string.