Coder Social home page Coder Social logo

ansible-virl's Introduction

ansible-virl

Ansible Modules for VIRL^2/CML^2

Installation

via pip

  pip install ansible-virl

via ansible-galaxy

  ansible-galaxy install '[email protected]:CiscoDevNet/ansible-virl.git'

Environmental Variables

  • VIRL_USERNAME: Username for the VIRL user (used when host not specified)
  • VIRL_PASSWORD: Password for the VIRL user (used when password not specified)
  • VIRL_HOST: The VIRL host (used when host not specified)
  • VIRL_LAB: The name of the lab

Inventory

To use the dynamic inventory plugin, the environmental variabiles must be set and a file (e.g. virl.yml) placed in the inventory specifying the plugin information:

plugin: virl

The dynamic inventory script will then return information about the nodes in the lab:

ok: [hq-host1] => {
    "virl_facts": {
        "config": "#cloud-config\npassword: admin\nchpasswd: { expire: False }\nssh_pwauth: True\nhostname: hq-host1\nruncmd:\n - sudo ip address add 10.0.1.10/24 dev enp0s2\n - sudo ip link set dev enp0s2 up\n - sudo ip route add default via 10.0.1.1\n",
        "cpus": null,
        "data_volume": null,
        "image_definition": "ubuntu-18-04",
        "interfaces": [
            {
                "ipv4_addresses": [],
                "ipv6_addresses": [],
                "mac_address": "52:54:00:13:1b:fb",
                "name": "enp0s2",
                "state": "STARTED"
            }
        ],
        "node_definition": "ubuntu",
        "ram": null,
        "state": "BOOTED"
    }
}

Example Playbooks

Create a Lab

- name: Create the lab
  virl_lab:
    host: "{{ virl_host }}"
    user: "{{ virl_username }}"
    password: "{{ virl_password }}"
    lab: "{{ virl_lab }}"
    state: present
    file: "{{ virl_lab_file }}"
  register: results

Start a Node

- name: Start Node
  virl_node:
    name: "{{ inventory_hostname }}"
    host: "{{ virl_host }}"
    user: "{{ virl_username }}"
    password: "{{ virl_password }}"
    lab: "{{ virl_lab }}"
    state: started
    image_definition: "{{ virl_image_definition | default(omit) }}"
    config: "{{ day0_config | default(omit) }}"

Collect facts about the Lab

- name: Collect Facts
  virl_lab_facts:
    host: "{{ virl_host }}"
    user: "{{ virl_username }}"
    password: "{{ virl_password }}"
    lab: "{{ virl_lab }}"
  register: result

License

GPLv3

ansible-virl's People

Contributors

jlothian avatar rschmied avatar stevenca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-virl's Issues

Please add some examples how to run

Hi guys,

After setting env variables and specifying "plugin: virl" in "virl.yml", it should run with dynamic inventory script, right?
Why after executing 'ansible-inventory virl.yml --graph" i get nothing?
What does host not specified mean in: VIRL_USERNAME: Username for the VIRL user (used when host not specified) ?

Please add some example/update docs on how to run.

Module creates groups with "invalid" characters

The ansible-virl module tries to create groups out of the various node definitions it finds in the running simulation. In so doing, it picks up whatever node definition names are in the simulation as group names. If these include invalid characters, then Ansible complains.

Example:

    "viptela-bond": {
        "hosts": [
            "vbond1"
        ]
    },
    "viptela-edge": {
        "hosts": [
            "site2-vedge1"
        ]
    },
    "viptela-manage": {
        "hosts": [
            "vmanage1"
        ]
    },
    "viptela-smart": {
        "hosts": [
            "vsmart1"
        ]
    },

Do we really need to create groups based on node definition? If so, we might want to do some character substitution either via Ansible configuration or within the module itself in order to avoid this warning:

[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but still be user configurable 
on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

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.