metalsmith.instance_config module¶
- class metalsmith.instance_config.CloudInitConfig(ssh_keys=None, user_data=None, meta_data=None)¶
Bases:
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 cloud-config data as a dictionary.
meta_data – Dict of data to add to the generated
meta_data
- 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, meta_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.
meta_data – Dict of data to add to the generated
meta_data
- generate(node, hostname=None, network_data=None)¶
Generate the config drive information.
- Parameters:
node – Node object.
hostname – Desired hostname (defaults to node’s name or ID).
network_data – Network metadata as dictionary
- Returns:
configdrive contents as a dictionary with keys:
meta_data
meta data dictionary
network_data
network data as 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.