Ansible Network Automation uses Ansible's network modules to manage network devices like routers and switches via SSH or API, replacing manual CLI commands. The key takeaway: define your device credentials and connection parameters in inventory, use ansible_network_os to select the correct module set, and always test against a staging environment first — a typo in a VLAN config can take down production.
✦ Definition~90s read
What is Ansible Network Automation?
Ansible Network Automation is a set of connection plugins, modules, and frameworks designed to manage network devices (switches, routers, firewalls) using Ansible's declarative model. Unlike server automation, network devices require dedicated communication protocols (SSH, API, NETCONF) and must handle idempotency carefully because a misapplied config can cause connectivity loss.
★
Imagine you're a manager of a huge office building with hundreds of light switches.
The core connection plugin is ansible.netcommon.network_cli, which replaces the deprecated local connection. It manages persistent SSH connections, handles privilege escalation (enable mode), and provides a consistent interface for network modules.
Vendor-specific modules like cisco.ios.ios_config and junipernetworks.junos.junos_config use this connection to push configurations idempotently.
Network-agnostic modules (ansible.netcommon.cli_config, ansible.netcommon.cli_command) work across vendors by relying on ansible_network_os to determine the CLI syntax. NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) provides a higher-level abstraction via the community.network.napalm_* modules, using APIs like NETCONF or RESTCONF for operations that are more reliable than CLI scraping.
Plain-English First
Imagine you're a manager of a huge office building with hundreds of light switches. You want to automate turning them all off at night. Ansible is like a robot that can flip switches for you. But here's the catch: some switches are old and wonky—they don't always respond correctly. The robot needs a special way to talk to each type of switch (that's the connection plugin). And you don't want the robot to flip a switch that's already off (that's idempotency). NAPALM is like a universal remote that works with many brands of switches. And ansible-vault is a locked safe where you keep the master key to the switch room. This article teaches you how to program your robot to handle all these quirks without causing an electrical fire.
It's 2 AM on a Saturday. I'm on-call, and our network automation pipeline just pushed a bad VLAN config to 200 Cisco switches. The symptom: all trunk ports flapped, causing a 15-minute outage for the entire east coast data center. The root cause? A playbook using ios_command with commands: 'vlan 100' instead of ios_config with lines: 'vlan 100'. The ios_command module doesn't enforce idempotency—it blindly sends the command, and the switch accepted it even though the VLAN existed, causing a momentary interface reset. That night, I learned the hard way that network automation is not server automation. You can't just SSH in and run commands; you need structured modules that understand the device's state.
Historically, Ansible started as a server automation tool. The command and shell modules worked fine for Linux, but network devices are state machines with fragile CLI parsers. Early adopters used connection: local and raw SSH, which led to brittle playbooks. The Ansible network team responded with connection plugins like network_cli and vendor-specific modules. But even today, many engineers fall into the trap of treating network devices like Linux boxes.
This article covers the production patterns I've developed over 5 years of automating Cisco, Juniper, Arista, and Nexus gear. We'll dive into the network_cli connection plugin, the difference between ios_command and ios_config, network-agnostic modules, NAPALM integration, and how to avoid the idempotency landmines that will take down your network. I'll also show you how to secure credentials with ansible-vault and debug when things go wrong.
By the end, you'll know exactly which module to use for which task, how to structure your playbooks for reliability, and what to do when a switch doesn't respond as expected. Let's fix your automation before it fixes you.
1. The network_cli Connection Plugin: Why local is Dead
The network_cli connection plugin (ansible.netcommon.network_cli) is the standard for SSH-based network automation in Ansible 2.9+. It replaces the deprecated local connection and provides persistent SSH sessions, privilege escalation (enable mode), and automatic prompt handling.
Key differences from local: - network_cli maintains a single SSH connection for the entire playbook, reducing overhead. - It handles enable mode automatically when ansible_become: yes and ansible_become_method: enable are set. - It parses device prompts and waits for the correct prompt before sending commands.
---
- name: Use network_cli forCiscoIOS
hosts: cisco
gather_facts: no
connection: ansible.netcommon.network_cli
tasks:
- name: Show version
ansible.netcommon.cli_command:
command: show version
register: output
- name: Display output
ansible.builtin.debug:
var: output.stdout_lines
Output
PLAY [Use network_cli for Cisco IOS] ************************************
connection: local is deprecated for network modules. Using it will produce a warning in Ansible 2.9 and will be removed in a future release. Migrate all playbooks to network_cli.
📊 Production Insight
We once had a playbook that used connection: local and delegate_to: localhost. It worked fine for 50 switches but failed with 200 because it opened 200 SSH connections simultaneously, overwhelming the control node. Switching to network_cli solved it.
🎯 Key Takeaway
Always use ansible.netcommon.network_cli for network modules; never use local or default ssh.
thecodeforge.io
Ansible Network Automation
2. Cisco IOS: ios_command vs ios_config
The two most common Cisco IOS modules are cisco.ios.ios_command and cisco.ios.ios_config. They serve different purposes:
ios_command: Sends arbitrary CLI commands and returns output. Not idempotent. Use for show commands only.
ios_config: Manages configuration sections idempotently. It reads the running config, compares it with the desired state, and applies only the necessary changes.
Example: Correct usage ``yaml - name: Configure VLAN 100 on interface cisco.ios.ios_config: lines: - vlan 100 parents: - interface GigabitEthernet0/1 ` This will only apply vlan 100` if it's not already present under the interface.
Example: Wrong usage (causes flap) ``yaml - name: BAD - using ios_command for config cisco.ios.ios_command: commands: - interface GigabitEthernet0/1 - vlan 100 `` This sends the commands blindly, causing the switch to re-apply VLAN 100, which resets the interface.
Idempotency check: Use --diff flag to see what changes Ansible will make: ``bash ansible-playbook -i inventory playbook.yml --diff --check ``
The --check mode with ios_config will simulate the change without applying it.
ios.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
- name: IOS commands
hosts: cisco
gather_facts: no
connection: ansible.netcommon.network_cli
tasks:
- name: Execute show command
cisco.ios.ios_command:
commands: show ip interface brief
register: result
- name: Configure hostname
cisco.ios.ios_config:
lines:
- hostname R1
match: exact
replace: line
register: config_result
- name: Display results
ansible.builtin.debug:
msg: "{{ result.stdout_lines }}"
Output
PLAY [IOS commands] ******************************************************
TASK [Execute show command] *********************************************
Run your playbook twice. The second run should report 'changed=0'. If it reports changes, your module is not idempotent.
📊 Production Insight
I once saw a playbook that used ios_command with commands: 'no vlan 100' to remove a VLAN. That command fails if the VLAN doesn't exist, causing the playbook to abort. ios_config with lines: 'no vlan 100' handles this gracefully.
🎯 Key Takeaway
Use ios_command only for show commands; use ios_config for all configuration changes to ensure idempotency.
3. Network-Agnostic Modules: cli_config and cli_command
For multi-vendor environments, Ansible provides network-agnostic modules: ansible.netcommon.cli_config and ansible.netcommon.cli_command. These modules rely on the ansible_network_os variable to determine the correct CLI syntax.
Example: cli_config ``yaml - name: Set hostname using agnostic module ansible.netcommon.cli_config: config: "hostname {{ inventory_hostname }}" ` This works on Cisco IOS, Junos, EOS, and NXOS as long as ansible_network_os` is set correctly.
Example: cli_command ``yaml - name: Show version ansible.netcommon.cli_command: command: show version register: version_output ``
Limitations: - cli_config does not support structured config; it sends raw text. For idempotent structured config, use vendor-specific modules. - cli_command does not handle privilege escalation automatically; you may need to include enable in the command string.
When to use: - Quick ad-hoc commands across vendors. - When you don't have vendor-specific collections installed. - For read-only operations (show commands).
Gotcha: The cli_config module uses the configure terminal command on Cisco devices. If you send a command that requires enable mode, you must set ansible_become: yes.
cli_config.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
---
- name: Use cli_config and cli_command
hosts: all
gather_facts: no
connection: ansible.netcommon.network_cli
tasks:
- name: Run show command
ansible.netcommon.cli_command:
command: show running-config | include hostname
register: output
- name: Configure banner
ansible.netcommon.cli_config:
config: |
banner motd ^
Unauthorized access prohibited
^
register: result
- name: Display config result
ansible.builtin.debug:
var: result
Output
PLAY [Use cli_config and cli_command] ***********************************
TASK [Run show command] *************************************************
The ansible.netcommon collection must be installed: ansible-galaxy collection install ansible.netcommon.
📊 Production Insight
We used cli_config to push a banner message across 500 switches of different vendors. It worked perfectly until we hit an old IOS that required banner motd ^ instead of banner motd #. We had to fall back to vendor-specific modules.
🎯 Key Takeaway
Network-agnostic modules are great for simple tasks across vendors, but for complex configs, use vendor-specific modules.
thecodeforge.io
Ansible Network Automation
4. NAPALM Integration via community.network
NAPALM (Network Automation and Programmability Abstraction Layer with Multivendor support) provides a unified API for network devices. The community.network.napalm_* modules (e.g., napalm_cli, napalm_config, napalm_get_facts) use NAPALM under the hood.
Inventory variables: ``yaml ansible_connection: community.network.napalm ansible_network_os: cisco.ios.ios # or junipernetworks.junos.junos, etc. napalm_platform: ios # must match napalm's platform name ``
Example: Get facts ``yaml - name: Gather facts via NAPALM community.network.napalm_get_facts: filter: ['facts', 'interfaces'] register: napalm_facts ``
Advantages: - Works with devices that have API access (NETCONF, RESTCONF) – more reliable than CLI scraping. - napalm_get_facts returns structured data (JSON) instead of CLI text. - napalm_config supports replace and commit operations (important for Junos).
Disadvantages: - Requires NAPALM on the control node, not on the device. - Some platforms require additional libraries (e.g., junos-eznc for Junos). - Not all NAPALM methods are idempotent; napalm_config with replace is, but napalm_cli is not.
NAPALM supports many platforms, but not all features. Check napalm --help for supported platforms. For unsupported devices, fall back to network_cli and vendor modules.
📊 Production Insight
We switched to NAPALM for Junos devices because junos_config sometimes got out of sync with the candidate config. NAPALM's commit method with confirm saved us from a bad commit that would have locked us out.
🎯 Key Takeaway
Use NAPALM when you need structured data or reliable commit/rollback; otherwise, vendor-specific modules are simpler.
5. Managing Junos: junos_config and junos_command
Juniper Junos devices use a different paradigm: candidate config and commit. The junipernetworks.junos.junos_config module handles this.
Example: Configure an interface ``yaml - name: Configure interface ge-0/0/0 junipernetworks.junos.junos_config: lines: - set interfaces ge-0/0/0 description "Ansible managed" - set interfaces ge-0/0/0 unit 0 family inet address 10.0.0.1/24 comment: "Updated by Ansible" ``
Commit options: ``yaml - name: Commit with confirm junipernetworks.junos.junos_config: lines: - set system hostname new-hostname commit: yes confirm: 5 # confirm in 5 minutes ``
Gotcha: Junos modules require ansible_network_os: junipernetworks.junos.junos and the junipernetworks.junos collection. Also, you need junos-ezncPython library on the control node: pip install junos-eznc.
Command module: ``yaml - name: Show interface status junipernetworks.junos.junos_command: commands: - show interfaces terse register: output ``
Idempotency:junos_config only applies changes that differ from the candidate config. Use --diff to see what will change.
junos.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
- name: ManageJunos
hosts: juniper
gather_facts: no
connection: ansible.netcommon.network_cli
tasks:
- name: Showinterface
junipernetworks.junos.junos_command:
commands: show interfaces terse
register: result
- name: Configure hostname
junipernetworks.junos.junos_config:
lines:
- set system host-name J1
comment: Update hostname
register: config_result
- name: Display config result
ansible.builtin.debug:
var: config_result
Output
PLAY [Manage Junos] *****************************************************
Always use junos_config for config changes; never use junos_command to send set commands directly. The config module properly handles the commit model.
📊 Production Insight
We once used junos_command to send commit after a series of set commands. If the commit failed, we had no rollback. Now we always use junos_config which rolls back automatically on error.
🎯 Key Takeaway
Junos modules understand the commit model; let them handle commit and rollback.
6. Managing Arista EOS: eos_config and eos_command
Arista EOS is similar to Cisco IOS but with some differences. The arista.eos.eos_config module is the primary config module.
Arista switches use > for user mode and # for privileged mode. The module handles this automatically.
📊 Production Insight
We had a playbook that used eos_command to send configure terminal and then vlan 200. It worked but was not idempotent. Switching to eos_config reduced run time by 50% because it only applied changes when needed.
🎯 Key Takeaway
Always use eos_config for configuration; it's idempotent and handles privilege escalation.
7. Managing Cisco NXOS: nxos_config and nxos_command
Cisco NX-OS (Nexus) uses a syntax similar to IOS but with differences. The cisco.nxos.nxos_config module is the config module.
Command module: ``yaml - name: Show version cisco.nxos.nxos_command: commands: - show version register: version ``
Gotcha: NX-OS requires feature commands for certain features (e.g., feature interface-vlan). You must ensure these are enabled before configuring related features.
Idempotency:nxos_config is idempotent. Use --diff to see changes.
If you configure VLAN interfaces without enabling feature interface-vlan, the module will fail. Add a task to enable the feature first.
📊 Production Insight
We once tried to configure an SVI on Nexus without enabling feature interface-vlan. The playbook failed with a cryptic error. Now we always have a prerequisite playbook that enables required features.
🎯 Key Takeaway
For NX-OS, ensure required features are enabled before configuring related settings.
8. Idempotency Challenges in Network Automation
Idempotency is the property that running a playbook multiple times produces the same result. In network automation, achieving idempotency is harder than on servers because:
Config modules compare text, not structured data. A slight difference in whitespace or ordering can cause false positives.
Stateful devices: Some commands have side effects (e.g., no shutdown on an already up interface).
Commit models: Junos requires explicit commit; if the module doesn't commit, the config is not applied.
CLI drift: If someone manually changes the config, Ansible may not detect it if the module uses a cached version.
Best practices: - Always use config modules (*_config) not command modules. - Use --diff to verify what will change. - Run playbooks with --check first. - For critical changes, use --diff and manual review. - Use ansible_network_os correctly to ensure the right module is used.
Example: Idempotent VLAN config ``yaml - name: Ensure VLAN 100 exists cisco.ios.ios_config: lines: - vlan 100 - name TEST_VLAN parents: - vlan 100 `` This will only create VLAN 100 if it doesn't exist. If it exists, no change.
Non-idempotent example: ``yaml - name: BAD - always sets hostname cisco.ios.ios_command: commands: - configure terminal - hostname {{ inventory_hostname }} `` This sets the hostname every run, even if it's already correct.
idempotency.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
---
- name: Idempotency challenge
hosts: cisco
gather_facts: no
connection: ansible.netcommon.network_cli
tasks:
- name: Ensure hostname is set
cisco.ios.ios_config:
lines:
- hostname R1
match: exact
replace: line
register: result
- name: Checkif changed
ansible.builtin.debug:
msg: "{{ 'Changed'if result.changed else'Idempotent' }}"
Output
PLAY [Idempotency challenge] ********************************************
TASK [Ensure hostname is set] *******************************************
ok: [rtr1]
TASK [Check if changed] *************************************************
ok: [rtr1] => {
"msg": "Idempotent"
}
PLAY RECAP *********************************************************************
Run the same playbook twice. The second run should show changed=0 for all tasks. If not, your module is not idempotent.
📊 Production Insight
We had a playbook that pushed the same NTP config every run because the module compared the config line-by-line and the order differed. We fixed it by using parents to specify the exact hierarchy.
🎯 Key Takeaway
Idempotency requires using config modules that compare current state; always test with --check and --diff.
9. Using ansible-vault for Device Credentials
Storing device credentials in plaintext is a security risk. ansible-vault encrypts sensitive data so it can be safely stored in version control.
Running playbook: ``bash ansible-playbook -i inventory playbook.yml --ask-vault-pass ` Or use a vault password file: `bash echo 'my_vault_pass' > .vault_pass ansible-playbook -i inventory playbook.yml --vault-password-file .vault_pass ``
Best practices: - Use separate vault files for different environments (dev, prod). - Never commit the vault password to version control. - Use ansible-vault rekey to change passwords. - For automation (CI/CD), use a vault password file stored in a secrets manager (e.g., HashiCorp Vault, AWS Secrets Manager).
Gotcha: If you use ansible-vault encrypt on a file that already contains variables, ensure the variables are referenced correctly. Use {{ }} syntax.
Playbook example: ``yaml - name: Configure NTP on all devices hosts: all gather_facts: no tasks: - name: Set NTP server ansible.builtin.include_role: name: ntp_config ``
The role ntp_config would have tasks for each vendor using when: ansible_network_os == 'cisco.ios.ios' etc.
multi_vendor.ymlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
- name: Multi-vendor playbook
hosts: all
gather_facts: no
connection: ansible.netcommon.network_cli
tasks:
- name: Showversion (Cisco)
cisco.ios.ios_command:
commands: show version
when: ansible_network_os == 'cisco.ios.ios'
register: version
- name: Showversion (Juniper)
junipernetworks.junos.junos_command:
commands: show version
when: ansible_network_os == 'junipernetworks.junos.junos'
register: version
- name: Display version
ansible.builtin.debug:
var: version.stdout_lines
Output
PLAY [Multi-vendor playbook] ********************************************
TASK [Show version (Cisco)] *********************************************
skipping: [j1]
ok: [rtr1]
TASK [Show version (Juniper)] *******************************************
When changing interface settings, you may lose connectivity to the device. Use wait_for to test connectivity after changes and have a rollback plan.
📊 Production Insight
We once applied a change that shut down the management interface. We had to console into the device to recover. Now we always test connectivity after changes and have an out-of-band access plan.
🎯 Key Takeaway
Always implement rollback strategies for critical changes; test connectivity after changes.
Ansible logs can grow quickly. Configure log rotation for /var/log/ansible/network.log.
📊 Production Insight
We had a mysterious failure that only happened at scale. Using -vvvv we saw that the SSH connection was being closed due to a timeout. We increased ansible_command_timeout to 60 seconds.
🎯 Key Takeaway
Use verbose logging and register to capture module output; always test with --check in a lab.
● Production incidentPOST-MORTEMseverity: high
The VLAN Flap That Took Down a Data Center
Symptom
All trunk interfaces went down for 15 minutes. Logs showed 'VLAN 100' being re-applied every 5 minutes.
Assumption
The engineer assumed ios_command was idempotent because it was 'just sending a command'.
Root cause
ios_command does not check current state; it sends the command verbatim. The switch interprets vlan 100 as a create command even if VLAN 100 exists, causing a momentary interface reset.
Fix
Replace ios_command with ios_config module using lines: 'vlan 100' and parents: 'interface GigabitEthernet0/1'.
Key lesson
Never use ios_command (or any *command module) for configuration changes.
Use dedicated config modules that implement idempotency checks.
Production debug guideSymptom → Root cause → Fix4 entries
Symptom · 01
Playbook hangs at 'Connecting to device'
→
Fix
Check SSH connectivity from control node: ssh -vvv user@device. If SSH works, ensure ansible_connection: ansible.netcommon.network_cli and ansible_network_os are set. Also check ansible_user and ansible_password are correct.
Symptom · 02
Module fails with 'timeout waiting for privilege escalation'
→
Fix
The device requires enable mode. Set ansible_become: yes, ansible_become_method: enable, and ansible_become_password: <enable_secret> in group_vars.
Symptom · 03
Config changes not applied (idempotency not working)
→
Fix
Ensure you're using config modules (e.g., ios_config) not command modules. Check diff output: if it says 'after' matches 'before', the module thinks the config is already present. Use --diff flag to see what Ansible thinks is the current state.
Symptom · 04
NAPALM module fails: 'napalm is not installed'
→
Fix
Install napalm on the control node: pip install napalm==4.1.0. Also set connection: community.network.napalm and provide napalm_platform (e.g., ios, junos).
★ Ansible Network Automation Quick Referenceprint this for your desk
Always use ansible.netcommon.network_cli for SSH-based network automation; never use local.
2
Use ios_config (and vendor-specific config modules) for configuration; never use ios_command for config changes.
3
Network-agnostic modules (cli_config, cli_command) are useful for simple tasks but lack idempotency for complex configs.
4
NAPALM integration provides structured data and reliable commit/rollback, but requires additional setup.
5
Junos, EOS, and NXOS have dedicated modules that handle their specific config models (commit, feature dependencies).
6
Idempotency requires config modules that compare current state; always test with --check and --diff.
7
Encrypt device credentials with ansible-vault and never store passwords in plaintext.
8
Structure inventory by vendor and use ansible_network_os for conditional tasks.
9
Implement rollback strategies for critical changes (backup, rescue, commit confirm).
10
Use verbose logging (-vvv) and register to debug module behavior.
11
Test changes in a lab before production; some modules do not support --check.
12
Keep Ansible and collections updated to avoid deprecated features.
INTERVIEW PREP · PRACTICE MODE
Interview Questions on This Topic
Q01JUNIOR
What is the difference between `ios_command` and `ios_config`?
Q02SENIOR
How do you achieve idempotency when automating Cisco IOS with Ansible?
Q03SENIOR
What is the `network_cli` connection plugin and why is it preferred over...
Q04SENIOR
How do you integrate NAPALM with Ansible?
Q05SENIOR
How do you manage Junos commit model with Ansible?
Q06SENIOR
What are the common idempotency challenges in network automation?
Q07JUNIOR
How do you secure device credentials in Ansible?
Q08SENIOR
What is the difference between `cli_config` and vendor-specific config m...
Q01 of 08JUNIOR
What is the difference between `ios_command` and `ios_config`?
ANSWER
ios_command sends arbitrary CLI commands and returns output; it is not idempotent and should only be used for show commands. ios_config manages configuration sections idempotently by comparing the desired state with the running config and applying only the necessary changes.
Q02 of 08SENIOR
How do you achieve idempotency when automating Cisco IOS with Ansible?
ANSWER
Use the cisco.ios.ios_config module with lines and parents to specify the desired configuration. The module reads the running config, compares it with the desired state, and applies only the differences. Always test with --check and --diff.
Q03 of 08SENIOR
What is the `network_cli` connection plugin and why is it preferred over `local`?
ANSWER
network_cli is a persistent SSH connection plugin for network devices. It handles privilege escalation, prompt detection, and session reuse. It is preferred over the deprecated local connection because it is more efficient (single connection per device) and handles network-specific quirks automatically.
Q04 of 08SENIOR
How do you integrate NAPALM with Ansible?
ANSWER
Install the napalm Python library and the community.network collection. Set ansible_connection: community.network.napalm and napalm_platform to the correct platform (e.g., ios). Use modules like napalm_get_facts, napalm_config, and napalm_cli. NAPALM provides structured data and reliable commit/rollback.
Q05 of 08SENIOR
How do you manage Junos commit model with Ansible?
ANSWER
Use the junipernetworks.junos.junos_config module. It handles candidate config, commit, and rollback. You can set commit: yes and confirm for commit confirm. Never use junos_command to send commit directly.
Q06 of 08SENIOR
What are the common idempotency challenges in network automation?
ANSWER
Challenges include: text-based config comparison (whitespace/ordering differences), stateful commands (e.g., no shutdown on an up interface), commit models (Junos), and CLI drift. Solutions include using config modules, --diff for verification, and structured data sources like NAPALM.
Q07 of 08JUNIOR
How do you secure device credentials in Ansible?
ANSWER
Use ansible-vault to encrypt sensitive variables like ansible_password and ansible_become_password. Store vault-encrypted files in group_vars and reference them via {{ vault_variable }}. Use --ask-vault-pass or a vault password file.
Q08 of 08SENIOR
What is the difference between `cli_config` and vendor-specific config modules?
ANSWER
cli_config is network-agnostic and sends raw text configuration. It is not idempotent for partial configs. Vendor-specific modules (e.g., ios_config) understand the device's config hierarchy and provide idempotency. Use cli_config for simple, one-off commands across vendors.
01
What is the difference between `ios_command` and `ios_config`?
JUNIOR
02
How do you achieve idempotency when automating Cisco IOS with Ansible?
SENIOR
03
What is the `network_cli` connection plugin and why is it preferred over `local`?
SENIOR
04
How do you integrate NAPALM with Ansible?
SENIOR
05
How do you manage Junos commit model with Ansible?
SENIOR
06
What are the common idempotency challenges in network automation?
SENIOR
07
How do you secure device credentials in Ansible?
JUNIOR
08
What is the difference between `cli_config` and vendor-specific config modules?
SENIOR
FAQ · 8 QUESTIONS
Frequently Asked Questions
01
What is the difference between `network_cli` and `netconf` connection?
network_cli uses SSH and CLI commands; netconf uses SSH and NETCONF protocol. netconf is more reliable and structured but requires NETCONF support on the device.
Was this helpful?
02
Can I use `ios_command` to apply configuration?
Technically yes, but it is not idempotent and can cause issues like interface flaps. Always use ios_config for configuration.
Was this helpful?
03
How do I test idempotency?
Run the playbook twice. The second run should show changed=0. Use --check and --diff to preview changes.
Was this helpful?
04
What is NAPALM and when should I use it?
NAPALM is a multi-vendor library that provides a unified API for network devices. Use it when you need structured data, reliable commit/rollback, or when CLI scraping is unreliable.
Was this helpful?
05
How do I store credentials securely?
Use ansible-vault to encrypt variables. Store the vault password in a secure location (e.g., secrets manager) and reference it in your automation.
Was this helpful?
06
Why does my playbook hang on 'Connecting to device'?
Check SSH connectivity, ensure ansible_connection is network_cli, and verify ansible_user and ansible_password are correct.
Was this helpful?
07
What does `parents` do in `ios_config`?
parents specifies the configuration hierarchy (e.g., interface GigabitEthernet0/1) so the module knows where to apply the lines.
Was this helpful?
08
Can I use `--check` with network modules?
Some modules support --check, but not all. Test in a lab. When in doubt, use --diff without --check to see what would change.