SlideShare uma empresa Scribd logo
1 de 11
Baixar para ler offline
Developing Ansible
Dynamic Inventory Script
Ahmed AbouZaid
@aabouzaid
About
Ahmed AbouZaid
A passionate DevOps Engineer, author and Free/Open source geek
who loves the community.
Automation, data, and metrics are my preferred areas.
I have a built-in monitoring chip, and too lazy to do anything manually :D
Blog | Github | Twitter
Intro
● Ansible inventory.
● Ansible dynamic inventory.
● Write your own inventory script.
● Netbox external inventory script.
● Tips and tricks.
Ansible inventory
● Static file (default is INI-like, but could be YAML too).
● Define hosts, groups, and vars.
● Could be a directory has multiple inventory sources.
● Has many limitations and hard to manage.
Ansible dynamic inventory
● Dynamic data source (obviously).
● External data source like EC2 or OpenStack or whatever.
● Almost any source could be a dynamic inventory for ansible.
Ansible dynamic inventory script
● Scripts written in any programming language.
● Should return data in JSON format.
● Use a convention (”--list” to get all hosts, and “--host” to get one host).
● Example:
ansible -i netbox.py all -m ping
Netbox dynamic inventory script
● The script gets hosts lists via Netbox API as a dynamic data source.
● Netbox is an IPAM and DCIM tool from DigitalOcean
network engineering team, which serves as a "Source of Truth".
● I opened the PR on Feb 2017 and approved on Oct 2017.
● It has been reviewed by Ansible community (6 peoples were involved).
● Repos:
https://github.com/digitalocean/netbox
https://github.com/AAbouZaid/netbox-as-ansible-inventory
Related to script stuff:
● YAML or INI config file.
● Must be PEP8 compliant.
● Support Python 2.6/2.7 and 3.5/3.6.
● Avoid code smells (Ansible sanity, online services).
● Write unit test (e.g. pytest).
Tips & Tricks
Tips & Tricks
Around script stuff:
● Create its own repository.
● Create a setup.py file.
● Push it to PyPI (so it could be used with pip).
● Use CI to run tests (e.g. Travis CI).
Resources
● https://docs.ansible.com/ansible/latest/intro_inventory.html
● https://docs.ansible.com/ansible/latest/intro_dynamic_inventory.html
● https://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html
Questions?
Thanks :-)

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Virtual training Intro to InfluxDB & Telegraf
Virtual training  Intro to InfluxDB & TelegrafVirtual training  Intro to InfluxDB & Telegraf
Virtual training Intro to InfluxDB & Telegraf
 
Influx/Days 2017 San Francisco | Dan Cech
Influx/Days 2017 San Francisco | Dan Cech Influx/Days 2017 San Francisco | Dan Cech
Influx/Days 2017 San Francisco | Dan Cech
 
Getting started with influx Db and Grafana Installation Guide
Getting started with influx Db and Grafana Installation GuideGetting started with influx Db and Grafana Installation Guide
Getting started with influx Db and Grafana Installation Guide
 
Introduction to influx db
Introduction to influx dbIntroduction to influx db
Introduction to influx db
 
Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...
Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...
Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...
 
InfluxDb
InfluxDbInfluxDb
InfluxDb
 
Need for Time series Database
Need for Time series DatabaseNeed for Time series Database
Need for Time series Database
 
InfluxDB & Kubernetes
InfluxDB & KubernetesInfluxDB & Kubernetes
InfluxDB & Kubernetes
 
DOWNSAMPLING DATA
DOWNSAMPLING DATADOWNSAMPLING DATA
DOWNSAMPLING DATA
 
Tick Stack - Listen your infrastructure and please sleep
Tick Stack - Listen your infrastructure and please sleepTick Stack - Listen your infrastructure and please sleep
Tick Stack - Listen your infrastructure and please sleep
 
Kapacitor Stream Processing
Kapacitor Stream ProcessingKapacitor Stream Processing
Kapacitor Stream Processing
 
A TRUE STORY ABOUT DATABASE ORCHESTRATION
A TRUE STORY ABOUT DATABASE ORCHESTRATIONA TRUE STORY ABOUT DATABASE ORCHESTRATION
A TRUE STORY ABOUT DATABASE ORCHESTRATION
 
