Wednesday, July 17, 2024

Cisco 137 - Ansible, Puppet, and Chef

Ansible
Model: PUSH = Agentless
Action file: Playbook
Protocols: SSH & NETCONF
Uses YAML.
Written in Python.


Puppet

Model: PULL = Requires Agent (or proxy)
Action file: Manifest
Protocols: HTTPS(REST) TCP port 8140
Written in Ruby

Example of Puppet DSL resource declaration:

sudo::conf { 'CoAdmins':
ensure    => present,
content    => '%admin ALL=(ALL) ALL',
}


Chef

Model: PULL = Requires Agent
Action file: Recipe, Runlist
Protocols: HTTPS(REST) TCP port 10002
Written in Ruby

Example of Chef recipe:
sudo "CoAdmins"
    group "CoAdmins"
    nopasswd true


Ansible's playbooks use an imperative language, whereas Puppet uses a declarative language.

Adoption numbers:

Wendell Odom's book says Ansible > Puppet > Chef

Jeremy says Ansible is the most popular choice for network device config management

Boson ExSim says Puppet is most mature and widely used

 


Tuesday, July 16, 2024

Cisco 136 - Python lists and dictionaries

list1 = [ "g0/0", "g0/1", "g0/2" ]

dictionary1 = { "config_speed" : 'auto',

    "config_duplex" : "auto",

    "config_ip" : "10.1.1.1" }

 

^ Notice dictionary uses key:value pairs

 

Cisco 135 - CRUD and REST

CRUD - REST (HTTP) Verb

Create    POST

Read    GET

Update    PATCH, PUT

Delete    DELETE


Cisco 134 - JSON, XML, YAML

---------------> JSON <---------------

JavaScript Object Notation
Attempts to strike balance between human-readable & machine readability
{
  “response” : {
    “type” : “Cisco Catalyst 9300”,
    “family” : “Switches”,
    “macAddr” : “f8:7b:20:67:62:80”
  }
}

Key:Value Pair
Value types:
- Text
- Numeric
- { } Object - Series of key:value pairs
- [ ] Array – Series of values (not key:value pairs)

Example of JSON Array:
[
“Fred”,
“Wilma”,
“Barney”
]

Example of JSON Object:
{
    “Parents”: [
        “Fred”,
        “Wilma”,
        “Barney”,
        “Betty”
    ],
    “Children”: [
        “Pebbles”,
        “Bambam”
    ]
}
^ This JSON object has two arrays within.

---

---------------> XML <---------------

eXtensible Markup Language
<?xml version = “1.0”>
<root>
    <blah>
        <blah1>
        <blah2>
        <blah3>
    </blah>
</root>

---

---------------> YAML <---------------

YAML Ain’t Markup Language
Used heavily in Ansible
#Comment about Playbook
-name: Get IOS Facts
    hosts: mylab
    vars:
        host:  “{{ ansible_host }}”
        username: “{{ username }}”
tasks:
    - ios_facts:
        gather_subset: all
        provider: “{{ cli }}”