Files
Ansible-Bootstrap/roles/virtualization/templates/cloud-user-data.yml.j2

23 lines
628 B
Django/Jinja

#cloud-config
hostname: "{{ hostname }}"
ssh_pwauth: true
package_update: false
package_upgrade: false
users:
{% for user in system_cfg.users %}
- name: "{{ user.name }}"
primary_group: "{{ user.name }}"
groups: users
{% if user.sudo | default(false) | bool %}
sudo: "ALL=(ALL) NOPASSWD:ALL"
{% endif %}
passwd: "{{ user.password | password_hash('sha512') }}"
lock_passwd: false
{% if 'keys' in user and user['keys'] is iterable and user['keys'] is not string and user['keys'] | length > 0 %}
ssh_authorized_keys:
{% for key in user['keys'] %}
- "{{ key }}"
{% endfor %}
{% endif %}
{% endfor %}