InfluxDB 2.0: Dashboarding 101 by David G. Simmons
InfluxDB 2.0: Dashboarding 101 by David G. SimmonsInfluxDB 2.0: Dashboarding 101 by David G. Simmons
InfluxDB 2.0: Dashboarding 101 by David G. Simmons
 
How to Build a Monitoring Application in 20 Minutes | Russ Savage | InfluxData
How to Build a Monitoring Application in 20 Minutes | Russ Savage | InfluxDataHow to Build a Monitoring Application in 20 Minutes | Russ Savage | InfluxData
How to Build a Monitoring Application in 20 Minutes | Russ Savage | InfluxData
 
Grafana introduction
Grafana introductionGrafana introduction
Grafana introduction
 
Intro to Kapacitor for Alerting and Anomaly Detection
Intro to Kapacitor for Alerting and Anomaly DetectionIntro to Kapacitor for Alerting and Anomaly Detection
Intro to Kapacitor for Alerting and Anomaly Detection
 
How Sensor Data Can Help Manufacturers Gain Insight to Reduce Waste, Energy C...
How Sensor Data Can Help Manufacturers Gain Insight to Reduce Waste, Energy C...How Sensor Data Can Help Manufacturers Gain Insight to Reduce Waste, Energy C...
How Sensor Data Can Help Manufacturers Gain Insight to Reduce Waste, Energy C...
 
InfluxData Architecture for IoT | Noah Crowley | InfluxData
InfluxData Architecture for IoT | Noah Crowley | InfluxDataInfluxData Architecture for IoT | Noah Crowley | InfluxData
InfluxData Architecture for IoT | Noah Crowley | InfluxData
 
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow FlightThe Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
The Data Lake Engine Data Microservices in Spark using Apache Arrow Flight
 
Intro to InfluxDB 2.0 and Your First Flux Query by Sonia Gupta
Intro to InfluxDB 2.0 and Your First Flux Query by Sonia GuptaIntro to InfluxDB 2.0 and Your First Flux Query by Sonia Gupta
Intro to InfluxDB 2.0 and Your First Flux Query by Sonia Gupta
 

Semelhante a Developing Ansible Dynamic Inventory Script - Nov 2017

Semelhante a Developing Ansible Dynamic Inventory Script - Nov 2017 (20)

Intro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetupIntro to-ansible-sep7-meetup
Intro to-ansible-sep7-meetup
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Ansible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-presAnsible nice-pdf-copy-for-pres
Ansible nice-pdf-copy-for-pres
 
Why we chose Argo Workflow to scale DevOps at InVision
Why we chose Argo Workflow to scale DevOps at InVisionWhy we chose Argo Workflow to scale DevOps at InVision
Why we chose Argo Workflow to scale DevOps at InVision
 
A quick intro to Ansible
A quick intro to AnsibleA quick intro to Ansible
A quick intro to Ansible
 
Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
 
Ansible Berlin Meetup Intro talk by @danvaida
Ansible Berlin Meetup Intro talk by @danvaidaAnsible Berlin Meetup Intro talk by @danvaida
Ansible Berlin Meetup Intro talk by @danvaida
 
Ansible and CloudStack
Ansible and CloudStackAnsible and CloudStack
Ansible and CloudStack
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Introduction to Ansible. Meetup Infracoders
Introduction to Ansible. Meetup InfracodersIntroduction to Ansible. Meetup Infracoders
Introduction to Ansible. Meetup Infracoders
 
Ansible Inventory Plugins
Ansible Inventory PluginsAnsible Inventory Plugins
Ansible Inventory Plugins
 
Elasticwulf Pycon Talk
Elasticwulf Pycon TalkElasticwulf Pycon Talk
Elasticwulf Pycon Talk
 
Apache Avro in LivePerson [Hebrew]
Apache Avro in LivePerson [Hebrew]Apache Avro in LivePerson [Hebrew]
Apache Avro in LivePerson [Hebrew]
 
