6.6 Recognize what Ansible and Terraform do for configuration management

CCNA 200-301 v1.1 · 6.0 Automation and Programmability

Ansible and Terraform are the configuration management tools the CCNA expects you to recognise. Ansible runs tasks from YAML playbooks over SSH or APIs, with no agent on the devices; Terraform describes the desired infrastructure in HCL and creates or changes it to match. Both keep configuration in files you can review and version.

What you must know

Ansible

Ansible connects from a control node to devices listed in an inventory, over SSH (or NETCONF and APIs), and runs tasks from a playbook written in YAML. Each task calls a module (such as cisco.ios.ios_vlans or ios_config). There is no agent to install on the devices, which suits network gear.

- name: Standard VLANs on every access switch
  hosts: access_switches
  gather_facts: false
  tasks:
    - name: VLANs 10 and 20
      cisco.ios.ios_vlans:
        config:
          - vlan_id: 10
            name: USERS
          - vlan_id: 20
            name: VOICE
        state: merged

The control node pushes the change to each device in turn (1).

Terraform

Terraform describes resources in HCL files: what should exist, not the steps to make it. Providers talk to each platform's API (clouds, Meraki, Catalyst Center, ACI). terraform plan shows what would change; terraform apply makes it so, and a state file remembers what Terraform manages. It is strongest for building infrastructure such as cloud networks, VPCs and SD-WAN or Meraki objects.

AnsibleTerraformPuppet / Chef
LanguageYAML playbooksHCLPuppet DSL / Ruby
StyleMostly procedural (tasks in order)Declarative (end state)Declarative / procedural
AgentAgentless (push)Agentless (API calls)Agent on each node (pull)
Typical useDevice configurationProvisioning infrastructureServer configuration

Commands

ansible-playbook -i inventory vlans.ymlRuns a playbook against the inventory.
terraform plan / terraform applyPreviews and applies infrastructure changes.

Exam traps

Check yourself

Which tool uses YAML playbooks and needs no agent on switches?
Ansible.
What does terraform plan do?
Shows the changes Terraform would make, without making them.

More topics in 6.0 Automation and Programmability