SlideShare a Scribd company logo
Extending the easy way
with foreman_hooks
Dominic Cleal
dcleal@redhat.com
3rd February 2014
Agenda
●

Orchestration today

●

ActiveRecord callbacks

●

Where to hook

●

Data in hooks

●

Troubleshooting

●

Cool examples

foreman_hooks | 2 | Dominic Cleal
Orchestration today
●

What does orchestration mean?
–
–

●

●

or·ches·trate (verb)
to arrange or manipulate, especially by means of clever or
thorough planning or maneuvering: to orchestrate a
profitable trade agreement (source: dictionary.com)

Namely: DNS, DHCP, TFTP, Puppet CA,
compute resources
Implemented in hosts and network interfaces,
on creation, update and destroy

foreman_hooks | 3 | Dominic Cleal
ActiveRecord callbacks
●

●

ActiveRecord is a database persistence layer in Ruby on
Rails
While mapping objects to tables, it provides a lifecycle of
events:
–

validation (before, after)

–

before_save

–

before_create

–

after_create

–

after_save

–

after_commit

foreman_hooks | 4 | Dominic Cleal
Where should you hook?
●

Orchestration hooks have benefits: ordering,
rollbacks and UI visibility

●

ActiveRecord works on nearly any object

●

Hooks are written into
~foreman/config/hooks/<object>/<event>

●

●

Each is a directory of executable files, called with the
event name, then the string representation of the
object
~foreman/config/hooks/host/managed/create/50_register_syste
m.sh create foo.example.com

foreman_hooks | 5 | Dominic Cleal
Data in hooks
●

$1 is the event name, e.g. create or destroy

●

$2 is the object's label, e.g. foo.example.com

●

