SlideShare a Scribd company logo
1 of 29
Download to read offline
Dynamic inventory:
No more host list!
#ansibleja Ansible勉強会#1
2014/06/10
@tagomoris
14年6月10日火曜日
TAGOMORI Satoshi (@tagomoris)
LINE Corp.
14年6月10日火曜日
Ansible
Batch server operations
add routing table entry
deploy ssh keys
update openssl
Install/update middleware
Hadoop, Presto, Fluentd (and its config/code ...)
14年6月10日火曜日
Ansible: good points
Minimal managed node requirements
Simple tool chain and files
YAML
and many built-in modules
Less stress of shell scripts
Dynamic inventory
14年6月10日火曜日
Ansible: bad points
Less japanese case-studies
Less japanese books and blog entries
Less japanese users? -> No!
14年6月10日火曜日
Inventory
Hosts and groups
Host variables / Group variables
Group of groups
‘group_vars/’ and ‘host_vars/’
14年6月10日火曜日
Inventory: example
mail01.local globalip=192.168.0.11
[blog]
www[01:30].blog.local virtualip=203.0.113.63
app[01:50].blog.local
master01.db.blog.local server_id=....
slave0[1:4].blog.local server_id=..????
[linenantoka]
www[01:10].nantoka.line.local
14年6月10日火曜日
ROLEs and TYPEs
Roles (web, app, db, hadoop, ...)
Groups (service-names, ...)
OSs, Server models, Disk types (HDD, SSD, ioDrive, ...)
IP addrs (local, global, virtual)
... and many more
14年6月10日火曜日
Yabitz
Our host management tool/server:
WebUI and WebAPI (json)
hostname[s], status, service, CPU, memory, disk,
rack position, size, local/global/virtual IPs, virtual/
parent server, ....
tags
changes(history, diff)
anything
links to other internal web tools
14年6月10日火曜日
Dynamic inventory
Dynamic inventory plugins
Cobbler external inventory script
Example for linux install server
AWS EC2 external inventory script
Digital Ocean, Google Compute Engine, Linode,
Zabbix, ...
Mix inventories (static and dynamic)
14年6月10日火曜日
Custom dynamic inventory
Original scripts AS dynamic inventory
“Developing Dynamic Inventory Sources”
http://docs.ansible.com/developing_inventory.html
executable program
implement `--list`
implement `--host HOSTNAME`
14年6月10日火曜日
JSON: for `--list`
Dynamic inventory: output
{
"databases": {
"hosts": [ "host1.local", "host2.local" ],
"vars": {
"a": true
}
},
"webservers": [ "host2.local", "host3.local" ],
"tokyo": {
"hosts": [ "host1.local", "host4.local", "host5.local" ],
"vars": {
"b": false
},
"children": [ "shibuya", "ebisu" ]
},
"shibuya": [ "host6.local" ],
"ebisu": [ "host7.local" ]
}
14年6月10日火曜日
JSON: for `--host HOSTNAME`
Dynamic inventory: output
{
“localip”: “192.0.2.53”,
“virtualip”: “203.0.113.53”,
“global_fqdn”: “tagomoris.example.com”,
}
14年6月10日火曜日
Dynamic inventory reference
1. inventory --list
2. inventory --host host1.local
3. inventory --host host2.local
4. inventory --host host4.local
5. ...
14年6月10日火曜日
Playbook execution
$ ansible-playbook PLAYBOOK_PATH.yml
14年6月10日火曜日
Yabitz inventory
ansible-playbook
bin/yabitz_inventory
Yabitz
playbooks/PLAYBOOK.yaml
Servers
14年6月10日火曜日
Role based playbooks
Flat playbook directory
playbooks/*.yaml
playbooks/SERVICE_NAME/*.yaml
“hosts” are always roles
hosts: centos
hosts: centos6
hosts: hadoop-slave
hosts: hadoop-all-nodes:fluentd-all-nodes
14年6月10日火曜日
Yabitz tags and ROLEs
Tags
Server-type-tag (by studio3104 crawler)
centos
centos5, centos6
Role-based-tag
hadoop-all-nodes
hadoop-master, service-hadoop-master2
hadoop-slave
14年6月10日火曜日
Implementation examples
ansible.cfg
[defaults]
hostfile=/path/to/bin/yabitz_inventory
commands
$ ansible-playbook playbooks/update-openssl.yaml
$ TARGET_HOSTS=host1.local,host2.local 
ansible-playbook playbooks/SERVICE/foo.yaml
14年6月10日火曜日
No more host lists!
Ansible inventory is very simple and understandable
But we cannot use it for real world operations
especially for hundreds or thousands of hosts...
Use dynamic inventory!
14年6月10日火曜日
Role based playbook testing
Serverspec
testing without breaking operations
providing double check (beside of ansible)
14年6月10日火曜日
Serverspec directories
from http://serverspec.org/tutorial.html
host based spec directory tree
spec/
SERVERNAME/
function_spec.rb
and exec (`rake spec`)
“How to share serverspec tests among hosts”
http://serverspec.org/advanced_tips.html
static file based test sharing
14年6月10日火曜日
Specs and roles
Role based provisioning
roles-to-hosts resolution MUST be done dynamically
Helper command to get roles from playbooks
and role based spec directory
bin/kick-spec
spec/ROLE/*_spec.rb
14年6月10日火曜日
Implementation example(2)
$ bin/kick-spec playbooks/BOOK.yaml
$ bin/kick-spec playbooks/BOOK.yaml 
--host host1.local --host host2.local
$ bin/kick-spec --role latest_openssl 
--host host5.local
14年6月10日火曜日
Conclusion
DO NOT write same data in 2 or more files
USE master data from anywhere
Dynamic inventory makes it possible!
14年6月10日火曜日
NO MORE HOST
LISTS!!!!!!!!
Thanks!
14年6月10日火曜日
Appendix: “_meta”(1)
Special attribute of JSON for `--list`
To include host variables in single JSON result
No more exec: `--host HOST`
{
“shibuya”: [ “host6.local” ],
“ebisu”: [ “host7.local” ],
“_meta”: {
“hostvars”: {
“host6.local”: { “var1”: “value1”, “var2”: “value2” },
“host7.local”: { .... }
}
}
}
14年6月10日火曜日
Without `_meta`:
`--list` x1 and `--host` x1000 !
With `_meta`:
`--list` x1 only!
Appendix: “_meta”(2)
14年6月10日火曜日
Benchmark: time before task starts
w/ yabitz_inventory
for thousands of hosts
Appendix: “_meta”(3)
w/o _meta w/ _meta
Elapsed time 18min! 10sec!!!!
14年6月10日火曜日

More Related Content

What's hot

Fabric
FabricFabric
Fabric
JS Lee
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
Cloudflare
 

What's hot (20)

Ruby on the server
Ruby on the serverRuby on the server
Ruby on the server
 
Rubyslava + PyVo #48
Rubyslava + PyVo #48Rubyslava + PyVo #48
Rubyslava + PyVo #48
 
Observable Node.js Applications - EnterpriseJS
Observable Node.js Applications - EnterpriseJSObservable Node.js Applications - EnterpriseJS
Observable Node.js Applications - EnterpriseJS
 
JavaScript code academy - introduction
JavaScript code academy - introductionJavaScript code academy - introduction
JavaScript code academy - introduction
 
Fabric
FabricFabric
Fabric
 
Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)Using Capifony for Symfony apps deployment (updated)
Using Capifony for Symfony apps deployment (updated)
 
How to deploy your Rails application on Windows
How to deploy your Rails application on WindowsHow to deploy your Rails application on Windows
How to deploy your Rails application on Windows
 
Jk rubyslava 25
Jk rubyslava 25Jk rubyslava 25
Jk rubyslava 25
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Odoo Performance Limits
Odoo Performance LimitsOdoo Performance Limits
Odoo Performance Limits
 
Traceur - Javascript.next - Now! RheinmainJS April 14th
Traceur - Javascript.next - Now! RheinmainJS April 14thTraceur - Javascript.next - Now! RheinmainJS April 14th
Traceur - Javascript.next - Now! RheinmainJS April 14th
 
Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming Go Profiling - John Graham-Cumming
Go Profiling - John Graham-Cumming
 
Talk about fabric
Talk about fabricTalk about fabric
Talk about fabric
 
Refactoring Katello Installer modules - Ewoud Kohl van Wijngaarden
Refactoring Katello Installer modules - Ewoud Kohl van WijngaardenRefactoring Katello Installer modules - Ewoud Kohl van Wijngaarden
Refactoring Katello Installer modules - Ewoud Kohl van Wijngaarden
 
Automatizando tarefas com grunt - O que era chato não é mais
Automatizando tarefas com grunt - O que era chato não é maisAutomatizando tarefas com grunt - O que era chato não é mais
Automatizando tarefas com grunt - O que era chato não é mais
 
Go debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFxGo debugging and troubleshooting tips - from real life lessons at SignalFx
Go debugging and troubleshooting tips - from real life lessons at SignalFx
 
Simple Tips and Tricks with Ansible
Simple Tips and Tricks with AnsibleSimple Tips and Tricks with Ansible
Simple Tips and Tricks with Ansible
 
Mass-Migration of 5000 Servers to Foreman/Katello with bootstrap.py - Evgeni ...
Mass-Migration of 5000 Servers to Foreman/Katello with bootstrap.py - Evgeni ...Mass-Migration of 5000 Servers to Foreman/Katello with bootstrap.py - Evgeni ...
Mass-Migration of 5000 Servers to Foreman/Katello with bootstrap.py - Evgeni ...
 
Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Fabric - a server management tool from Instagram
Fabric - a server management tool from InstagramFabric - a server management tool from Instagram
Fabric - a server management tool from Instagram
 

Similar to Dynamic Inventory: no more host lists!

Dist::Zilla - Maximum Overkill for CPAN Distributions
Dist::Zilla - Maximum Overkill for CPAN DistributionsDist::Zilla - Maximum Overkill for CPAN Distributions
Dist::Zilla - Maximum Overkill for CPAN Distributions
Ricardo Signes
 

Similar to Dynamic Inventory: no more host lists! (20)

Infrastructure as Code with Chef / Puppet
Infrastructure as Code with Chef / PuppetInfrastructure as Code with Chef / Puppet
Infrastructure as Code with Chef / Puppet
 
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
PHP Conference Argentina 2013 - Independizate de tu departamento IT - Habilid...
 
Ansible @ Red Hat | December 2015 Ansible Meetup in Melbourne
Ansible @ Red Hat | December 2015 Ansible Meetup in MelbourneAnsible @ Red Hat | December 2015 Ansible Meetup in Melbourne
Ansible @ Red Hat | December 2015 Ansible Meetup in Melbourne
 
Tame your Infrastructure with Puppet
Tame your Infrastructure with PuppetTame your Infrastructure with Puppet
Tame your Infrastructure with Puppet
 
Smartgears
SmartgearsSmartgears
Smartgears
 
Ansible
AnsibleAnsible
Ansible
 
Perl family: 15 years of Perl 6 and Perl 5
Perl family: 15 years of Perl 6 and Perl 5Perl family: 15 years of Perl 6 and Perl 5
Perl family: 15 years of Perl 6 and Perl 5
 
Installation of LAMP Server with Ubuntu 14.10 Server Edition
Installation of LAMP Server with Ubuntu 14.10 Server EditionInstallation of LAMP Server with Ubuntu 14.10 Server Edition
Installation of LAMP Server with Ubuntu 14.10 Server Edition
 
Servicios y Herramientas para usar en tu próximo proyecto
Servicios y Herramientas para usar en tu próximo proyectoServicios y Herramientas para usar en tu próximo proyecto
Servicios y Herramientas para usar en tu próximo proyecto
 
Big app design for Node.js
Big app design for Node.jsBig app design for Node.js
Big app design for Node.js
 
Unleashing the Rails Asset Pipeline
Unleashing the Rails Asset PipelineUnleashing the Rails Asset Pipeline
Unleashing the Rails Asset Pipeline
 
Scaling Puppet Usage to a Global Organization
Scaling Puppet Usage to a Global OrganizationScaling Puppet Usage to a Global Organization
Scaling Puppet Usage to a Global Organization
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
OpenNebula, the foreman and CentOS play nice, too
OpenNebula, the foreman and CentOS play nice, tooOpenNebula, the foreman and CentOS play nice, too
OpenNebula, the foreman and CentOS play nice, too
 
Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)Massively Parallel Processing with Procedural Python (PyData London 2014)
Massively Parallel Processing with Procedural Python (PyData London 2014)
 
Docker Continuous Delivery Workshop
Docker Continuous Delivery WorkshopDocker Continuous Delivery Workshop
Docker Continuous Delivery Workshop
 
Brno Perl Mongers 28.5.2015 - Perl family by mj41
Brno Perl Mongers 28.5.2015 - Perl family by mj41Brno Perl Mongers 28.5.2015 - Perl family by mj41
Brno Perl Mongers 28.5.2015 - Perl family by mj41
 
perlall
perlallperlall
perlall
 
Dist::Zilla - Maximum Overkill for CPAN Distributions
Dist::Zilla - Maximum Overkill for CPAN DistributionsDist::Zilla - Maximum Overkill for CPAN Distributions
Dist::Zilla - Maximum Overkill for CPAN Distributions
 
Sayoo odoo open_erp
Sayoo odoo open_erpSayoo odoo open_erp
Sayoo odoo open_erp
 

More from SATOSHI TAGOMORI

More from SATOSHI TAGOMORI (20)

Ractor's speed is not light-speed
Ractor's speed is not light-speedRactor's speed is not light-speed
Ractor's speed is not light-speed
 
Good Things and Hard Things of SaaS Development/Operations
Good Things and Hard Things of SaaS Development/OperationsGood Things and Hard Things of SaaS Development/Operations
Good Things and Hard Things of SaaS Development/Operations
 
Maccro Strikes Back
Maccro Strikes BackMaccro Strikes Back
Maccro Strikes Back
 
Invitation to the dark side of Ruby
Invitation to the dark side of RubyInvitation to the dark side of Ruby
Invitation to the dark side of Ruby
 
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)Hijacking Ruby Syntax in Ruby (RubyConf 2018)
Hijacking Ruby Syntax in Ruby (RubyConf 2018)
 
Make Your Ruby Script Confusing
Make Your Ruby Script ConfusingMake Your Ruby Script Confusing
Make Your Ruby Script Confusing
 
Hijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in RubyHijacking Ruby Syntax in Ruby
Hijacking Ruby Syntax in Ruby
 
Lock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive OperationsLock, Concurrency and Throughput of Exclusive Operations
Lock, Concurrency and Throughput of Exclusive Operations
 
Data Processing and Ruby in the World
Data Processing and Ruby in the WorldData Processing and Ruby in the World
Data Processing and Ruby in the World
 
Planet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: BigdamPlanet-scale Data Ingestion Pipeline: Bigdam
Planet-scale Data Ingestion Pipeline: Bigdam
 
Technologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise BusinessTechnologies, Data Analytics Service and Enterprise Business
Technologies, Data Analytics Service and Enterprise Business
 
Ruby and Distributed Storage Systems
Ruby and Distributed Storage SystemsRuby and Distributed Storage Systems
Ruby and Distributed Storage Systems
 
Perfect Norikra 2nd Season
Perfect Norikra 2nd SeasonPerfect Norikra 2nd Season
Perfect Norikra 2nd Season
 
Fluentd 101
Fluentd 101Fluentd 101
Fluentd 101
 
To Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT ToTo Have Own Data Analytics Platform, Or NOT To
To Have Own Data Analytics Platform, Or NOT To
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and Containers
 
How To Write Middleware In Ruby
How To Write Middleware In RubyHow To Write Middleware In Ruby
How To Write Middleware In Ruby
 
Modern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldModern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real World
 
Open Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud ServiceOpen Source Software, Distributed Systems, Database as a Cloud Service
Open Source Software, Distributed Systems, Database as a Cloud Service
 
Fluentd Overview, Now and Then
Fluentd Overview, Now and ThenFluentd Overview, Now and Then
Fluentd Overview, Now and Then
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

Dynamic Inventory: no more host lists!

  • 1. Dynamic inventory: No more host list! #ansibleja Ansible勉強会#1 2014/06/10 @tagomoris 14年6月10日火曜日
  • 2. TAGOMORI Satoshi (@tagomoris) LINE Corp. 14年6月10日火曜日
  • 3. Ansible Batch server operations add routing table entry deploy ssh keys update openssl Install/update middleware Hadoop, Presto, Fluentd (and its config/code ...) 14年6月10日火曜日
  • 4. Ansible: good points Minimal managed node requirements Simple tool chain and files YAML and many built-in modules Less stress of shell scripts Dynamic inventory 14年6月10日火曜日
  • 5. Ansible: bad points Less japanese case-studies Less japanese books and blog entries Less japanese users? -> No! 14年6月10日火曜日
  • 6. Inventory Hosts and groups Host variables / Group variables Group of groups ‘group_vars/’ and ‘host_vars/’ 14年6月10日火曜日
  • 7. Inventory: example mail01.local globalip=192.168.0.11 [blog] www[01:30].blog.local virtualip=203.0.113.63 app[01:50].blog.local master01.db.blog.local server_id=.... slave0[1:4].blog.local server_id=..???? [linenantoka] www[01:10].nantoka.line.local 14年6月10日火曜日
  • 8. ROLEs and TYPEs Roles (web, app, db, hadoop, ...) Groups (service-names, ...) OSs, Server models, Disk types (HDD, SSD, ioDrive, ...) IP addrs (local, global, virtual) ... and many more 14年6月10日火曜日
  • 9. Yabitz Our host management tool/server: WebUI and WebAPI (json) hostname[s], status, service, CPU, memory, disk, rack position, size, local/global/virtual IPs, virtual/ parent server, .... tags changes(history, diff) anything links to other internal web tools 14年6月10日火曜日
  • 10. Dynamic inventory Dynamic inventory plugins Cobbler external inventory script Example for linux install server AWS EC2 external inventory script Digital Ocean, Google Compute Engine, Linode, Zabbix, ... Mix inventories (static and dynamic) 14年6月10日火曜日
  • 11. Custom dynamic inventory Original scripts AS dynamic inventory “Developing Dynamic Inventory Sources” http://docs.ansible.com/developing_inventory.html executable program implement `--list` implement `--host HOSTNAME` 14年6月10日火曜日
  • 12. JSON: for `--list` Dynamic inventory: output { "databases": { "hosts": [ "host1.local", "host2.local" ], "vars": { "a": true } }, "webservers": [ "host2.local", "host3.local" ], "tokyo": { "hosts": [ "host1.local", "host4.local", "host5.local" ], "vars": { "b": false }, "children": [ "shibuya", "ebisu" ] }, "shibuya": [ "host6.local" ], "ebisu": [ "host7.local" ] } 14年6月10日火曜日
  • 13. JSON: for `--host HOSTNAME` Dynamic inventory: output { “localip”: “192.0.2.53”, “virtualip”: “203.0.113.53”, “global_fqdn”: “tagomoris.example.com”, } 14年6月10日火曜日
  • 14. Dynamic inventory reference 1. inventory --list 2. inventory --host host1.local 3. inventory --host host2.local 4. inventory --host host4.local 5. ... 14年6月10日火曜日
  • 15. Playbook execution $ ansible-playbook PLAYBOOK_PATH.yml 14年6月10日火曜日
  • 17. Role based playbooks Flat playbook directory playbooks/*.yaml playbooks/SERVICE_NAME/*.yaml “hosts” are always roles hosts: centos hosts: centos6 hosts: hadoop-slave hosts: hadoop-all-nodes:fluentd-all-nodes 14年6月10日火曜日
  • 18. Yabitz tags and ROLEs Tags Server-type-tag (by studio3104 crawler) centos centos5, centos6 Role-based-tag hadoop-all-nodes hadoop-master, service-hadoop-master2 hadoop-slave 14年6月10日火曜日
  • 19. Implementation examples ansible.cfg [defaults] hostfile=/path/to/bin/yabitz_inventory commands $ ansible-playbook playbooks/update-openssl.yaml $ TARGET_HOSTS=host1.local,host2.local ansible-playbook playbooks/SERVICE/foo.yaml 14年6月10日火曜日
  • 20. No more host lists! Ansible inventory is very simple and understandable But we cannot use it for real world operations especially for hundreds or thousands of hosts... Use dynamic inventory! 14年6月10日火曜日
  • 21. Role based playbook testing Serverspec testing without breaking operations providing double check (beside of ansible) 14年6月10日火曜日
  • 22. Serverspec directories from http://serverspec.org/tutorial.html host based spec directory tree spec/ SERVERNAME/ function_spec.rb and exec (`rake spec`) “How to share serverspec tests among hosts” http://serverspec.org/advanced_tips.html static file based test sharing 14年6月10日火曜日
  • 23. Specs and roles Role based provisioning roles-to-hosts resolution MUST be done dynamically Helper command to get roles from playbooks and role based spec directory bin/kick-spec spec/ROLE/*_spec.rb 14年6月10日火曜日
  • 24. Implementation example(2) $ bin/kick-spec playbooks/BOOK.yaml $ bin/kick-spec playbooks/BOOK.yaml --host host1.local --host host2.local $ bin/kick-spec --role latest_openssl --host host5.local 14年6月10日火曜日
  • 25. Conclusion DO NOT write same data in 2 or more files USE master data from anywhere Dynamic inventory makes it possible! 14年6月10日火曜日
  • 27. Appendix: “_meta”(1) Special attribute of JSON for `--list` To include host variables in single JSON result No more exec: `--host HOST` { “shibuya”: [ “host6.local” ], “ebisu”: [ “host7.local” ], “_meta”: { “hostvars”: { “host6.local”: { “var1”: “value1”, “var2”: “value2” }, “host7.local”: { .... } } } } 14年6月10日火曜日
  • 28. Without `_meta`: `--list` x1 and `--host` x1000 ! With `_meta`: `--list` x1 only! Appendix: “_meta”(2) 14年6月10日火曜日
  • 29. Benchmark: time before task starts w/ yabitz_inventory for thousands of hosts Appendix: “_meta”(3) w/o _meta w/ _meta Elapsed time 18min! 10sec!!!! 14年6月10日火曜日