Podcast
Questions and Answers
What is the primary focus of the course 'Automating Networks with Ansible the Right Way'?
What is the primary focus of the course 'Automating Networks with Ansible the Right Way'?
- Fundamentals of Python programming for network engineers.
- System administration tasks using Ansible on Linux-based systems.
- Advanced MPLS configurations and troubleshooting.
- Designing, implementing, operating, and troubleshooting automation solutions in a complex network using Ansible. (correct)
Which of the following is a key difference when using Ansible for network automation compared to system administration?
Which of the following is a key difference when using Ansible for network automation compared to system administration?
- System administration relies heavily on SSH transport, while network automation requires additional connectivity methods.
- Network automation often involves devices without native Python support, requiring module logic to run on the control machine. (correct)
- Ansible is primarily designed for system administration, making it less effective for network automation.
- Network devices always have Python installed locally, simplifying module execution.
In the context of the Globomantics network scenario, what is the main purpose of MPLS VPNs?
In the context of the Globomantics network scenario, what is the main purpose of MPLS VPNs?
- To provide internet access to all Globomantics customers.
- To simplify BGP route exchanges between Globomantics and its customers.
- To eliminate the need for route targets in network configurations.
- To enable multitenancy by keeping customer data separate across geographically dispersed sites. (correct)
How do route targets (RTs) contribute to multitenancy in an MPLS network?
How do route targets (RTs) contribute to multitenancy in an MPLS network?
Which Ansible component is used to define global runtime settings, such as the location of the inventory file and log storage?
Which Ansible component is used to define global runtime settings, such as the location of the inventory file and log storage?
What is the purpose of the Ansible inventory file?
What is the purpose of the Ansible inventory file?
In Ansible, what is a 'playbook'?
In Ansible, what is a 'playbook'?
Within an Ansible playbook, what is the purpose of a 'task'?
Within an Ansible playbook, what is the purpose of a 'task'?
Which variable is used to inform Ansible's SSH logic about the type of network device it is connecting to?
Which variable is used to inform Ansible's SSH logic about the type of network device it is connecting to?
What file format is commonly used for Ansible variable files?
What file format is commonly used for Ansible variable files?
Why is disabling fact gathering a common practice in network-oriented Ansible playbooks?
Why is disabling fact gathering a common practice in network-oriented Ansible playbooks?
What is the benefit of using a playbook-level configuration file instead of the global Ansible configuration file?
What is the benefit of using a playbook-level configuration file instead of the global Ansible configuration file?
What is the primary purpose of 'retry files' in Ansible?
What is the primary purpose of 'retry files' in Ansible?
In Ansible, what is the purpose of the group_vars
folder?
In Ansible, what is the purpose of the group_vars
folder?
What is the function of the register
keyword in an Ansible task?
What is the function of the register
keyword in an Ansible task?
What is the purpose of the debug
module in Ansible?
What is the purpose of the debug
module in Ansible?
In Ansible, what is the purpose of a 'handler'?
In Ansible, what is the purpose of a 'handler'?
What does it mean for an operation to be 'idempotent' in the context of Infrastructure as Code?
What does it mean for an operation to be 'idempotent' in the context of Infrastructure as Code?
What is the primary goal of Infrastructure as Code (IaC)?
What is the primary goal of Infrastructure as Code (IaC)?
What is the purpose of 'version control' in an IaC environment?
What is the purpose of 'version control' in an IaC environment?
What benefit does Infrastructure as Code provide in multi-vendor network environments?
What benefit does Infrastructure as Code provide in multi-vendor network environments?
What is Continuous Integration and Continuous Deployment (CI/CD) in the context of IaC?
What is Continuous Integration and Continuous Deployment (CI/CD) in the context of IaC?
What is a significant business benefit of adopting Infrastructure as Code?
What is a significant business benefit of adopting Infrastructure as Code?
What is the purpose of the host_vars
directory in Ansible?
What is the purpose of the host_vars
directory in Ansible?
What is Jinja2 primarily used for in Ansible?
What is Jinja2 primarily used for in Ansible?
What is the purpose of the notify
keyword in an Ansible task?
What is the purpose of the notify
keyword in an Ansible task?
When using the ios_config
module, what does the save_when: changed
option accomplish?
When using the ios_config
module, what does the save_when: changed
option accomplish?
What is the benefit of using the cli_config
module in Ansible?
What is the benefit of using the cli_config
module in Ansible?
When is it most appropriate to use feature-specific Ansible modules (e.g., ios_vrf
) instead of generic configuration management modules (e.g., ios_config
)?
When is it most appropriate to use feature-specific Ansible modules (e.g., ios_vrf
) instead of generic configuration management modules (e.g., ios_config
)?
Why can removing stale configurations be challenging when using CLI-based Infrastructure as Code solutions?
Why can removing stale configurations be challenging when using CLI-based Infrastructure as Code solutions?
What is the primary purpose of custom filters in Ansible?
What is the primary purpose of custom filters in Ansible?
Why is it beneficial to use custom filters for complex data manipulations in Ansible?
Why is it beneficial to use custom filters for complex data manipulations in Ansible?
What does the filters
function in a custom Ansible filter module return?
What does the filters
function in a custom Ansible filter module return?
What is the purpose of regular expressions (regex) in the context of network automation?
What is the purpose of regular expressions (regex) in the context of network automation?
What is the primary goal of unit testing custom filters in Ansible?
What is the primary goal of unit testing custom filters in Ansible?
What is the benefit of using Ansible itself for unit testing custom filters?
What is the benefit of using Ansible itself for unit testing custom filters?
In mathematical set theory, what does the 'set difference' operation (A - B) determine?
In mathematical set theory, what does the 'set difference' operation (A - B) determine?
How can set difference be used to solve the problem of unwanted configurations?
How can set difference be used to solve the problem of unwanted configurations?
When using the rt_diff
filter, which list isn't looped over?
When using the rt_diff
filter, which list isn't looped over?
What is the key benefit of using Ansible roles?
What is the key benefit of using Ansible roles?
What is Ansible Galaxy?
What is Ansible Galaxy?
Which of the following best describes the role of Pluralsight's course 'Automating Networks with Ansible the Right Way'?
Which of the following best describes the role of Pluralsight's course 'Automating Networks with Ansible the Right Way'?
What is a key recommendation for maximizing the learning experience in the 'Automating Networks with Ansible the Right Way' course?
What is a key recommendation for maximizing the learning experience in the 'Automating Networks with Ansible the Right Way' course?
Regarding Ansible's applicability in network automation compared to other IT systems, what is a primary consideration?
Regarding Ansible's applicability in network automation compared to other IT systems, what is a primary consideration?
In the context of network automation using Ansible, what is the significance of understanding various connectivity methods beyond SSH?
In the context of network automation using Ansible, what is the significance of understanding various connectivity methods beyond SSH?
What is the key architectural benefit of MPLS VPNs in the Globomantics network scenario?
What is the key architectural benefit of MPLS VPNs in the Globomantics network scenario?
How do route targets (RTs) enable customized connectivity in an MPLS network?
How do route targets (RTs) enable customized connectivity in an MPLS network?
What is the role of routers R1 and R2 in the Globomantics MPLS network automation project?
What is the role of routers R1 and R2 in the Globomantics MPLS network automation project?
How does Ansible's configuration file relate to playbook execution?
How does Ansible's configuration file relate to playbook execution?
Within the Ansible framework, how are individual group and host variables utilized during playbook execution?
Within the Ansible framework, how are individual group and host variables utilized during playbook execution?
When configuring Ansible to connect to network devices, what is the purpose of the ansible_network_os
variable?
When configuring Ansible to connect to network devices, what is the purpose of the ansible_network_os
variable?
Why is it preferable to use a playbook-level configuration file over the global Ansible configuration file in network automation projects?
Why is it preferable to use a playbook-level configuration file over the global Ansible configuration file in network automation projects?
How is a Python virtual environment beneficial in the context of Ansible network automation?
How is a Python virtual environment beneficial in the context of Ansible network automation?
What is the purpose of using the ios_command
module in Ansible for network automation?
What is the purpose of using the ios_command
module in Ansible for network automation?
What approach should be used to extract the standard output from the structured data when using the ios_command
module?
What approach should be used to extract the standard output from the structured data when using the ios_command
module?
What is the function of the run_once
task-level directive in Ansible?
What is the function of the run_once
task-level directive in Ansible?
What is the purpose of Infrastructure as Code (IaC)?
What is the purpose of Infrastructure as Code (IaC)?
Which of the following is a core component of Infrastructure as Code?
Which of the following is a core component of Infrastructure as Code?
Why is the concept of 'idempotence' crucial in Infrastructure as Code (IaC)?
Why is the concept of 'idempotence' crucial in Infrastructure as Code (IaC)?
How does Infrastructure as Code leverage abstraction in multivendor network environments?
How does Infrastructure as Code leverage abstraction in multivendor network environments?
How does version control enhance troubleshooting in an Infrastructure as Code environment?
How does version control enhance troubleshooting in an Infrastructure as Code environment?
What is the potential impact of Continuous Integration and Continuous Deployment (CI/CD) on network management in an IaC context?
What is the potential impact of Continuous Integration and Continuous Deployment (CI/CD) on network management in an IaC context?
What is a key business benefit of adopting Infrastructure as Code?
What is a key business benefit of adopting Infrastructure as Code?
In Ansible, what is the purpose of the host_vars
directory?
In Ansible, what is the purpose of the host_vars
directory?
What is the primary function of Jinja2 templates in Ansible-based Infrastructure as Code?
What is the primary function of Jinja2 templates in Ansible-based Infrastructure as Code?
When using the ios_config
module in Ansible, what is the function of the notify
keyword?
When using the ios_config
module in Ansible, what is the function of the notify
keyword?
When deploying Infrastructure as Code to network devices, why can removing stale configurations be a challenge?
When deploying Infrastructure as Code to network devices, why can removing stale configurations be a challenge?
Why are custom filters useful in Ansible playbooks?
Why are custom filters useful in Ansible playbooks?
In the context of Ansible, what is the primary role of the filters
function within a custom filter module?
In the context of Ansible, what is the primary role of the filters
function within a custom filter module?
When writing custom filters in Ansible, why is it beneficial to keep advanced logic in Python and task orchestration in Ansible?
When writing custom filters in Ansible, why is it beneficial to keep advanced logic in Python and task orchestration in Ansible?
What is the purpose of regular expressions (regex) in the context of network automation and custom filters?
What is the purpose of regular expressions (regex) in the context of network automation and custom filters?
What is the main benefit of writing unit tests for custom filters in Ansible?
What is the main benefit of writing unit tests for custom filters in Ansible?
Regarding the use of Ansible for unit testing custom filters, why is this approach effective?
Regarding the use of Ansible for unit testing custom filters, why is this approach effective?
How can set difference be used to solve the problem of unwanted configurations in network automation with Ansible?
How can set difference be used to solve the problem of unwanted configurations in network automation with Ansible?
What is the function of Ansible Galaxy?
What is the function of Ansible Galaxy?
In the 'Automating Networks with Ansible the Right Way' course, what prior knowledge is recommended for students to succeed?
In the 'Automating Networks with Ansible the Right Way' course, what prior knowledge is recommended for students to succeed?
How does Ansible's approach to network device management generally differ from its approach to Linux server management?
How does Ansible's approach to network device management generally differ from its approach to Linux server management?
What role does Globomantics play in the context of the network automation scenarios presented in the course?
What role does Globomantics play in the context of the network automation scenarios presented in the course?
In an MPLS VPN, what determines the level of connectivity and isolation between different customers?
In an MPLS VPN, what determines the level of connectivity and isolation between different customers?
How does the Ansible configuration file influence playbook execution?
How does the Ansible configuration file influence playbook execution?
How do playbooks utilize variables for specific hosts or groups?
How do playbooks utilize variables for specific hosts or groups?
In Ansible network automation, what is the purpose of disabling fact gathering?
In Ansible network automation, what is the purpose of disabling fact gathering?
How do you configure a playbook to execute a particular task only once, regardless of the number of hosts?
How do you configure a playbook to execute a particular task only once, regardless of the number of hosts?
Which of the following is a core principle behind Infrastructure as Code?
Which of the following is a core principle behind Infrastructure as Code?
How does Infrastructure as Code (IaC) improve consistency and reduce errors in network management?
How does Infrastructure as Code (IaC) improve consistency and reduce errors in network management?
In Ansible, what is the primary purpose of Jinja2 templates within the context of Infrastructure as Code?
In Ansible, what is the primary purpose of Jinja2 templates within the context of Infrastructure as Code?
What is a key challenge when applying Infrastructure as Code to network devices, particularly with CLI-based approaches?
What is a key challenge when applying Infrastructure as Code to network devices, particularly with CLI-based approaches?
When writing custom filters in Ansible, why is it beneficial to delegate complex logic to Python?
When writing custom filters in Ansible, why is it beneficial to delegate complex logic to Python?
What is the primary purpose of using regular expressions (regex) when writing custom filters for network automation?
What is the primary purpose of using regular expressions (regex) when writing custom filters for network automation?
Why should you write unit tests when creating custom filters in Ansible?
Why should you write unit tests when creating custom filters in Ansible?
When using Ansible to unit test custom filters, what benefit is gained by using Ansible instead of a dedicated testing framework?
When using Ansible to unit test custom filters, what benefit is gained by using Ansible instead of a dedicated testing framework?
How can mathematical set difference be used to solve the problem of unwanted configurations on network devices?
How can mathematical set difference be used to solve the problem of unwanted configurations on network devices?
In the context of Ansible and Infrastructure as Code, what does 'abstraction' enable in multi-vendor network environments?
In the context of Ansible and Infrastructure as Code, what does 'abstraction' enable in multi-vendor network environments?
In the context of Ansible, what is the main purpose of roles?
In the context of Ansible, what is the main purpose of roles?
According to the course material, what is a significant business advantage of adopting Infrastructure as Code (IaC)?
According to the course material, what is a significant business advantage of adopting Infrastructure as Code (IaC)?
Flashcards
Ansible configuration file
Ansible configuration file
A configuration file that defines global runtime settings for Ansible, such as the inventory file location and logging options.
Ansible inventory
Ansible inventory
A file that lists all the hosts and groups of hosts managed by Ansible.
Ansible variable files
Ansible variable files
Files that store group and host-specific data, often containing configuration settings.
Ansible playbooks
Ansible playbooks
Signup and view all the flashcards
ansible_network_os
ansible_network_os
Signup and view all the flashcards
ansible_user
ansible_user
Signup and view all the flashcards
ansible_password
ansible_password
Signup and view all the flashcards
group_vars folder
group_vars folder
Signup and view all the flashcards
ios_command module
ios_command module
Signup and view all the flashcards
copy module
copy module
Signup and view all the flashcards
stdout
stdout
Signup and view all the flashcards
run_once
run_once
Signup and view all the flashcards
inventory_hostname
inventory_hostname
Signup and view all the flashcards
IaC
IaC
Signup and view all the flashcards
host_vars
host_vars
Signup and view all the flashcards
Jinja2
Jinja2
Signup and view all the flashcards
save_when: changed
save_when: changed
Signup and view all the flashcards
handler
handler
Signup and view all the flashcards
idempotent
idempotent
Signup and view all the flashcards
ios_config
ios_config
Signup and view all the flashcards
Abstraction
Abstraction
Signup and view all the flashcards
cli_config
cli_config
Signup and view all the flashcards
lookup
lookup
Signup and view all the flashcards
ios_vrf
ios_vrf
Signup and view all the flashcards
Custom Filter
Custom Filter
Signup and view all the flashcards
filter directory
filter directory
Signup and view all the flashcards
RE library
RE library
Signup and view all the flashcards
Unit test
Unit test
Signup and view all the flashcards
Set
Set
Signup and view all the flashcards
Set difference
Set difference
Signup and view all the flashcards
Ansible Roles
Ansible Roles
Signup and view all the flashcards
ansible-galaxy
ansible-galaxy
Signup and view all the flashcards
Ansible-galaxy Website
Ansible-galaxy Website
Signup and view all the flashcards
Study Notes
- This course focuses on automating networks with Ansible, emphasizing practical application and production-ready solutions.
- The course covers designing, implementing, operating, and troubleshooting automation solutions in complex networks.
- Key principles include Ansible-based network automation, infrastructure as code, design options (CLI and API-based), Python coding for Ansible customization, and bulletproofing playbooks.
- Prior knowledge of Python, basic networking (CCNA level), and an introduction to Layer 3 VPNs are recommended.
Network Automation Differences
- Ansible is typically used in systems administration, but involves some specific differences in network automation.
- Most network devices lack native Python support, unlike Linux-based systems.
- Ansible delegates module execution to managed devices with Python.
- Without Python, the module logic runs on the Ansible control machine.
- Network devices commonly use different connectivity methods beyond SSH.
MPLS Network Overview
- Multiprotocol Label Switching (MPLS) enables multitenancy across geographically dispersed sites using VPNs.
- Globomantics, a network service provider, automates customer provisioning using Ansible.
- MPLS VPNs use Border Gateway Protocol (BGP) to exchange IP routes.
- Route targets (RTs) are numeric tags applied to BGP routes, determining VPN membership.
- Ansible primarily manages R1 and R2 routers.
Ansible Core Components
- The Ansible configuration file defines global runtime settings like inventory file location and logging.
- The Ansible inventory lists managed hosts and groups.
- Variable files store group and host-specific data, significantly used for configuration settings.
- Playbooks are the mainstay of Ansible, containing a list of plays.
- Plays include tasks, which are specific actions to be accomplished on the target hosts.
- The configuration file contains global operations while plays select groups from the inventory based on high level global operations that affect the entire playbook.
- Group and host variables are consumed at the task level.
- ansible_network_os specifies the type of network device.
- ansible_user sets the login username.
- ansible_password sets the login password.
Ansible Preparation Steps
- Install Ansible and create a directory structure with basic component files.
- Python virtual environment with Python version 3.6.7 and Ansible version 2.7.7 is used.
- The default config file is in /etc/ansible/ansible.cfg, and playbook-level config files are recommended for portability.
- Common defaults include disabling fact gathering (gathering: false), identifying the inventory file (inventory = inv.yml), and disabling retry files (retry_files_enabled = False).
- The YAML inventory format is hierarchical, starting with the all group containing subgroups.
- The group_vars folder automatically inherits variables at the group level.
First Ansible Playbook
- A playbook lists plays, defining the play data and scope.
- Tasks include names, modules, and options.
- ios_command module runs exec-level commands on Cisco IOS devices.
- The register task option stores the result.
- The debug module prints output.
- Ansible prints out the play and task names in the console log.
Playbook Logging Challenge
- Output data should be represented as simple text, and configuration snippets backed up to files.
- ansible-doc feature provides documentation of Ansible
- Examine stdout, a list of strings, one per command issued.
- JSON structure uses dot notation (e.g., cli_result.stdout) or Python notation (e.g., cli_result['stdout']).
- The file module creates directories.
- run_once accomplishes folder creation only once instead of N times.
- The copy module writes content from memory to a file on the control machine.
- inventory_hostname variable reflects the hostname of each host.
Infrastructure as Code (IaC)
- Traditional network operators often manually determine the current state of devices and their configuration.
- IaC allows operators to declare a desired state.
- IaC solutions offer varying levels of abstraction for different environments.
- Version control systems track changes made by all users with difference checking capabilities.
IaC Components
- Idempotence means an operation can be executed multiple times without unnecessary changes after the initial setup.
- Variables illustrate route target management using YAML data.
- Ansible workflows can be designed generically with custom templates per device type.
- Version control enables reverting to previous states, checking logs, and enhancing troubleshooting and postmortem processes.
- Continuous Integration/Continuous Deployment (CI/CD) automates testing and deployment.
Business Benefits of IaC
- Quality is improved by reducing variability.
- Time is reallocated from mundane tasks to network design and planning.
- Automation frameworks like Ansible are low or no cost.
- Automation for a US Federal Government customer reduced defect rates, shortened lead times, and saved approximately $2 million annually.
Deploying "ios_config" for CLI-based IAC
- The host_vars folder defines specific variables for individual hosts.
- R1 and R2 have VRFs with route import and export lists.
- Jinja2 templates allow loops for iteration and if/else statements for conditional logic.
- The ios_config module makes changes to the router
- The src option specifies the Jinja2 template file path.
- The save_when: changed option copies the running-config to startup-config if changes are required.
- The notify option calls a handler when changes occur.
- Handlers listen for a specific signal (e.g., config_changed) and execute tasks conditionally
- Handlers are used to print output only if there was a change.
- Use ansible-doc to learn more about file and copy modules
Deploying "cli_config" for CLI-based IAC
- Uses a more platform-agnostic approach with a mixed IOS and IOS XR network.
- The inventory file includes additional hierarchy with ios_routers and iosxr_routers subgroups.
- Subgroups allow defining OS-specific variables in the group_vars folder, such as ansible_network_os.
- Templates are device-based (ios_vpn.j2 and iosxr_vpn.j2).
- Module cli_config handles any network CLI via the ansible_network_os field.
- set_fact module performs variable assignment.
- The cli_config module uses lookup to render the template manually.
- The handler is notified if a change occurs, and results are stored in cli_result.
- A bug exists in cli_config: does not properly save IOS configurations.
Deploying "ios_vrf" for CLI-based IAC
- Manages VPN membership configuration by just updating route targets in the network based on declarative statement without any templates.
- The ios_vrf module passes a list of dictionaries.
- Naming variables consistently with module suboptions helps stay organized.
Comparing CLI-based Infrastructure as Code Solutions
- Generic solutions rely on modules like ios_config or cli_config.
- Specific modules like ios_vrf have a limited set of features.
- Generic solutions use Jinja2 templates, while specific solutions ingest structured data directly.
The Big Problem
- Ansible may have difficulty removing stale configurations when using CLI-based Infrastructure as Code solutions.
- Removing old configuration is challenging as Ansible does not want to make assumptions.
- Basic IaC solutions are great at remediating missing route targets if any exist.
Custom Filters
- Ansible is easily extendable using Python with custom filters, modules, and plugins.
- Filters are Python functions that complement existing Ansible constructs.
- Filters enable running arbitrary Python code in playbooks.
- YAML-based DSL can be inflexible.
- Python functions often reduce complexity
- Ansible plugins need to be included in the config file.
- The FilterModule class in Python is consumed by Ansible.
- The filters function returns a dictionary mapping Ansible filter names to Python function names.
Simplest Possible Custom Filter
- Filter extracts the BGP Autonomous System Number from the route target using Python.
- Specify custom filters file path in the config file.
- The FilterModule class creates a method called filters.
- A statichmethod decorator is used since Ansible doesn’t need to instantiate this class.
- Invoke custom filter using the pipe syntax.
Parser and Regex Basics
- Python filter transforms the VRF definition text blob into a JSON structure.
- Regular expressions (regex) match input strings against generic patterns for extracting data fields.
- Named capture groups identify data.
- Regex101.com support checking regex against sample text inputs.
Custom Parser for VRF Information Demo
- The RE library is used for regular expressions.
- A filter takes in a single string (text), which should be a delimited blob.
- The big blob gets broken into smaller chunks, one per VRF.
- A Python list comprehension combined with string splitting is used .
- Iterate through each VRF stanza individually to search the VRF stanza for the VRF name, and store it in dictionary form.
Bullet-proofing Code with Unit Tests
- Unit tests pass static data to individual code segments (custom filters).
- Test the results by the use of static input.
- Detect future changes to detect breaking changes without impacting production
Using Ansible for Filter Unit Testing
- Use Ansible to test Ansible.
- Playbook loads test cases defined in the task's directory.
- One task file is created for each filter, and each task file contains individual test cases.
- The play runs on localhost only and uses connection local.
- The find module grabs YAML files that begin with test_ in the tasks directory.
- The map filter grabs all path attributes from each dictionary and assembles them into a simple list of strings.
- Walk the list of file names pulling each one into the playbook using the include_tasks directive.
- The assert module asserts provided list of conditions are all true.
Set Theory Basics
- A set is a mathematical term representing a collection of unique elements.
- Sets are unsorted, unsorted collections of unique elements.
- Operations include union, intersection, and difference.
- Set difference answers the set difference: which one is in one set, but is NOT in the other set.
Set Operations in Python
- want represents the desired state (YAML lists).
- have represents the current route target configuration.
- want - have identifies route targets to add (present in desired state, not in current state).
- have - want identifies route targets to remove (currently configured, not in desired state).
Custom Filter for Route-targeting Presence Determination
- Filter takes two arguments: list of VRFs from intended state and dictionary of VRFs from running configuration.
- Function returns a list of VRFs.
- Uses get function that works with a list indexes, returns NOne if matching value found,.
- Adds or deletes based on matching filter conditions
- Set intersection not required because its a non change
Unit Tests For the Custom Filter
- Use static data to mock up YAML-formatted data.
- Mock variables such as run-vrf-dict to compare current stated vs intended state
- Assert individual data fields are correct.
Fitting the Pieces Together
- The desired state is stored in per-host variable files using YAML format.
- The playbook captures the current VRF configuration.
- Tasks: parse the lists of current import and export route targets; Compare to desired configurations and then Apply any route target additions or removals.
- Jinja loops are nested for each set of commands
- Commands loop to add the necessary data
The Whole Solution in Action
- A Jinja2 template applies config changes.
- Four inner loops add and delete route target import/export.
- grep for seeing a high‑level view of a large Ansible playbook.
- Steps: grab the VRF config, parse it, perform set difference, apply changes, and display changes if they occurred.
- A key component is rt_diff filter
- Use desired state route target lists via a script, run the playbook again, and the infrastructure updates appropriately; no more manual changes directly on devices.
Ansible Roles
- An Ansible Role encapsulates Ansible components into a self-contained package for reuse.
- Each Ansible Role will include unit tests for code
- Roles are available via Ansbile Galaxy
- Roles assist in scaling the Ansible architecture
- Helps maximizes code reuse
Ansible Galaxy Refresher
- ansible-galaxy is a shell command available to create or interfact with files from Ansible
- Use ansible-galaxy list command to enumate installed Ansible Roles
- Use ansible-galaxy search command to to search the Ansible-galaxy website
- Use the ansible-galaxy install command to install the modules on to your Ansible distribution
- Ansible's init command builds the directory
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.