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

27 lines
748 B
Django/Jinja

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