All Projects → davidban77 → Ansible Collection Gns3

davidban77 / Ansible Collection Gns3

Licence: mit
Ansible Collection for GNS3 Server REST API using gns3fy

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Ansible Collection Gns3

Rollback
Ansible role to rollback scripting applications like PHP, Python, Ruby, etc. in a capistrano style
Stars: ✭ 230 (+1110.53%)
Mutual labels:  ansible, playbook
Ansible Role Mysql
Ansible Role - MySQL
Stars: ✭ 826 (+4247.37%)
Mutual labels:  ansible, playbook
Ansible Playbook Grapher
A command line tool to create a graph representing your Ansible playbook tasks and roles
Stars: ✭ 234 (+1131.58%)
Mutual labels:  ansible, playbook
Ansible Nginx Hardening
This Ansible role provides secure nginx configurations.
Stars: ✭ 180 (+847.37%)
Mutual labels:  ansible, playbook
Ansible For Devops
Ansible for DevOps examples.
Stars: ✭ 5,265 (+27610.53%)
Mutual labels:  ansible, playbook
Ansible Ubuntu
Ansible scripts to setup Ubuntu desktop/server
Stars: ✭ 182 (+857.89%)
Mutual labels:  ansible, playbook
Cp Ansible
Ansible playbooks for the Confluent Platform
Stars: ✭ 285 (+1400%)
Mutual labels:  ansible, playbook
Redfish Ansible Module
Ansible modules for Out-Of-Band Controllers using Redfish APIs
Stars: ✭ 139 (+631.58%)
Mutual labels:  ansible, playbook
Ansible Role Php
Ansible Role - PHP
Stars: ✭ 396 (+1984.21%)
Mutual labels:  ansible, playbook
Mac Dev Playbook
Mac setup and configuration via Ansible.
Stars: ✭ 4,202 (+22015.79%)
Mutual labels:  ansible, playbook
Ansible Collection Hardening
This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
Stars: ✭ 2,543 (+13284.21%)
Mutual labels:  ansible, playbook
Debops
DebOps - Your Debian-based data center in a box
Stars: ✭ 734 (+3763.16%)
Mutual labels:  ansible, playbook
Graylog Ansible Role
Ansible role which installs and configures Graylog
Stars: ✭ 173 (+810.53%)
Mutual labels:  ansible, playbook
Nci Ansible Ui
Simple web interface for running Ansible playbooks
Stars: ✭ 217 (+1042.11%)
Mutual labels:  ansible, playbook
Terrible
An Ansible playbook that apply the principle of the Infrastructure as Code on a QEMU/KVM environment.
Stars: ✭ 161 (+747.37%)
Mutual labels:  ansible, playbook
Ansible Elk
📊 Ansible playbook for setting up an ELK/EFK stack and clients.
Stars: ✭ 284 (+1394.74%)
Mutual labels:  ansible, playbook
Ansible Mysql Hardening
This Ansible role provides security configuration for MySQL.
Stars: ✭ 132 (+594.74%)
Mutual labels:  ansible, playbook
Ansible Role K3s
Ansible role for installing k3s as either a standalone server or HA cluster.
Stars: ✭ 132 (+594.74%)
Mutual labels:  ansible, playbook
Ansible Freeipa
Ansible roles and modules for FreeIPA
Stars: ✭ 284 (+1394.74%)
Mutual labels:  ansible, playbook
Kubeadm Playbook
Fully fledged (HA) Kubernetes Cluster using official kubeadm, ansible and helm. Tested on RHEL/CentOS/Ubuntu with support of http_proxy, dashboard installed, ingress controller, heapster - using official helm charts
Stars: ✭ 533 (+2705.26%)
Mutual labels:  ansible, playbook

Ansible Module for GNS3

Ansible-Galaxy collections repository for GNS3 Server REST API using gns3fy - see the docs.

Installation

For the module to be used you need to have installed gns3fy

pip install gns3fy

This collections is packaged under ansible-galaxy, so to install it you need mazer from Ansible Projects:

mazer install davidban77.gns3

Features

  • Open/closes projects.
  • Starts/stops all nodes inside a project, or it can be done sequentially with a delay factor.
  • Creates/Updates projects with nodes and links specified as variables in a playbook.
  • Deletes projects safely by stopping nodes, if there are any, then closing the project and finally deleting it.
  • Creates/Deletes/Restores snapshots of projects.
  • Retrieves information about available emulators on the GNS3 server compute, as well as available images, console ports, version, etc..
  • Idempotency is present in all actions. An example could be reflected in a playbook that creates a project with nodes and links, these settings will not be executed again on a rerun (and by settings I mean projects settings, nodes and links)/

