Giter VIP home page Giter VIP logo

phpipam-api's Introduction

Playbooks for interacting with the phpipam api

With a working phpipam install you can enable the api and use these interactions inside of playbooks. You will need to configure the app id and create a user that will be accessing this api in order to gather a token.

Setting up the API for usage in Ansible

Inside of the gui you will need to navigate to the API section under administration. Here you can configure the app id for the API Next you will need to navigate to the Users section to create your API user

Interacting with the API

To find the subnets and to populate specific variables you'll need to poke around the API with postman or curl.

using curl to return a token: curl -k https://ipam.example.com/api/phpipamappid/user/ -X POST -u <username>:<password>

grabbing the token from the returned json output: curl -k https://ipam.example.com/api/phpipamappid/sections/ --header "token: .J1e9ipFZkPE6EvIRAqEf9hp" -X GET

Once you have the ID of the sections this can be used to get the subnets inside this section. curl -k https://ipam.example.com/api/phpipamappid/sections/{ID}/ --header "token: .J1e9ipFZkPE6EvIRAqEf9hp" -X GET

This will list all of the subents in this section, and you'll want to grab the id from the returned objects

"id": <number>,
...

This is where the subnet_id: variable is populated.

Reserve IP example Playbook

reserve_ip.yml playbook is an example of using the URI module to make an api call, register the output to populate variables, making calls to register an ip, and update phpipam's database.

To generate the encrypted value to populate the vault password for the api_pass variable you will need to generate this with ansible-vault. https://docs.ansible.com/ansible/2.4/vault.html

One all of the values in the group_vars/all file are set to match your environment and only then will the playbook succeed. Making the call to the API will pull down the token which is then stored in a variable and used throughout the playbook

phpipam documentation https://phpipam.net/api/api_documentation/

phpipam-api's People

Contributors

chaoticmind avatar mljosev avatar nullconfig avatar

Watchers

 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.