import yaml


def _instance_user_data(hostname, otp, instance_vars):
    """Return instance user data (common instance vars + hostname and otp)."""

    key_value_pairs = instance_vars.copy()
    key_value_pairs['hostname'] = hostname
    key_value_pairs['otp'] = otp

    return "#cloud-config\n" + yaml.dump(
        key_value_pairs, default_flow_style=False, default_style='\''
    )