#cloud-config
#password: fedora
#chpasswd: {expire: False}
#ssh_pwauth: True
ssh_authorized_keys:
  - "{% if pubkey_remote.stdout is defined %}{{ pubkey_remote['stdout'] }}{% else %}{{ pubkey_local['stdout'] }}{% endif %}"

# Add users to the system. Users are added after groups are added.
{% if 'cloud_config' in res_def %}
users:
{% for item in res_def['cloud_config']['users'] %}
  - name: {{ item['name'] | default('admin') }}
    gecos: {{ item['gecos'] | default('Admin User') }}
    groups: {{ item['groups'] | default('wheel') }}
    sudo: {{ item['sudo'] | default('ALL=(ALL) NOPASSWD:ALL')}}
    ssh_import_id: {{ item['ssh_import_id'] | default('None') }}
    lock_passwd: {{ item['lock_passwd'] | default('true') }}
    ssh-authorized-keys:
      - {% if pubkey_remote.stdout is defined %}{{ pubkey_remote['stdout'] }}{% else %}{{ pubkey_local['stdout'] }}{% endif %}
{% endfor %}
{% endif %}

timezone: UTC

runcmd:
{% if res_def['cloud_config']['run_commands'] is defined %}
{% for item in res_def['cloud_config']['run_commands'] %}
 - {{ item }}
{% endfor %}
{% endif %}
 - systemctl disable cloud-init.service
 - systemctl disable cloud-init-local.service
 - systemctl disable cloud-final.service
 - systemctl disable cloud-config.service
 - poweroff
