oO.o's Ansible Host Collection (Formerly Devember 2022)

Alpha 4 is up which adds the users role. On first run, it will dump a users dictionary into each host’s host_vars file which is configurable. You can also simply supply something like this:

users:
  my_admin:
    adm: true
    lock: true

Which will set up my_admin with passwordless admin privileges and your SSH key. Note that this would also delete any non-system users except the current Ansible user. To preserve the current user state, run the role without supplying a users dictionary and then edit what shows up in the inventory.

Here is an example of what the users dictionary looks like after an initial run on a Debian Vagrant VM.

# BEGIN ANSIBLE MANAGED BLOCK: Local users (Editable)
users:
  root:
    gecos: root
    group: root
    groups:
    - root
    home: /root
    shell: /bin/bash
    ssh:
      auth: []
      id: []
    uid: '0'
  vagrant:
    adm: true
    gecos: vagrant,,,
    group: vagrant
    groups:
    - audio
    - cdrom
    - dip
    - floppy
    - netdev
    - plugdev
    - vagrant
    - video
    home: /home/vagrant
    shell: /bin/bash
    ssh:
      auth:
      - pub: AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
        type: rsa
      id: []
    uid: '1000'
# END ANSIBLE MANAGED BLOCK: Local users (Editable)

Support for RouterOS here was a little rocky, but it works. Of course there is much less to configure for RouterOS users, but administration and authorized SSH keys are handled.