{"id":60,"date":"2021-10-05T20:59:00","date_gmt":"2021-10-05T20:59:00","guid":{"rendered":"https:\/\/172.105.20.94\/?p=60"},"modified":"2022-12-04T18:45:30","modified_gmt":"2022-12-05T02:45:30","slug":"use-ansible-to-automatically-insert-cme-configuration-on-cme-routers","status":"publish","type":"post","link":"https:\/\/tungle.ca\/?p=60","title":{"rendered":"Use Ansible to automatically insert CME configuration on CME Routers"},"content":{"rendered":"\n<p>+ Step #1<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install Ubuntu version to work with SSHv2 and ansible 2.9.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"215\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-42-1024x215.png\" alt=\"\" class=\"wp-image-61\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-42-1024x215.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-42-300x63.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-42-768x161.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-42.png 1039w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Test SSH connection on both CME Routers<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"919\" height=\"413\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-43.png\" alt=\"\" class=\"wp-image-62\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-43.png 919w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-43-300x135.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-43-768x345.png 768w\" sizes=\"auto, (max-width: 919px) 100vw, 919px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check the configuration on R2\/R3.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"798\" height=\"531\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-44.png\" alt=\"\" class=\"wp-image-63\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-44.png 798w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-44-300x200.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-44-768x511.png 768w\" sizes=\"auto, (max-width: 798px) 100vw, 798px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>R3 does not have any CIPC registered directory number.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"775\" height=\"532\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-45.png\" alt=\"\" class=\"wp-image-64\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-45.png 775w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-45-300x206.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-45-768x527.png 768w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/figure>\n\n\n\n<p>+ Step #2:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create ansible.cfg, hosts file and ansible yaml file to insert configuration on R3<\/li>\n<\/ul>\n\n\n\n<p style=\"line-height:1\">tung@tung-VirtualBox:~\/Documents\/Ansible$ cat tung.yml<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">---\n\n- name: Manage Cisco Router CME devices\n\n&nbsp; hosts: r1\n\n&nbsp; gather_facts: false\n\n&nbsp; connection: local\n\n&nbsp; vars:\n\n&nbsp;&nbsp;&nbsp; cli:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; username: admin\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password: cisco\n\n&nbsp; tasks:\n\n&nbsp;&nbsp;&nbsp; - name: Configure Ephone-dn on R2\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ios_config:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; provider: \"{{ cli }}\"\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorize: yes\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parents: ephone-dn&nbsp; 1\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lines:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - number 1111\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - name tungle1-1111\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - hold-alert 30 originator\n\n&nbsp;&nbsp;&nbsp; - name: Configure Ephone-dn on R2\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ios_config:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; provider: \"{{ cli }}\"\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorize: yes\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parents: ephone-dn&nbsp; 2\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lines:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - number 1112\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - name tungle1-1112\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - hold-alert 30 originator\n\n&nbsp;&nbsp;&nbsp; - name: Configure Ephone number on R2\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ios_config:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; provider: \"{{ cli }}\"\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorize: yes\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parents: ephone&nbsp; 1\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lines:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - mac-address 0800.AAAA.28C0\n\n&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- username \"tungle1-1111\" password Pa$$w0rd\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - type CIPC\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - button&nbsp; 1:1\n\n&nbsp;&nbsp;&nbsp; - name: Configure Ephone number on R2\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ios_config:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; provider: \"{{ cli }}\"\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authorize: yes\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; parents: ephone&nbsp; 2\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lines:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - mac-address 0800.BBBB.1234\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - username \"tungle1-1112\" password Pa$$w0rd\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - type CIPC\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - button&nbsp; 1:2\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; register: print_output -&nbsp; debug: var=print_output<\/code><\/pre>\n\n\n\n<p style=\"line-height:1\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"966\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-46-1024x966.png\" alt=\"\" class=\"wp-image-65\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-46-1024x966.png 1024w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-46-300x283.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-46-768x724.png 768w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-46.png 1039w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>tung@tung-VirtualBox:~\/Documents\/Ansible$ cat ansible.cfg<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"yaml\" class=\"language-yaml\">[defaults]\n\ninventory = .\/hosts\n\nhost_key_checking = false\n\ndeprecation_warnings=False\n\ntimeout = 5<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"897\" height=\"231\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-47.png\" alt=\"\" class=\"wp-image-66\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-47.png 897w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-47-300x77.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-47-768x198.png 768w\" sizes=\"auto, (max-width: 897px) 100vw, 897px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"148\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-48.png\" alt=\"\" class=\"wp-image-67\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-48.png 895w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-48-300x50.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-48-768x127.png 768w\" sizes=\"auto, (max-width: 895px) 100vw, 895px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Run ansible-playbook<\/li>\n<\/ul>\n\n\n\n<p style=\"line-height:1\">tung@tung-VirtualBox:~\/Documents\/Ansible$ ansible-playbook tung.yml<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"747\" height=\"756\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-49.png\" alt=\"\" class=\"wp-image-68\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-49.png 747w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-49-296x300.png 296w\" sizes=\"auto, (max-width: 747px) 100vw, 747px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Check on CME Router<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"560\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-50.png\" alt=\"\" class=\"wp-image-69\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-50.png 757w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-50-300x222.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>CIPCs have been registered successfully via Ansible<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"616\" src=\"https:\/\/172.105.20.94\/wp-content\/uploads\/2021\/12\/image-51.png\" alt=\"\" class=\"wp-image-70\" srcset=\"https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-51.png 770w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-51-300x240.png 300w, https:\/\/tungle.ca\/wp-content\/uploads\/2021\/12\/image-51-768x614.png 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>+ Step #1 + Step #2: tung@tung-VirtualBox:~\/Documents\/Ansible$ cat tung.yml tung@tung-VirtualBox:~\/Documents\/Ansible$ cat ansible.cfg tung@tung-VirtualBox:~\/Documents\/Ansible$ ansible-playbook tung.yml<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2],"tags":[15],"class_list":["post-60","post","type-post","status-publish","format-standard","hentry","category-ansible","category-cisco-voice","tag-cisco"],"_links":{"self":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts\/60","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=60"}],"version-history":[{"count":6,"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions"}],"predecessor-version":[{"id":4419,"href":"https:\/\/tungle.ca\/index.php?rest_route=\/wp\/v2\/posts\/60\/revisions\/4419"}],"wp:attachment":[{"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=60"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=60"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tungle.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=60"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}