• No results found

Key Technical Concepts

Play​books

Play​books spec​ify a list of tasks that are run in se​quence across one or more hosts. Each task can also run mul​ti​ple times with a vari​able tak​ing a dif​fer​ent value. Play​books are ex​pressed in YAML for​mat.

In​ven​tory

In​ven​tory is the rep​re​sen​ta​tion of in​for​ma​tion about hosts — what groups a host be​longs to, the prop​er​ties those groups and hosts have. A hi​er​ar​chy of groups often re​sults.

Tem​plates

Tem​plates allow you to gen​er​ate con​fig​u​ra​tion files from val​ues set in var​i​ous in​ven​tory prop​-er​ties. This means that you can store one tem​plate in source con​trol that ap​plies to many dif​-fer​ent en​vi​ron​ments.

Roles

Roles are a way to en​cap​su​late com​mon tasks and prop​er​ties for reuse, if you find your​self writ​-ing the same tasks in mul​ti​ple play​books, turn them into roles.

Sam​ple Play​book To Con​fig​ure VLANs:

cisco@linux-dev:~/nxos-ansible/ansible_playbooks$ more vlans.yml # vlans.yml

nxos_vlan: vlan_id="2-20,99" state=present host={{ inventory_hostname }}

- name: config VLANs names for a few VLANs

nxos_vlan: vlan_id={{ item.vid }} name={{ item.name }} host={{ inventory_hostname }}

state=present with_items:

- { vid: 2, name: web } - { vid: 3, name: app }

- { vid: 4, name: db } - { vid: 20, name: server } - { vid: 99, name: native }

An​si​ble Ref​er​ence Links

https://​github.​com/​datacenter/​nxos-ansible http://​docs.​ansible.​com/​ansible/​

Chef

Introduction

Chef is a pow​er​ful au​toma​tion plat​form that trans​forms com​plex in​fra​struc​ture into code, en​-abling your data cen​ter in​fra​struc​ture au​toma​tion using a de​clar​a​tive, in​tent-based model.

Whether you’re op​er​at​ing in the cloud, on-premises, or a hy​brid, Chef au​to​mates how ap​pli​ca​-tions are con​fig​ured, de​ployed, and man​aged across your net​work, no mat​ter its size.

Chef is built around sim​ple con​cepts: achiev​ing de​sired state, cen​tral​ized mod​el​ing of IT in​fra​-struc​ture, and re​source prim​i​tives that serve as build​ing blocks. These con​cepts en​able you to quickly man​age any in​fra​struc​ture with Chef. These very same con​cepts allow Chef to han​dle the most dif​fi​cult in​fra​struc​ture chal​lenges and cus​tomer use-cases, any​thing that can run the chef-client can be man​aged by Chef.

Key Technical Concepts

Chef Server

The Chef server acts as a hub for con​fig​u​ra​tion data. It stores:

• Cookbooks

• Recipes (The policies that are applied to nodes)

• Metadata that describes each registered node that is being managed by the chef-client.

Node

Any phys​i​cal, vir​tual, or cloud ma​chine or switch con​fig​ured to be main​tained by a chef-client.

Chef Client

Runs lo​cally on every node that is reg​is​tered with the Chef server. Per​forms all con​fig​u​ra​tion tasks spec​i​fied by the run-list and brings client into de​sired state.

Chef Re​sources

Term used for a group​ing of man​aged ob​jects/at​trib​utes and one or more cor​re​spond​ing im​-ple​men​ta​tions. It de​scribes the de​sired state for a con​fig​u​ra​tion item and de​clares the steps needed to bring that item to the de​sired state. It spec​i​fies a re​source type—such as a pack​age, tem​plate or ser​vice, and lists ad​di​tional de​tails (also known as at​trib​utes), as nec​es​sary. These are grouped into recipes, which de​scribe work​ing con​fig​u​ra​tions

The 2 core lay​ers of a re​source:

• Resource Type: Definition of managed objects.

• Resource Provider: Implementation of management tasks on objects.

Cook​book

A cook​book de​fines a sce​nario and con​tains every​thing that is re​quired to sup​port that sce​-nario, and is used for de​vice con​fig​u​ra​tion and pol​icy dis​tri​b​u​tion:

• Recipes that specify the resources to use and the order in which they are to be applied

• Attribute values

• File distributions

• Templates

• Extensions to Chef, such as libraries, definitions, and custom resources Recipe

A col​lec​tion of re​sources, de​fined using pat​terns (re​source names, at​tribute-value pairs, and ac​-tions); helper code is added around this using Ruby:

• Must be stored in a cookbook

• May use the results of a search query and read the contents of a data bag

• May have a dependency on one (or more) recipes

• Must be added to a run-list before it can be used by the chef-client

• Is always executed in the same order as listed in a run-list

• The chef-client will run a recipe only when asked

Sam​ple Cook​book Show​ing Con​fig​u​ra​tion of Switch In​ter​face as L3 or L2:

cisco_interface 'Ethernet1/1' do action :create

ipv4_address '10.1.1.1' ipv4_netmask_length 24 ipv4_proxy_arp true ipv4_redirects true shutdown true

switchport_mode 'disabled' end

switchport_mode 'access' switchport_vtp true end

Related documents