Behind the Scenes at Coolblue - Feb 2017
Behind the Scenes at Coolblue - Feb 2017Behind the Scenes at Coolblue - Feb 2017
Behind the Scenes at Coolblue - Feb 2017
 
PyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applicationsPyConIT 2018 Writing and deploying serverless python applications
PyConIT 2018 Writing and deploying serverless python applications
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
 
eZ Publish nextgen
eZ Publish nextgeneZ Publish nextgen
eZ Publish nextgen
 
Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015Ansible is the simplest way to automate. SymfonyCafe, 2015
Ansible is the simplest way to automate. SymfonyCafe, 2015
 

Mais de Ahmed AbouZaid

Mais de Ahmed AbouZaid (8)

Platform Engineering: Manage your infrastructure using Kubernetes and Crossplane
Platform Engineering: Manage your infrastructure using Kubernetes and CrossplanePlatform Engineering: Manage your infrastructure using Kubernetes and Crossplane
Platform Engineering: Manage your infrastructure using Kubernetes and Crossplane
 
Kubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS examKubernetes Security Best Practices - With tips for the CKS exam
Kubernetes Security Best Practices - With tips for the CKS exam
 
Docker Best Practices Workshop
Docker Best Practices WorkshopDocker Best Practices Workshop
Docker Best Practices Workshop
 
Kubernetes Requests and Limits
Kubernetes Requests and LimitsKubernetes Requests and Limits
Kubernetes Requests and Limits
 
DevOps for Engineers
DevOps for EngineersDevOps for Engineers
DevOps for Engineers
 
How contributing to Open-source made me a better DevOps
How contributing to Open-source made me a better DevOpsHow contributing to Open-source made me a better DevOps
How contributing to Open-source made me a better DevOps
 
Getting Started with Ansible
Getting Started with AnsibleGetting Started with Ansible
Getting Started with Ansible
 
Why Ubuntu? - Arabic
Why Ubuntu? - ArabicWhy Ubuntu? - Arabic
Why Ubuntu? - Arabic
 

Último

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Developing Ansible Dynamic Inventory Script - Nov 2017

  • 1. Developing Ansible Dynamic Inventory Script Ahmed AbouZaid @aabouzaid
  • 2. About Ahmed AbouZaid A passionate DevOps Engineer, author and Free/Open source geek who loves the community. Automation, data, and metrics are my preferred areas. I have a built-in monitoring chip, and too lazy to do anything manually :D Blog | Github | Twitter
  • 3. Intro ● Ansible inventory. ● Ansible dynamic inventory. ● Write your own inventory script. ● Netbox external inventory script. ● Tips and tricks.
  • 4. Ansible inventory ● Static file (default is INI-like, but could be YAML too). ● Define hosts, groups, and vars. ● Could be a directory has multiple inventory sources. ● Has many limitations and hard to manage.
  • 5. Ansible dynamic inventory ● Dynamic data source (obviously). ● External data source like EC2 or OpenStack or whatever. ● Almost any source could be a dynamic inventory for ansible.
  • 6. Ansible dynamic inventory script ● Scripts written in any programming language. ● Should return data in JSON format. ● Use a convention (”--list” to get all hosts, and “--host” to get one host). ● Example: ansible -i netbox.py all -m ping
  • 7. Netbox dynamic inventory script ● The script gets hosts lists via Netbox API as a dynamic data source. ● Netbox is an IPAM and DCIM tool from DigitalOcean network engineering team, which serves as a "Source of Truth". ● I opened the PR on Feb 2017 and approved on Oct 2017. ● It has been reviewed by Ansible community (6 peoples were involved). ● Repos: https://github.com/digitalocean/netbox https://github.com/AAbouZaid/netbox-as-ansible-inventory
  • 8. Related to script stuff: ● YAML or INI config file. ● Must be PEP8 compliant. ● Support Python 2.6/2.7 and 3.5/3.6. ● Avoid code smells (Ansible sanity, online services). ● Write unit test (e.g. pytest). Tips & Tricks
  • 9. Tips & Tricks Around script stuff: ● Create its own repository. ● Create a setup.py file. ● Push it to PyPI (so it could be used with pip). ● Use CI to run tests (e.g. Travis CI).