Git Product home page Git Product logo

ansible-resource-format's Introduction

Ansible Resource Format

This plugin transforms a set of Node resources into an Ansible dynamic inventory format

Build and install

To build the plugin use:

gradle clean build

To install, copy the jar file to rundeck:

cp build/libs/ansible-resource-format-X.X.X.jar $RDECK_BASE/libext

How to use

  • On the resource API URL , add the parameter format with the value ansible-inventory. For example:
http://rundeck:4440/api/26/project/<Project>/resources?authtoken=<Token>&format=ansible-inventory
  • create a python file to add the dynamic inventory, see an example on example/rundeck-inventory.py

  • test the dynamic inventory:

python example/rundeck-inventory.py

You should see something like:

{
  "_meta": {
    "hostvars": {
      "localhost": {
        "ansible_connection": "ssh",
        "ansible_host": "localhost",
        "description": "Rundeck server node",
        "hostname": "localhost",
        "nodename": "localhost",
        "osArch": "x86_64",
        "osFamily": "unix",
        "osName": "Mac OS X",
        "osVersion": "10.13.6"
      },
      "remotenode": {
        "ansible_connection": "ssh",
        "ansible_host": "192.168.0.13",
        "ansible_user": "rundeck",
        "custom:test": "This is a test",
        "hostname": "192.168.0.13",
        "nodename": "remotenode",
        "osFamily": "Centos",
        "osName": "Centos7",
        "osType": "X86-64",
        "username": "rundeck"
      }
    }
  },
  "rundeck": {
    "children": [
       "centos7"
    ],
    "hosts": [
      "localhost"
    ]
  },
  "centos7": {
      "hosts": [
        "remotenode"
      ]
  }
}

Rundeck tags are transform on Ansible groups.

  • Use the Ansible inventory:
ansible -i rundeck-inventory.py all -m ping

or filtering by tag

ansible -i rundeck-inventory.py centos7 -m ping

ansible-resource-format's People

Contributors

ltamaster avatar sjrd218 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.