Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »


https://hub.docker.com/r/juniper/pyez-ansible/

Commands:

docker pull juniper/pyez-ansible

docker run -it --rm juniper/pyez-ansible ash


vMX config for ansible + Netconfig

set system login user ansible class super-user
set system login user ansible authentication encrypted-password "$1$rgdhLoHQ$/eV08mYSvYSBsaHbyaPTp/"            ## ansible123
set system services ssh root-login allow
set system services ssh protocol-version v2
set system services netconf ssh

Netconfig Test:

ssh ansible@192.168.56.11 -p 830 -s netconf


Create an directory ( on the windows host )  + and create the hosts and playbook.yml there

jkriker@jkriker-T460 MINGW64 ~/Documents/ansiblescript
$ cd facts_playbook/

jkriker@jkriker-T460 MINGW64 ~/Documents/ansiblescript/facts_playbook
$ ls
hosts playbook.yml


Start the container:

docker run -it --rm -v $PWD:/project juniper/pyez-ansible ash

-it
--rm
-v    $PWD         is the host directory
        :/project    is the container directory


Basic hosts & playbook.yml file:


hosts and playbook.yml
import sys
import json
import yaml
from pprint import pprint
from jnpr.junos import Device
from jnpr.junos.exception import ConnectError

dev = Device(host='192.168.99.11',user='ansible',passwd='ansible123')
try:
    dev.open()
except ConnectError as err:
    print ("Cannot connect to device: {0}".format(err))
    sys.exit(1)

#print("#print everything\n")
#pprint (dev.facts)

#print("\n#print only the version")
#pprint (dev.facts['version'])

print (yaml.dump(dev.facts))

#print (json.dumps(dev.facts))

dev.close()



  • No labels