stdin is the JSON representation of the object
{

"host": {
"name": "puppet.example.com",
"id": 82,
"ip": "192.168.30.10",
"environment_id": 1,
"environment_name": "production",
"last_report": "2014-01-27T22:25:34Z",
"mac": "52:54:00:2c:93:07",
"sp_mac": null,
"sp_ip": null,
"sp_name": null,
"domain_id": 6,
"domain_name": "example.com",
.....
foreman_hooks | 6 | Dominic Cleal
Troubleshooting
●

Do enable Foreman's debug logging
–

config.log_level = :debug in
~foreman/config/environments/production.rb

Found hook to Host::Managed#update, filename 01_debug_log
Finished registering 4 hooks for Host::Managed#update
Observed update hook on test.example.com
Queueing 1 hooks for Host::Managed#update
Queuing hook 01_debug_log for Host::Managed#update at
priority 01
Running hook:
/home/dcleal/code/foreman/foreman/config/hooks/host/managed
/update/01_debug_log update test.example.com

foreman_hooks | 7 | Dominic Cleal
Hook examples (1/3)
●

Extending Foreman quickly with hook scripts
–

http://bit.ly/1f8zVUZ

# cat << EOF >
~foreman/config/hooks/host/destroy/70_deactivate_puppetdb
#!/bin/bash
# We can only deactivate data in PuppetDB, not add it
[ "x$1" = xdestroy ] || exit 0
# Remove data in PuppetDB, supplying the FQDN
#
# assumes sudo rules set up as this runs as 'foreman':
#
foreman ALL = NOPASSWD : /usr/bin/puppet node deactivate *
#
Defaults:foreman !requiretty
#
sudo puppet node deactivate $2
EOF
foreman_hooks | 8 | Dominic Cleal
Hook examples (2/3)
●

FreeIPA Integration Guide (Stephen Benjamin)
–

●

http://bit.ly/19YBQhv

Uses a “create” hook to run “ipa host-add”, then
an after-commit hook to add the OTP
parameter via the API

foreman_hooks | 9 | Dominic Cleal
foreman_hooks | 10 | Dominic Cleal
Hook examples (3/3)
●

AWS VPC rDNS creation (Brian Galura)
–

●

●

●

http://bit.ly/1e47F9J

Uses “create” and “destroy” hook to run nsupdate,
creating a PTR record in his local name server
From the stdin data, the IP address and host
name can be retrieved with $(hook_data
host.ip)
Works around bug #3166

foreman_hooks | 11 | Dominic Cleal
Questions?
●

https://github.com/theforeman/foreman_hooks

●

RPM users:
–

●

yum install foreman-plugin-hooks

Debian users:
–

aptitude install ruby-foreman-hooks

foreman_hooks | 12 | Dominic Cleal
Ad

More Related Content

What's hot (20)

Auto infra with_foreman_katello
Auto infra with_foreman_katelloAuto infra with_foreman_katello
Auto infra with_foreman_katello
Sachin Ghai
 
Foreman presentation
Foreman presentationForeman presentation
Foreman presentation
Glen Ogilvie
 
PXEless Discovery with Foreman
PXEless Discovery with ForemanPXEless Discovery with Foreman
PXEless Discovery with Foreman
Stephen Benjamin
 
Foreman in your datacenter
Foreman in your datacenterForeman in your datacenter
Foreman in your datacenter
lzap
 
Connecting AWS and Katello/The Foreman
Connecting AWS and Katello/The ForemanConnecting AWS and Katello/The Foreman
Connecting AWS and Katello/The Foreman
Lukas Kallies
 
Openstack il2014 staypuft- your friendly foreman openstack installer
Openstack il2014   staypuft- your friendly foreman openstack installerOpenstack il2014   staypuft- your friendly foreman openstack installer
Openstack il2014 staypuft- your friendly foreman openstack installer
Arthur Berezin
 
Apache Provisionr (incubating) - Bucharest JUG 10
Apache Provisionr (incubating) - Bucharest JUG 10Apache Provisionr (incubating) - Bucharest JUG 10
Apache Provisionr (incubating) - Bucharest JUG 10
Andrei Savu
 
OSDC 2015: Stephen Benjamin | Foreman in Your Data Center
OSDC 2015: Stephen Benjamin | Foreman in Your Data CenterOSDC 2015: Stephen Benjamin | Foreman in Your Data Center
OSDC 2015: Stephen Benjamin | Foreman in Your Data Center
NETWAYS
 
SaltStack Integration with Foreman (2016)
SaltStack Integration with Foreman (2016)SaltStack Integration with Foreman (2016)
SaltStack Integration with Foreman (2016)
Stephen Benjamin
 
Configuration and lifecycle in Mixed environments
Configuration and lifecycle in Mixed environmentsConfiguration and lifecycle in Mixed environments
Configuration and lifecycle in Mixed environments
Dmitry Kireev
 
CfgMgmtCamp 2015 - Managing the Content Lifecycle with Katello
CfgMgmtCamp 2015 - Managing the Content Lifecycle with KatelloCfgMgmtCamp 2015 - Managing the Content Lifecycle with Katello
CfgMgmtCamp 2015 - Managing the Content Lifecycle with Katello
Stephen Benjamin
 
Using puppet, foreman and git to develop and operate a large scale internet s...
Using puppet, foreman and git to develop and operate a large scale internet s...Using puppet, foreman and git to develop and operate a large scale internet s...
Using puppet, foreman and git to develop and operate a large scale internet s...
techblog
 
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Puppet
 
Foreman-and-Puppet-for-Openstack-Audo-Deployment
Foreman-and-Puppet-for-Openstack-Audo-DeploymentForeman-and-Puppet-for-Openstack-Audo-Deployment
Foreman-and-Puppet-for-Openstack-Audo-Deployment
yating yang
 
A user's perspective on SaltStack and other configuration management tools
A user's perspective on SaltStack and other configuration management toolsA user's perspective on SaltStack and other configuration management tools
A user's perspective on SaltStack and other configuration management tools
SaltStack
 
PuppetCamp Sydney 2012 - Building a Multimaster Environment
PuppetCamp Sydney 2012 - Building a Multimaster EnvironmentPuppetCamp Sydney 2012 - Building a Multimaster Environment
PuppetCamp Sydney 2012 - Building a Multimaster Environment
Greg Cockburn
 
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet
 
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam RuzickaOSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
NETWAYS
 
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
NETWAYS
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
Michael Lessard
 
Auto infra with_foreman_katello
Auto infra with_foreman_katelloAuto infra with_foreman_katello
Auto infra with_foreman_katello
Sachin Ghai
 
Foreman presentation
Foreman presentationForeman presentation
Foreman presentation
Glen Ogilvie
 
PXEless Discovery with Foreman
PXEless Discovery with ForemanPXEless Discovery with Foreman
PXEless Discovery with Foreman
Stephen Benjamin
 
Foreman in your datacenter
Foreman in your datacenterForeman in your datacenter
Foreman in your datacenter
lzap
 
Connecting AWS and Katello/The Foreman
Connecting AWS and Katello/The ForemanConnecting AWS and Katello/The Foreman
Connecting AWS and Katello/The Foreman
Lukas Kallies
 
Openstack il2014 staypuft- your friendly foreman openstack installer
Openstack il2014   staypuft- your friendly foreman openstack installerOpenstack il2014   staypuft- your friendly foreman openstack installer
Openstack il2014 staypuft- your friendly foreman openstack installer
Arthur Berezin
 
Apache Provisionr (incubating) - Bucharest JUG 10
Apache Provisionr (incubating) - Bucharest JUG 10Apache Provisionr (incubating) - Bucharest JUG 10
Apache Provisionr (incubating) - Bucharest JUG 10
Andrei Savu
 
OSDC 2015: Stephen Benjamin | Foreman in Your Data Center
OSDC 2015: Stephen Benjamin | Foreman in Your Data CenterOSDC 2015: Stephen Benjamin | Foreman in Your Data Center
OSDC 2015: Stephen Benjamin | Foreman in Your Data Center
NETWAYS
 
SaltStack Integration with Foreman (2016)
SaltStack Integration with Foreman (2016)SaltStack Integration with Foreman (2016)
SaltStack Integration with Foreman (2016)
Stephen Benjamin
 
Configuration and lifecycle in Mixed environments
Configuration and lifecycle in Mixed environmentsConfiguration and lifecycle in Mixed environments
Configuration and lifecycle in Mixed environments
Dmitry Kireev
 
CfgMgmtCamp 2015 - Managing the Content Lifecycle with Katello
CfgMgmtCamp 2015 - Managing the Content Lifecycle with KatelloCfgMgmtCamp 2015 - Managing the Content Lifecycle with Katello
CfgMgmtCamp 2015 - Managing the Content Lifecycle with Katello
Stephen Benjamin
 
Using puppet, foreman and git to develop and operate a large scale internet s...
Using puppet, foreman and git to develop and operate a large scale internet s...Using puppet, foreman and git to develop and operate a large scale internet s...
Using puppet, foreman and git to develop and operate a large scale internet s...
techblog
 
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Running at Scale: Practical Performance Tuning with Puppet - PuppetConf 2013
Puppet
 
Foreman-and-Puppet-for-Openstack-Audo-Deployment
Foreman-and-Puppet-for-Openstack-Audo-DeploymentForeman-and-Puppet-for-Openstack-Audo-Deployment
Foreman-and-Puppet-for-Openstack-Audo-Deployment
yating yang
 
A user's perspective on SaltStack and other configuration management tools
A user's perspective on SaltStack and other configuration management toolsA user's perspective on SaltStack and other configuration management tools
A user's perspective on SaltStack and other configuration management tools
SaltStack
 
PuppetCamp Sydney 2012 - Building a Multimaster Environment
PuppetCamp Sydney 2012 - Building a Multimaster EnvironmentPuppetCamp Sydney 2012 - Building a Multimaster Environment
PuppetCamp Sydney 2012 - Building a Multimaster Environment
Greg Cockburn
 
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet Availability and Performance at 100K Nodes - PuppetConf 2014
Puppet
 
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam RuzickaOSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
OSCamp 2019 | #3 Ansible: Foreman Discovery by Adam Ruzicka
NETWAYS
 
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
NETWAYS
 
Red Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with PuppetRed Hat Satellite 6 - Automation with Puppet
Red Hat Satellite 6 - Automation with Puppet
Michael Lessard
 

Viewers also liked (10)

Improving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetImproving Operations Efficiency with Puppet
Improving Operations Efficiency with Puppet
Nicolas Brousse
 
How I hack on puppet modules
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modules
Kris Buytaert
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conference
ohadlevy
 
KubeCon EU 2016: Heroku to Kubernetes
KubeCon EU 2016: Heroku to KubernetesKubeCon EU 2016: Heroku to Kubernetes
KubeCon EU 2016: Heroku to Kubernetes
KubeAcademy
 
Docker Puppet Automatisation on Hidora
Docker Puppet Automatisation on HidoraDocker Puppet Automatisation on Hidora
Docker Puppet Automatisation on Hidora
Open-IT
 
Top 10 paramedical examiner interview questions and answers
Top 10 paramedical examiner interview questions and answersTop 10 paramedical examiner interview questions and answers
Top 10 paramedical examiner interview questions and answers
tonychoper7206
 
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Puppet
 
Lifecycle Management mit Puppet und Foreman
Lifecycle Management mit Puppet und ForemanLifecycle Management mit Puppet und Foreman
Lifecycle Management mit Puppet und Foreman
B1 Systems GmbH
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles Pattern
Puppet
 
Introduction to Parameters in Foreman
Introduction to Parameters in ForemanIntroduction to Parameters in Foreman
Introduction to Parameters in Foreman
Tomer Brisker
 
Improving Operations Efficiency with Puppet
Improving Operations Efficiency with PuppetImproving Operations Efficiency with Puppet
Improving Operations Efficiency with Puppet
Nicolas Brousse
 
How I hack on puppet modules
How I hack on puppet modulesHow I hack on puppet modules
How I hack on puppet modules
Kris Buytaert
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conference
ohadlevy
 
KubeCon EU 2016: Heroku to Kubernetes
KubeCon EU 2016: Heroku to KubernetesKubeCon EU 2016: Heroku to Kubernetes
KubeCon EU 2016: Heroku to Kubernetes
KubeAcademy
 
Docker Puppet Automatisation on Hidora
Docker Puppet Automatisation on HidoraDocker Puppet Automatisation on Hidora
Docker Puppet Automatisation on Hidora
Open-IT
 
Top 10 paramedical examiner interview questions and answers
Top 10 paramedical examiner interview questions and answersTop 10 paramedical examiner interview questions and answers
Top 10 paramedical examiner interview questions and answers
tonychoper7206
 
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Beaker: Automated, Cloud-Based Acceptance Testing - PuppetConf 2014
Puppet
 
Lifecycle Management mit Puppet und Foreman
Lifecycle Management mit Puppet und ForemanLifecycle Management mit Puppet und Foreman
Lifecycle Management mit Puppet und Foreman
B1 Systems GmbH
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles Pattern
Puppet
 
Introduction to Parameters in Foreman
Introduction to Parameters in ForemanIntroduction to Parameters in Foreman
Introduction to Parameters in Foreman
Tomer Brisker
 
Ad

Similar to Extending Foreman the easy way with foreman_hooks (20)

Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on Docker
RightScale
 
Docker on Docker
Docker on DockerDocker on Docker
Docker on Docker
Docker, Inc.
 
FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...
FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...
FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...
Didac Oliveira
 
It gilde 20150209
It gilde 20150209It gilde 20150209
It gilde 20150209
Martin Simons
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
RightScale
 
Sprint 157
Sprint 157Sprint 157
Sprint 157
ManageIQ
 
Sprint 17
Sprint 17Sprint 17
Sprint 17
ManageIQ
 
Sprint 153
Sprint 153Sprint 153
Sprint 153
ManageIQ
 
The Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 PrimerThe Domino 10 RHEL 7 Primer
The Domino 10 RHEL 7 Primer
Bill Malchisky Jr.
 
Devopstore
DevopstoreDevopstore
Devopstore
Farkhad Badalov
 
Sprint 154
Sprint 154Sprint 154
Sprint 154
ManageIQ
 
Sprint 125
Sprint 125Sprint 125
Sprint 125
ManageIQ
 
Coredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS serverCoredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS server
Yann Hamon
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production
Hung Lin
 
Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal Development
Chris Tankersley
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0
Jakub Hajek
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Aleksey Asiutin
 
PaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at YelpPaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at Yelp
Nathan Handler
 
Retrofitting Continuous Delivery
Retrofitting Continuous Delivery Retrofitting Continuous Delivery
Retrofitting Continuous Delivery
Alan Norton
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)
Brian Brazil
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on Docker
RightScale
 
FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...
FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...
FOSDEM'17: Disaster Recovery Management with ReaR (relax-and-recover) & DRLM ...
Didac Oliveira
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
RightScale
 
Sprint 157
Sprint 157Sprint 157
Sprint 157
ManageIQ
 
Sprint 153
Sprint 153Sprint 153
Sprint 153
ManageIQ
 
Sprint 154
Sprint 154Sprint 154
Sprint 154
ManageIQ
 
Sprint 125
Sprint 125Sprint 125
Sprint 125
ManageIQ
 
Coredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS serverCoredns nodecache - A highly-available Node-cache DNS server
Coredns nodecache - A highly-available Node-cache DNS server
Yann Hamon
 
6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production 6 Months Sailing with Docker in Production
6 Months Sailing with Docker in Production
Hung Lin
 
Modernize Your Drupal Development
Modernize Your Drupal DevelopmentModernize Your Drupal Development
Modernize Your Drupal Development
Chris Tankersley
 
Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0Docker Swarm and Traefik 2.0
Docker Swarm and Traefik 2.0
Jakub Hajek
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Aleksey Asiutin
 
PaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at YelpPaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at Yelp
Nathan Handler
 
Retrofitting Continuous Delivery
Retrofitting Continuous Delivery Retrofitting Continuous Delivery
Retrofitting Continuous Delivery
Alan Norton
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)
Brian Brazil
 
