Start coverting the network users playbook to use loops and new key
This commit is contained in:
parent
2b7cb022da
commit
69697ef58c
@ -1,10 +1,8 @@
|
||||
---
|
||||
- hosts: router
|
||||
- hosts: router.net.enp.one
|
||||
name: Configure users on router
|
||||
connection: network_cli
|
||||
gather_facts: false
|
||||
vars:
|
||||
ansible_network_os: edgeos
|
||||
tasks:
|
||||
- import_tasks: tasks/users-preprocessing.yml
|
||||
|
||||
@ -14,8 +12,7 @@
|
||||
- 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]) }}"
|
||||
loop: "{{ local_users | difference([None]) }}"
|
||||
|
||||
- name: Grant administrative access to admin users
|
||||
edgeos_config:
|
||||
@ -25,15 +22,13 @@
|
||||
- "{{ local_admin_users | difference([None]) }}"
|
||||
|
||||
- name: Assemble loadkey files
|
||||
copy:
|
||||
src: keys/{{ item }}
|
||||
dest: /tmp
|
||||
with_items:
|
||||
- "{{ local_admin_users | difference([None]) }}"
|
||||
edgeos_command:
|
||||
commands:
|
||||
- sudo tee "{{ item.sshkeys | join('\n') }}"<<</tmp/{{ item.name }}.keys
|
||||
loop: "{{ local_admin_users | difference([None]) }}"
|
||||
|
||||
- name: Load keys
|
||||
edgeos_config:
|
||||
lines:
|
||||
- loadkey {{ item }} /tmp/{{ item }}/*.pub
|
||||
with_items:
|
||||
- "{{ local_admin_users | difference([None]) }}"
|
||||
- loadkey {{ item }} /tmp/{{ item }}.keys
|
||||
loop: "{{ local_admin_users | difference([None]) }}"
|
||||
|
Reference in New Issue
Block a user