This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x1 ➜ collection_development ansible-navigator run parse.yml -m stdout --ee false | |
| PLAY [localhost] *************************************************************** | |
| TASK [Define some data] ******************************************************** | |
| ok: [localhost] | |
| TASK [Pass text and template_path] ********************************************* | |
| ok: [localhost] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - hosts: localhost | |
| gather_facts: false | |
| tasks: | |
| - name: Define some data | |
| ansible.builtin.set_fact: | |
| data: | |
| wan: | |
| - name: LAN3 | |
| ipv4-address: 100.100.100.1 | |
| subnet-mask: 255.255.255.248 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - hosts: localhost | |
| gather_facts: false | |
| tasks: | |
| - name: Define some test data | |
| ansible.builtin.set_fact: | |
| values: | |
| - name: a | |
| value: 1 | |
| - name: b | |
| value: 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import itertools | |
| import yaml | |
| # - name: Build the data structure | |
| # set_fact: | |
| # data_sources: | |
| # - data: interfaces.results | |
| # match_key: name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Tests for an interable_equality function.""" | |
| from typing import Iterable | |
| from typing import Generator | |
| def iterable_equality(iterable_one: Iterable, iterable_two: Iterable) -> bool: | |
| """Check the equality of 2 iterables. | |
| Convert both to a list and check length and items. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| from pprint import pprint | |
| str="""Name: toml | |
| Version: 0.10.2 | |
| Summary: Python Library for Tom's Obvious, Minimal Language | |
| Home-page: https://github.com/uiri/toml | |
| Author: William Pearson | |
| Author-email: uiri@xqz.ca | |
| License: MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ Sample runner script | |
| """ | |
| import datetime | |
| import os | |
| from typing import Dict | |
| from typing import List | |
| import ansible_runner | |
| class Ansible: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - name: Generate a random number | |
| ansible.builtin.set_fact: | |
| num: "{{ pick_from | random(start=1) }}" | |
| - name: Set the condition flag | |
| ansible.builtin.set_fact: | |
| condition_met: "{{ num|int == number_to_match }}" | |
| - name: Get out quick when condition is met |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ipaddress | |
| from typing import List | |
| def get_peers(address: str) -> List[str]: | |
| """Return possible peers when given an address""" | |
| addr = ipaddress.ip_interface(address) | |
| hosts = list(addr.network.hosts()) | |
| try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% macro render_neighbors(parent, indent) %} | |
| {% if 'neighbors' in parent %} | |
| {% for neighbor_id, neighbor in parent['neighbors']|sort_by_ip_as_int() %} | |
| {# ############################################## activate #} | |
| {% if 'activate' in neighbor and neighbor['activate'] %} | |
| - "{{indent}}neighbor {{ neighbor['ipv4_address'] }} activate" | |
| {% endif %} | |
| {# ############################################## remote_as #} | |
| {% if 'remote_as' in neighbor %} | |
| - "{{indent}}neighbor {{ neighbor['ipv4_address'] }} remote-as {{ neighbor['remote_as'] }}" |