diff --git a/ansible.cfg b/ansible.cfg index b834221..d2d1dbf 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,8 +1,8 @@ [defaults] roles_path = /srv/ansible/roles host_key_checking = False -library = /srv/ansible/lib/python3.5/site-packages/napalm_ansible-0.9.1-py3.5.egg/napalm_ansible/modules -action_plugins = /srv/ansible/lib/python3.5/site-packages/napalm_ansible-0.9.1-py3.5.egg/napalm_ansible/plugins/action +library = /srv/nslab-ansible/local/lib/python2.7/site-packages/napalm_ansible/modules +action_plugins = /srv/nslab-ansible/local/lib/python2.7/site-packages/napalm_ansible/plugins/action [persistent_connection] command_timeout=100 diff --git a/core-deploy.retry b/core-deploy.retry index 6a0dc6c..11a615c 100644 --- a/core-deploy.retry +++ b/core-deploy.retry @@ -1,4 +1,3 @@ ansible-vmx1 ansible-vmx2 ansible-vmx3 -ansible-vmx4 diff --git a/core-deploy.yml b/core-deploy.yml index afd379b..4511099 100644 --- a/core-deploy.yml +++ b/core-deploy.yml @@ -13,11 +13,18 @@ ## Second Play - name: Generate Configuration for all routers gather_facts: no - connection: local +# connection: local hosts: all tags: [ template ] tasks: - include_vars: "./nodes.yml" + - name: Get facts for napalm_os_version + napalm_get_facts: + hostname: "{{ ansible_host }}" + username: "{{ ansible_user }}" + dev_os: "{{ ansible_network_os }}" + optional_args: + key_file: "{{ ansible_ssh_private_key_file }}" - name: create the directory for the configuration file: path=core_config state=directory run_once: true @@ -46,5 +53,6 @@ key_file: "{{ ansible_ssh_private_key_file }}" config_file: core_config/{{inventory_hostname}}-config.txt commit_changes: "{{commit}}" + replace_config: "{{replace_config|default('0')}}" diff_file: diff/{{inventory_hostname}}-diff.txt when: "inventory_hostname in nodes.keys()" diff --git a/core_config/ansible-vmx1-config.txt b/core_config/ansible-vmx1-config.txt index ace1a00..4fff368 100644 --- a/core_config/ansible-vmx1-config.txt +++ b/core_config/ansible-vmx1-config.txt @@ -1,4 +1,5 @@ +version 15.1F6.9 system { host-name ansible-vmx1; no-redirects; @@ -75,7 +76,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.41/24; + address 10.39.0.41/20; } } } diff --git a/core_config/ansible-vmx2-config.txt b/core_config/ansible-vmx2-config.txt index a97bbea..d99a813 100644 --- a/core_config/ansible-vmx2-config.txt +++ b/core_config/ansible-vmx2-config.txt @@ -1,4 +1,5 @@ +version 15.1F6.9 system { host-name ansible-vmx2; no-redirects; @@ -62,7 +63,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.42/24; + address 10.39.0.42/20; } } } diff --git a/core_config/ansible-vmx3-config.txt b/core_config/ansible-vmx3-config.txt index ab9aab3..075dad4 100644 --- a/core_config/ansible-vmx3-config.txt +++ b/core_config/ansible-vmx3-config.txt @@ -1,4 +1,5 @@ +version 15.1F6.9 system { host-name ansible-vmx3; no-redirects; @@ -62,7 +63,7 @@ interfaces { description "OOB to MGMT Network"; unit 0 { family inet { - address 10.39.0.43/24; + address 10.39.0.43/20; } } } diff --git a/core_config/ansible-vmx4-config.txt b/core_config/ansible-vmx4-config.txt deleted file mode 100644 index 585c52a..0000000 --- a/core_config/ansible-vmx4-config.txt +++ /dev/null @@ -1,136 +0,0 @@ - -system { - host-name ansible-vmx4; - no-redirects; - root-authentication { - encrypted-password "$5$mcE0Hfiq$JfBeC3QSAvnd1tjqlOhlYXDgVrwvd6S4G3oVj5wiMO7"; ## SECRET-DATA - } - login { - user salt { - uid 2001; - class super-user; - authentication { - encrypted-password "$5$yp7ziGTI$F5F.6AUlR8hDK2JIsw5WRrTLex/yTCWH3iSR1Auk293"; ## SECRET-DATA - ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCjxY2hLZ+ju5wdK4GYNhKGgnS8EWLBoEVpo+xQkhDzkTiBx3HGAnmARcVV0B9MqrHZl1omdnirJeygWzVbVY4yPUqGgEcUsTTq9fvK4AjTwtaoB5txAosaOnZq0zewmuZ6EMi6E3RND6A3FGXkf1Il2jg3I8k/dGqdyFI80B7sWy90fk+EqsGMPxVc+l5vAtY2jm84ellxxzBsulxfCSKPH86hZ1GqZ8A1ZBWITu15NjQw0aGssSYGMMTa1T8eFyY4hHWqqdwgOlODg9mZwwP1JdJH79SRoTOjqGGixuAFDGAgH3fNX6u8wTmYya/z7WXH6B2XwiiaZYdcyEbMLPZt"; ## SECRET-DATA - } - } - } - services { - ssh; - netconf { - ssh; - traceoptions { - file nc.txt size 1m world-readable; - flag incoming; - } - } - } - syslog { - user * { - any emergency; - } - file messages { - any any; - authorization info; - } - file interactive-commands { - interactive-commands any; - } - } -} - -interfaces { - ge-0/0/0 { - description "ansible-vmx1" - vlan-tagging; - encapsulation flexible-ethernet-services; - unit 40 { - vlan-id 40; - family inet { - address 172.10.14.4/24 - } - family mpls; - } - } - - fxp0 { - description "OOB to MGMT Network"; - unit 0 { - family inet { - address 10.39.0.44/24; - } - } - } - lo0 { - unit 0 { - family inet { - address 10.39.8.44/32; - } - } - } -} -routing-options { - router-id 10.39.8.44; - autonomous-system 65000; - static { - route 0.0.0.0/0 { - next-hop 10.39.0.1; - no-readvertise; - preference 255; - } - } -} -protocols { - bgp { - group Core { - type internal; - export __Ansible_Core_export; - local-address 10.39.8.44; - family inet { - unicast; - } - family inet-vpn { - unicast; - } - neighbor 10.39.8.41; - } - } - ospf { - area 0 { - interface ge-0/0/0.40 { - interface-type p2p; - metric 10; - } - interface lo0.0 { - passive; - } - } - } - ldp { - interface ge-0/0/0.40; - interface lo0.0; - } - rsvp { - interface ge-0/0/0.40; - } - mpls { - interface ge-0/0/0.40; - } - lldp { - interface ge-0/0/0; - } -} -policy-options { - policy-statement __Ansible_Core_export { - term ebgp { - from { - protocol bgp; - external; - } - then { - next-hop self; - accept; - } - } - } -} diff --git a/diff/ansible-vmx1-diff.txt b/diff/ansible-vmx1-diff.txt new file mode 100644 index 0000000..e69de29 diff --git a/diff/ansible-vmx2-diff.txt b/diff/ansible-vmx2-diff.txt new file mode 100644 index 0000000..e69de29 diff --git a/diff/ansible-vmx3-diff.txt b/diff/ansible-vmx3-diff.txt new file mode 100644 index 0000000..e69de29 diff --git a/facts_napalm.retry b/facts_napalm.retry new file mode 100644 index 0000000..11a615c --- /dev/null +++ b/facts_napalm.retry @@ -0,0 +1,3 @@ +ansible-vmx1 +ansible-vmx2 +ansible-vmx3 diff --git a/facts_napalm.yml b/facts_napalm.yml index 1389b49..0411634 100644 --- a/facts_napalm.yml +++ b/facts_napalm.yml @@ -15,4 +15,5 @@ register: results - name: Display facts - debug: var=results + debug: + var: "napalm_os_version" diff --git a/junos/core.j2 b/junos/core.j2 index 2255b3a..be93459 100644 --- a/junos/core.j2 +++ b/junos/core.j2 @@ -5,6 +5,7 @@ ### System configuration ###### ************************************************** #} +version {{napalm_os_version}} system { host-name {{inventory_hostname}}; no-redirects;