40 lines
1.2 KiB
YAML
40 lines
1.2 KiB
YAML
|
---
|
||
|
- hosts: router
|
||
|
name: Configure users on router
|
||
|
connection: network_cli
|
||
|
gather_facts: false
|
||
|
vars:
|
||
|
ansible_network_os: edgeos
|
||
|
tasks:
|
||
|
- import_tasks: tasks/users-preprocessing.yml
|
||
|
|
||
|
- name: Create users
|
||
|
edgeos_config:
|
||
|
lines:
|
||
|
- set system login user {{ item.name }} authentication encrypted-password "{{ item.password }}"
|
||
|
- set system login user {{ item.name }} full-name "{{ item.fullname if item.fullname is defined else "" }}"
|
||
|
- set system login user {{ item.name }} level {{ 'operator' if item.name != 'ansible' else 'admin' }}
|
||
|
with_items:
|
||
|
- "{{ local_users | difference([None]) }}"
|
||
|
|
||
|
- name: Grant administrative access to admin users
|
||
|
edgeos_config:
|
||
|
lines:
|
||
|
- set system login user {{ item.name }} level admin
|
||
|
with_items:
|
||
|
- "{{ local_admin_users | difference([None]) }}"
|
||
|
|
||
|
- name: Assemble loadkey files
|
||
|
copy:
|
||
|
src: keys/{{ item }}
|
||
|
dest: /tmp
|
||
|
with_items:
|
||
|
- "{{ local_admin_users | difference([None]) }}"
|
||
|
|
||
|
- name: Load keys
|
||
|
edgeos_config:
|
||
|
lines:
|
||
|
- loadkey {{ item }} /tmp/{{ item }}/*.pub
|
||
|
with_items:
|
||
|
- "{{ local_admin_users | difference([None]) }}"
|