Modules

These are the modules provided with this collection:

  • gns3_version: Retrieves GNS3 server version. (TO BE DEPRECATED with the gns3_facts module)
  • gns3_facts: Retrieves the compute(s) information of a GNS3 server
  • gns3_project: Module to interact with GNS3 server projects
    • It opens/closes projects and performs basic turnup/teradown operations on nodes.
    • It creates/updates or deletes projects, with the respective nodes and links specified
  • gns3_project_file: Updates/creates a file on a project directory.
  • gns3_snapshot: Module that interacts with snapshots of a project on GNS3 server.
  • gns3_node: Module to operate a node in a GNS3 server project.
  • gns3_node_file: Updates/creates a file on a node directory.
  • gns3_nodes_inventory: Retrieves GNS3 a project nodes console information.

Examples: using the module

Here are some examples of how to use the module.

Get server version

---
- host: localhost
  # Call the collections to use the respective modules
  collections:
    - davidban77.gns3
  vars:
    gns3_url: http://localhost
  tasks:
    - name: Get the server facts
      gns3_facts:
        url: "{{ gns3_url }}"
        port: 3080
        get_images: all
        get_compute_ports: yes
      register: result

    - debug: var=result

Get nodes_inventory information from a project

---
- host: localhost
  # Call the collections to use the respective modules
  collections:
    - davidban77.gns3
  vars:
    gns3_url: http://localhost
  tasks:
    - name: Get the server version
      gns3_nodes_inventory:
        url: "{{ gns3_url }}"
        project_name: lab_example
      register: result

    - debug: var=result

Manipulate GNS3 projects

---
# Open a GNS3 project
- name: Start lab
  gns3_project:
    url: "{{ gns3_url }}"
    state: opened
    project_name: lab_example

# Stop all nodes inside an open project
- name: Stop nodes
  gns3_project:
    url: "{{ gns3_url }}"
    state: opened
    project_name: lab_example
    nodes_state: stopped
    nodes_strategy: all
    poll_wait_time: 5

# Open a GNS3 project and start nodes one by one with a delay of 10sec between them
- name: Start nodes one by one
  gns3_project:
    url: "{{ gns3_url }}"
    state: opened
    project_name: lab_example
    nodes_state: started
    nodes_strategy: one_by_one
    nodes_delay: 10

# Close a GNS3 project
- name: Stop lab
  gns3_project:
    url: "{{ gns3_url }}"
    state: closed
    project_id: "UUID-SOMETHING-1234567"

Create and delete projects

---
# Create a GNS3 project given nodes and links specifications
- name: Create a project
  gns3_project:
    url: "{{ gns3_url }}"
    state: present
    project_name: new_lab
    nodes_spec:
        - name: alpine-1
          template: alpine
        - name: alpine-2
          template: alpine
    links_spec:
        - ['alpine-1', 'eth0', 'alpine-2', 'eth1']

# Delete a GNS3 project
- name: Delete project
  gns3_project:
    url: "{{ gns3_url }}"
    state: absent
    project_name: new_lab

Examples: using the roles

There are also some convinient roles that you can use to manage your labs. Here is an example playbook:

main.yml

- hosts: localhost
  tasks:
    - import_role:
        name: create_lab
      when: execute == "create"
    - import_role:
        name: delete_lab
      when: execute == "delete"

This way you can call and switch the behaviour of the playbook:

Create the lab

ansible-playbook main.yml -e execute=create

Or delete the lab

ansible-playbook main.yml -e execute=delete

Here is the example variable file which specifies the naming convention used. You can see that the variable names come from the module itself with only gns3_

---
gns3_url: "http://dev_gns3server"
gns3_project_name: test_ansible
gns3_nodes_spec:
    - name: veos-1
      template: "vEOS-4.21.5F"
    - name: veos-2
      template: "vEOS-4.21.5F"
    - name: ios-1
      template: "IOU-15.4"
    - name: ios-2
      template: "IOU-15.4"
gns3_nodes_strategy: one_by_one
gns3_links_spec:
    - ["veos-1", "Ethernet1", "veos-2", "Ethernet1"]
    - ["veos-1", "Ethernet2", "ios-1", "Ethernet1/0"]
    - ["veos-2", "Ethernet2", "ios-2", "Ethernet1/0"]
    - ["ios-1", "Ethernet1/2", "ios-2", "Ethernet1/2"]

More examples

For more examples like create an /etc/network/interfaces file for an alpine docker node to configure its network interfaces, or restore a project to an specific snapshot, you can go to the test/playbooks directory.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].