Ad

Recently uploaded (20)

Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul Shares 5 Steps to Implement AI Agents for Maximum Business Efficien...
Noah Loul
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 

Extending Foreman the easy way with foreman_hooks

  • 1. Extending the easy way with foreman_hooks Dominic Cleal [email protected] 3rd February 2014
  • 2. Agenda ● Orchestration today ● ActiveRecord callbacks ● Where to hook ● Data in hooks ● Troubleshooting ● Cool examples foreman_hooks | 2 | Dominic Cleal
  • 3. Orchestration today ● What does orchestration mean? – – ● ● or·ches·trate (verb) to arrange or manipulate, especially by means of clever or thorough planning or maneuvering: to orchestrate a profitable trade agreement (source: dictionary.com) Namely: DNS, DHCP, TFTP, Puppet CA, compute resources Implemented in hosts and network interfaces, on creation, update and destroy foreman_hooks | 3 | Dominic Cleal
  • 4. ActiveRecord callbacks ● ● ActiveRecord is a database persistence layer in Ruby on Rails While mapping objects to tables, it provides a lifecycle of events: – validation (before, after) – before_save – before_create – after_create – after_save – after_commit foreman_hooks | 4 | Dominic Cleal
  • 5. Where should you hook? ● Orchestration hooks have benefits: ordering, rollbacks and UI visibility ● ActiveRecord works on nearly any object ● Hooks are written into ~foreman/config/hooks/<object>/<event> ● ● Each is a directory of executable files, called with the event name, then the string representation of the object ~foreman/config/hooks/host/managed/create/50_register_syste m.sh create foo.example.com foreman_hooks | 5 | Dominic Cleal
  • 6. Data in hooks ● $1 is the event name, e.g. create or destroy ● $2 is the object's label, e.g. foo.example.com ● stdin is the JSON representation of the object { "host": { "name": "puppet.example.com", "id": 82, "ip": "192.168.30.10", "environment_id": 1, "environment_name": "production", "last_report": "2014-01-27T22:25:34Z", "mac": "52:54:00:2c:93:07", "sp_mac": null, "sp_ip": null, "sp_name": null, "domain_id": 6, "domain_name": "example.com", ..... foreman_hooks | 6 | Dominic Cleal
  • 7. Troubleshooting ● Do enable Foreman's debug logging – config.log_level = :debug in ~foreman/config/environments/production.rb Found hook to Host::Managed#update, filename 01_debug_log Finished registering 4 hooks for Host::Managed#update Observed update hook on test.example.com Queueing 1 hooks for Host::Managed#update Queuing hook 01_debug_log for Host::Managed#update at priority 01 Running hook: /home/dcleal/code/foreman/foreman/config/hooks/host/managed /update/01_debug_log update test.example.com foreman_hooks | 7 | Dominic Cleal
  • 8. Hook examples (1/3) ● Extending Foreman quickly with hook scripts – http://bit.ly/1f8zVUZ # cat << EOF > ~foreman/config/hooks/host/destroy/70_deactivate_puppetdb #!/bin/bash # We can only deactivate data in PuppetDB, not add it [ "x$1" = xdestroy ] || exit 0 # Remove data in PuppetDB, supplying the FQDN # # assumes sudo rules set up as this runs as 'foreman': # foreman ALL = NOPASSWD : /usr/bin/puppet node deactivate * # Defaults:foreman !requiretty # sudo puppet node deactivate $2 EOF foreman_hooks | 8 | Dominic Cleal
  • 9. Hook examples (2/3) ● FreeIPA Integration Guide (Stephen Benjamin) – ● http://bit.ly/19YBQhv Uses a “create” hook to run “ipa host-add”, then an after-commit hook to add the OTP parameter via the API foreman_hooks | 9 | Dominic Cleal
  • 10. foreman_hooks | 10 | Dominic Cleal
  • 11. Hook examples (3/3) ● AWS VPC rDNS creation (Brian Galura) – ● ● ● http://bit.ly/1e47F9J Uses “create” and “destroy” hook to run nsupdate, creating a PTR record in his local name server From the stdin data, the IP address and host name can be retrieved with $(hook_data host.ip) Works around bug #3166 foreman_hooks | 11 | Dominic Cleal
  • 12. Questions? ● https://github.com/theforeman/foreman_hooks ● RPM users: – ● yum install foreman-plugin-hooks Debian users: – aptitude install ruby-foreman-hooks foreman_hooks | 12 | Dominic Cleal