{% load i18n %}

<p class="text-right">
    <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
      Cloud-init options
    </a>
</p>
<div class="collapse" id="collapseExample">
    <div class="card card-body">
      <b> {% trans "Use Jinja2 template syntax, values: " %}</b>
      <ul>
        <li><code>hostname</code> - {% trans "vm hostname" %}</li>
        <li><code>sysuser</code>  - {% trans "vm system default user (cloud)" %}</li>
        <li><code>password</code> - {% trans "default user password (use 'hash' filter to convert sha512)" %}</li>
        <li><code>owner</code>    - {% trans "vm owner django username" %}</li>
        <li><code>acl.allusers</code> - {% trans "get all associated user's username to vm (list)" %}</li>
        <li><code>acl.operators</code> - {% trans "get all associated operator level user's username to vm (list)" %}</li>
        <li><code>acl.users</code> - {% trans "get all associated user level user's username to vm (list)" %}</li>
        <li><code>net.ipv4</code> - {% trans "default host ip address" %}</li>
        <li><code>net.ipv6</code> - {% trans "default host ipv6 address" %}</li>
        <li><code>net.vlans</code> - {% trans "associated vlans: list of objects (name: vlan name, ipv4/ipv6: host ip in vlan)" %}</li>
        <li><code>ssh.keys</code> - {% trans "owner's ssh-keys dictionary: the key is the ssh-key's name" %}</li>
        <li><code>ci.rndstr(len: int)</code> - {% trans "function: make random string with 'len' charachters lenght" %}</li>
        <li><code>ci.loadjson(url: str)</code> - {% trans "load json object from remote url" %}</li>
       </ul> 
       <p>{% trans "Filters: hash - sha512 hash method" %}</p>
       <p>{% trans "Use this commands, to clean cloud-init setup (for save as template example):" %}</p>
       <pre>
cloud-init clean
userdel -p -f cloud   # delete default user</pre>
      <b>Example:</b>
     <pre>{% verbatim %}
#cloud-config
users:
  - default
  - name: {{sysuser}} 
    sudo: ['ALL=(ALL) NOPASSWD:ALL']
    groups: sudo
    shell: /bin/bash
    ssh_pwauth: True
    chpasswd: { expire: False }
    lock-passwd: false
    passwd: "{{ password | hash }}"
    ssh_authorized_keys:
      - {{ ssh.keys['my-key'] }}
{% for u in acl.operators %}
  - name: {{u}} 
    shell: /bin/bash
{% endfor %}
{% endverbatim %}</pre> 
    </div>
</div>