Skip to content

network-automate/microservice-junos-deployer

Repository files navigation

Microservice to push configuration to Junos device.

Description

This microservice provides mechanism to deploy configuration to Junos Devices. These configuration files must be generated by any 3rd part solution and will be consume by this container.

Docker image: jnprautomate/junos-deployer

Basic usage

# Pull image from docker
% docker pull jnprautomate/junos-deployer

# Create folder structure
% mkdir {inputs,configs,diffs}

# make inventory for ansible
vim inputs/inventory.ini

% docker run -it --rm \
	-v ${PWD}/inputs:/inventory \
	-v ${PWD}/diffs:/outputs \
	-v ${PWD}/configs:/config \
	jnprautomate/junos-deployer:latest

Data management:

Inputs

  • Ansible Inventory file (inventory.ini) with following elements:
    • ansible_host: IP of the device
    • netconf_port: netconf port uses to connect to devices (default is 830)
    • ansible_ssh_private_key: Private key to use to authenticate against devices (Optional)
    • ansible_ssh_user: Username to use for the connection
    • ansible_ssh_pass: Password to use for the connection (Optional if private key is configured)
  • commit_mode: define how configuration management is. done: merge or replace (optional)
  • Configuration folder where all configuration files are stored with this syntax: {{inventory_hostname}}.conf

Outputs

  • Configuration diff for every devices: One file per device (Optional)

Volumes to mount

  • inventory: Folder where inventory file is located
  • config: Folder where all the configuration files are located
  • outputs: Optional folder to get access to all diff when configuration are committed.

Output example

Below is an example of how to use this container

  • Display inventory
evpn-microservice ᐅ cat inventory/inventory.ini

[demo]
demo-qfx10k2-14    ansible_host=172.25.90.67
demo-qfx10k2-15    ansible_host=172.25.90.68

[demo:vars]
netconf_port=830
ansible_ssh_user=ansible
ansible_ssh_pass=juniper123
ansible_ssh_private_key = "~/.ssh/id_lab_gsbt"
commit_mode="merge"
  • Display list of configs
evpn-microservice ᐅ tree -L 2
.
├── configs/
│   ├── demo-qfx10k2-14.conf
│   ├── demo-qfx10k2-15.conf
├── diffs/
└── inputs/
    ├── inventory.ini
  • Run container to deploy configuration
evpn-microservice ᐅ docker run -it --rm \
	-v ${PWD}/inputs:/inventory \
	-v ${PWD}/diffs:/outputs \
	-v ${PWD}/configs:/config \
	jnprautomate/junos-deployer:latest
	
Deploy configuration to Junos devices
  > Check inventory file
  > Inventory file found (inputs/inventory.ini)
  > Deploy configurations to devices

PLAY [Deploy configuration] *******************************************************************************************

TASK [include_vars] ***************************************************************************************************
ok: [demo-qfx10k2-14]
ok: [demo-qfx10k2-15]

TASK [config-deploy-core : Commit Configuration to devices] ***********************************************************
changed: [demo-qfx10k2-14]
changed: [demo-qfx10k2-15]

PLAY RECAP ************************************************************************************************************
demo-qfx10k2-14            : ok=2    changed=1    unreachable=0    failed=0
demo-qfx10k2-15            : ok=2    changed=1    unreachable=0    failed=0
  • Get list of changes for a given device
evpn-microservice ᐅ cat diffs/demo-qfx10k2-14-diff.log

[edit protocols bgp group underlay]
-    authentication-key "$9$hc1cylKM8N-VtuMXNboajHq.QnEhreMX1Rylv8dVoJGDi.Tz3p0Ik.hrKv7NJGDHqf5Qn9tO36RSreXxVwY24ZzF/CpB.P39tOIR"; ## SECRET-DATA
+    authentication-key "$9$ez0KM8X7-sYg1R7Vs4DjmfTQ/tleWL7VSrM8x-2gDik.PQ69AIEy5QeWXxwsik.fT3n/t01hAprvWLVbgoJZUH9CuOIcQFA01hyr"; ## SECRET-DATA
  • Display all files
evpn-microservice ᐅ tree -L 2
.
├── configs/
│   ├── demo-qfx10k2-14.conf
│   ├── demo-qfx10k2-15.conf
├── diffs/
│   ├── demo-qfx10k2-14-diff.log
│   ├── demo-qfx10k2-15-diff.log
└── inputs/
    ├── inventory.ini