- Network Automation Cookbook
- Karim Okasha
- 145字
- 2025-04-04 13:10:14
How it works...
Ansible provides declarative modules to configure various system-level parameters on Juniper devices. The junos_system Ansible module enables us to set up the hostname and the DNS servers on the Juniper devices. The junos_user module provides us with the ability to set up the basic parameters for the system users on a Juniper device. In this example, we set up all the users who have SSH keys as their authentication method, and we loop over the users data structure and select only the users with the SSH_key option defined.
Once we run this playbook, we can see that the configuration on the devices is updated, as shown in the following code block:
$ Ansible@mxpe01# show system
host-name mxpe01;
}
name-server {
172.20.1.1;
172.20.1.15;
}
login {
user admin {
uid 2001;
class super-user;
authentication {
SSH-rsa "SSH-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0/wvdC5ycAanRorlfMYDMAv5OTcYAALlE2bdboajsQPQNEw1Li3N0J50OJBWXX+FFQuF7JKpM32vNQjQN7BgyaBWQGxv+Nj0ViVP+8X8Wuif0m6bFxBYSaPbIbGogDjPu4qU90Iv48NGOZpcPLqZthtuN7yZKPshX/0YJtXd2quUsVhzVpJnncXZMb4DZQeOin7+JVRRrDz6KP6meIylf35mhG3CV5VqpoMjYTzkDiHwIrFWVMydd4C77RQu27N2HozUtZgJy9KD8qIJYVdP6skzvp49IdInwhjOA+CugFQuhYhHSoQxRxpws5RZlvrN7/0h0Ahc3OwHaUWD+P7lz Ansible@centos7.localdomain"; ## SECRET-DATA
}
}