Code Monkey home page Code Monkey logo

ciscoaci's Introduction

CiscoACI

Hostvar Based Ansible Playbook for Cisco ACI

Utilizes Host based specific variables as inputs for the playbook.

This format is based on the My All in One, Device Specific YAML File for Ansible hostvar scheme.

The state need to be set to present, absent or query for playbook task activation

Example:

Hostvar File: lab-apic.yml

aci_apic:
  hostname: 'lab-apic'
  location_domain_name: "example.com"
  ipv4: 10.100.1.1
  mask: 255.255.255.0
  gw: 10.100.1.254

tns:
  - name: 'DevQA1'
    state: absent

  - name: 'common'
    state: ignore

  - name: 'DevQA2'
    state: present

Playbook Task:

  - name: Load APIC Variable File
    include_vars: "hostvars/{{ inventory_hostname }}.yml"

  - name: TN Task
    aci_tenant:
      host: "{{ aci_apic.ipv4 }}"
      username: "{{ username }}"
      password: "{{ password }}"
      validate_certs: no
      tenant: "{{ item.name }}"
      description: "{{ reference }}"
      state: "{{ item.state }}"
    delegate_to: localhost
    register: result_tn
    when: (item.state == "present" or item.state == "absent" or item.state == "query")
    with_items:
      - "{{ tns }}"

In the above example the playbook will perform the following actions

  1. The tenant DevQA1 will be deleted from the APIC
  2. The tenant common will remain untouched or ignored
  3. The tenant DevQA2 will be added to the APIC

ACI_Net_SimpleBuild Playbook

  • Creates:
    • Tenants
    • VRF(s)

ACI_Ops_SimpleBuild Playbook

  • Creates:
    • AP(s)
    • BD(s)
    • BD Subnet(s)
    • EPG(s)

The playbook requires at least a basic inventory for the call {{ inventory_hostname }}

[all:vars]
ansible_python_interpreter=/usr/bin/python
ansible_connection = local

[aci:children]
aci_prod
aci_dev

[aci_dev]
lab-apic ansible_host=10.100.1.1

[aci_prod]
prod-apic ansible_host=10.200.1.1

Playbook commands (Host: lab-apic.yml) Using included inventory:

ansible-playbook ACI_Net_SimpleBuild.yml -i inventory -l lab-apic
ansible-playbook ACI_Ops_SimpleBuild.yml -i inventory -l lab-apic

ciscoaci's People

Contributors

jrosa770 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.