SlideShare una empresa de Scribd logo
1 de 20
Descargar para leer sin conexión
Writing your own
augeasproviders
Dominic Cleal
dcleal@redhat.com
4th February 2014
Agenda
●

Intro to Augeas

●

Intro to augeasproviders

●

Delving into augeasproviders
●
●

Core support layer

●
●

Types and providers layer
Test layer

What's next?

augeasproviders | 2 | Dominic Cleal
A tree, its branches and leaves
Augeas turns configuration files into a tree structure:
/etc/hosts -> /files/etc/hosts

... and their parameters into branches and leaves:
augtool> print /files/etc/hosts
/files/etc/hosts
/files/etc/hosts/1
/files/etc/hosts/1/ipaddr = "127.0.0.1"
/files/etc/hosts/1/canonical = "localhost"

augeasproviders | 3 | Dominic Cleal
Augeas provides many stock parsers
They are called lenses:
Access
Aliases
Anacron
Approx
AptConf
Automaster
Automounter
BackupPCHosts
cgconfig
cgrules
Channels
...

Cron
Crypttab
debctrl
Desktop
Dhcpd
Dpkg
Exports
FAI_DiskConfig
Fonts
Fuse
Grub

Host_Conf
Hostname
Hosts_Access
IniFile
Inputrc
Iptables
Kdump
Keepalived
Keepalived
Login_defs
Mke2fs

$ augtool print /augeas//path | wc -l
813
augeasproviders | 4 | Dominic Cleal
augtool lets you inspect the tree
$ augtool
augtool> ls /
augeas/ = (none)
files/ = (none)
augtool> print /files/etc/passwd/root/
/files/etc/passwd/root
/files/etc/passwd/root/password = "x"
/files/etc/passwd/root/uid = "0"
/files/etc/passwd/root/gid = "0"
/files/etc/passwd/root/name = "root"
/files/etc/passwd/root/home = "/root"
/files/etc/passwd/root/shell = "/bin/bash"

augeasproviders | 5 | Dominic Cleal
Puppet has a native provider
augeas { 'export /foo':
context => '/files/etc/exports',
changes => [
"set dir[. = '/foo'] /foo",
"set dir[. = '/foo']/client weeble",
"set dir[. = '/foo']/client/option[1] ro",
"set dir[. = '/foo']/client/option[2] all_squash",
],
}
$ cat /etc/exports
/foo weeble(ro,all_squash)

augeasproviders | 6 | Dominic Cleal
Introducing augeasproviders
kernel_parameter { 'elevator':
ensure => present,
value => 'deadline',
}
shellvar
ensure
target
value
}

{ 'HOSTNAME':
=> present,
=> '/etc/sysconfig/network',
=> 'host.example.com',

sysctl { 'net.ipv4.ip_forward':
ensure => present,
value => '1',
}

augeasproviders | 7 | Dominic Cleal
More types (and providers)
●

host, mailalias

●

mounttab (puppetlabs-mount_providers)

●

apache_setenv (and apache_directive to follow)

●

kernel_parameter

●

nrpe_command

●

pg_hba

●

puppet_auth

●

sshd_config, sshd_config_subsystem

●

sysctl

●

syslog
augeasproviders | 8 | Dominic Cleal
But Augeas is safe...

class network($hostname) {
file_line { 'set hostname':
ensure => present,
path
=> '/etc/sysconfig/network',
line
=> “HOSTNAME=${hostname}”,
}
}
# puppet apply example.pp
Notice: /Stage[main]/Main/File_line[set
hostname]/ensure: created
# . /etc/sysconfig/network
-bash: bar: command not found

augeasproviders | 9 | Dominic Cleal
But Augeas is safe...

class network($hostname) {
shellvar { 'HOSTNAME':
ensure => present,
target => '/etc/sysconfig/network',
value => $hostname,
}
}
# puppet apply example.pp
Error: Could not set 'present' on ensure:
/augeas/files/etc/sysconfig/network/error/path =
/files/etc/sysconfig/network
/augeas/files/etc/sysconfig/network/error/message =
Failed to match
augeasproviders | 10 | Dominic Cleal
augeasproviders | 11 | Dominic Cleal
Types and providers
●

●

●

●

See last year's talk on replacing “exec” with a type/provider
Nothing fancy here – either building on existing types,
where they're been properly separated, or declaring new
ones
Types all take a “target” parameter for the configuration file
to be edited, but providers have sensible defaults
augeasproviders helps declare getters/setters in providers
with attribute helpers:
●

attr_aug_accessor(:foo)

●

Gives us foo and foo=

augeasproviders | 12 | Dominic Cleal
What's in augeasproviders core?
●

Helpers to define information about the file being managed
●

default_file
●

●

lens
●

●

Defines a block for the Augeas lens of the file

resource_path
●

●

Defines a block to get the default file path for this provider

Defines a block for the location in the tree of this resource

Augeas library wrappers
●

augopen, augopen!
●

Helpers to open the Augeas library, save, and close

augeasproviders | 13 | Dominic Cleal
augeasproviders | 14 | Dominic Cleal
What's in augeasproviders core?
●

Helpers to define methods that use Augeas
●

define_aug_method, define_aug_method!
●

●

Takes a block, which is wrapped in augopen or augopen!
methods to open Augeas

Helpers using the resource_path
●

attr_aug_accessor, attr_aug_reader, attr_aug_writer
●

Much like Ruby's accessor definitions

augeasproviders | 15 | Dominic Cleal
augeasproviders | 16 | Dominic Cleal
Complete functional tests
●

Don't test the provider, test the resource

●

Start with a set of known-state fixtures

●

Then take a resource and build a catalogue out of it:
shellvar { .. }

●

●

catalogue

.apply

Then let's check the result of the resource apply
But what happens if you run it twice? Verify that a resource
behaves in an idempotent manner

augeasproviders | 17 | Dominic Cleal
Verifying test results
●

Much code stolen from rspec-puppet-augeas
●

If you haven't checked it out, and use augeas { }
resources, do so.

augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", '
{ "net.ipv4.ip_forward" = "1" }
')

aug_open(target, "Sysctl.lns") do |aug|
aug.match("#comment[. =~ regexp('kernel.sysrq:.*')]").should == []
aug.match("#comment[. = 'SysRq setting']").should_not == []
end

augeasproviders | 18 | Dominic Cleal
What's next?
●

Big split
●

augeasproviders core
●

Do users want packages?

●

Can Puppet reliably handle libs in other modules?

●
●
●

Where to put existing providers?
Resource testing to rspec-puppet or r-p-augeas

Always more providers

augeasproviders | 19 | Dominic Cleal
Questions?

http://augeas.net
augeas-devel@redhat.com
freenode: #augeas

augeasproviders | 20 | Dominic Cleal

Más contenido relacionado

La actualidad más candente

More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricksbcoca
 
PyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudPyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudSimone Soldateschi
 
Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Workhorse Computing
 
Ansible fest Presentation slides
Ansible fest Presentation slidesAnsible fest Presentation slides
Ansible fest Presentation slidesAaron Carey
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestrationbcoca
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleCoreStack
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Puppet
 
Challenges when building high profile editorial sites
Challenges when building high profile editorial sitesChallenges when building high profile editorial sites
Challenges when building high profile editorial sitesYann Malet
 
快快樂樂用Homestead
快快樂樂用Homestead快快樂樂用Homestead
快快樂樂用HomesteadChen Cheng-Wei
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done rightDan Vaida
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Brian Schott
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliGetSource
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Jun Hong Kim
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Soshi Nemoto
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Alex S
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansibleGeorge Shuklin
 

La actualidad más candente (19)

More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
 
PyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudPyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the Cloud
 
Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.Selenium sandwich-3: Being where you aren't.
Selenium sandwich-3: Being where you aren't.
 
Ansible fest Presentation slides
Ansible fest Presentation slidesAnsible fest Presentation slides
Ansible fest Presentation slides
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 
Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...Replacing "exec" with a type and provider: Return manifests to a declarative ...
Replacing "exec" with a type and provider: Return manifests to a declarative ...
 
Challenges when building high profile editorial sites
Challenges when building high profile editorial sitesChallenges when building high profile editorial sites
Challenges when building high profile editorial sites
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Puppet fundamentals
Puppet fundamentalsPuppet fundamentals
Puppet fundamentals
 
快快樂樂用Homestead
快快樂樂用Homestead快快樂樂用Homestead
快快樂樂用Homestead
 
Ansible roles done right
Ansible roles done rightAnsible roles done right
Ansible roles done right
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
Manage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cliManage WordPress with Awesome using wp cli
Manage WordPress with Awesome using wp cli
 
Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)Hadoop meet Rex(How to construct hadoop cluster with rex)
Hadoop meet Rex(How to construct hadoop cluster with rex)
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)
 
Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015Ansible is the simplest way to automate. MoldCamp, 2015
Ansible is the simplest way to automate. MoldCamp, 2015
 
Best practices for ansible
Best practices for ansibleBest practices for ansible
Best practices for ansible
 

Similar a Writing your own augeasproviders

Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)Dominic Cleal
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppetelliando dias
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Puppet
 
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context ConstraintsAlessandro Arrichiello
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!Jeff Geerling
 
Chef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructureChef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructureMichaël Lopez
 
Orchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and MspectatorOrchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and MspectatorRaphaël PINSON
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Puppet
 
Drupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine showDrupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine showGeorge Boobyer
 
Configuration Surgery with Augeas
Configuration Surgery with AugeasConfiguration Surgery with Augeas
Configuration Surgery with AugeasPuppet
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk GötzNETWAYS
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOpsAgile Spain
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleStein Inge Morisbak
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOpsОмские ИТ-субботники
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with AnsibleIvan Serdyuk
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet CampPuppet
 

Similar a Writing your own augeasproviders (20)

Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)Configuration surgery with Augeas (OggCamp 12)
Configuration surgery with Augeas (OggCamp 12)
 
Script it
Script itScript it
Script it
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppet
 
Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014Writing and Publishing Puppet Modules - PuppetConf 2014
Writing and Publishing Puppet Modules - PuppetConf 2014
 
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
 
DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!DevOps for Humans - Ansible for Drupal Deployment Victory!
DevOps for Humans - Ansible for Drupal Deployment Victory!
 
Chef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructureChef - industrialize and automate your infrastructure
Chef - industrialize and automate your infrastructure
 
Orchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and MspectatorOrchestrated Functional Testing with Puppet-spec and Mspectator
Orchestrated Functional Testing with Puppet-spec and Mspectator
 
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
Orchestrated Functional Testing with Puppet-spec and Mspectator - PuppetConf ...
 
Drupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine showDrupal Camp Brighton 2015: Ansible Drupal Medicine show
Drupal Camp Brighton 2015: Ansible Drupal Medicine show
 
Configuration Surgery with Augeas
Configuration Surgery with AugeasConfiguration Surgery with Augeas
Configuration Surgery with Augeas
 
Augeas @RMLL 2012
Augeas @RMLL 2012Augeas @RMLL 2012
Augeas @RMLL 2012
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
 
My SQL 101
My SQL 101My SQL 101
My SQL 101
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOps
 
Zero Downtime Deployment with Ansible
Zero Downtime Deployment with AnsibleZero Downtime Deployment with Ansible
Zero Downtime Deployment with Ansible
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Campmodern module development - Ken Barber 2012 Edinburgh Puppet Camp
modern module development - Ken Barber 2012 Edinburgh Puppet Camp
 

Último

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 interpreternaman860154
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
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 Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
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 MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 

Último (20)

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
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
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
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 

Writing your own augeasproviders

  • 1. Writing your own augeasproviders Dominic Cleal dcleal@redhat.com 4th February 2014
  • 2. Agenda ● Intro to Augeas ● Intro to augeasproviders ● Delving into augeasproviders ● ● Core support layer ● ● Types and providers layer Test layer What's next? augeasproviders | 2 | Dominic Cleal
  • 3. A tree, its branches and leaves Augeas turns configuration files into a tree structure: /etc/hosts -> /files/etc/hosts ... and their parameters into branches and leaves: augtool> print /files/etc/hosts /files/etc/hosts /files/etc/hosts/1 /files/etc/hosts/1/ipaddr = "127.0.0.1" /files/etc/hosts/1/canonical = "localhost" augeasproviders | 3 | Dominic Cleal
  • 4. Augeas provides many stock parsers They are called lenses: Access Aliases Anacron Approx AptConf Automaster Automounter BackupPCHosts cgconfig cgrules Channels ... Cron Crypttab debctrl Desktop Dhcpd Dpkg Exports FAI_DiskConfig Fonts Fuse Grub Host_Conf Hostname Hosts_Access IniFile Inputrc Iptables Kdump Keepalived Keepalived Login_defs Mke2fs $ augtool print /augeas//path | wc -l 813 augeasproviders | 4 | Dominic Cleal
  • 5. augtool lets you inspect the tree $ augtool augtool> ls / augeas/ = (none) files/ = (none) augtool> print /files/etc/passwd/root/ /files/etc/passwd/root /files/etc/passwd/root/password = "x" /files/etc/passwd/root/uid = "0" /files/etc/passwd/root/gid = "0" /files/etc/passwd/root/name = "root" /files/etc/passwd/root/home = "/root" /files/etc/passwd/root/shell = "/bin/bash" augeasproviders | 5 | Dominic Cleal
  • 6. Puppet has a native provider augeas { 'export /foo': context => '/files/etc/exports', changes => [ "set dir[. = '/foo'] /foo", "set dir[. = '/foo']/client weeble", "set dir[. = '/foo']/client/option[1] ro", "set dir[. = '/foo']/client/option[2] all_squash", ], } $ cat /etc/exports /foo weeble(ro,all_squash) augeasproviders | 6 | Dominic Cleal
  • 7. Introducing augeasproviders kernel_parameter { 'elevator': ensure => present, value => 'deadline', } shellvar ensure target value } { 'HOSTNAME': => present, => '/etc/sysconfig/network', => 'host.example.com', sysctl { 'net.ipv4.ip_forward': ensure => present, value => '1', } augeasproviders | 7 | Dominic Cleal
  • 8. More types (and providers) ● host, mailalias ● mounttab (puppetlabs-mount_providers) ● apache_setenv (and apache_directive to follow) ● kernel_parameter ● nrpe_command ● pg_hba ● puppet_auth ● sshd_config, sshd_config_subsystem ● sysctl ● syslog augeasproviders | 8 | Dominic Cleal
  • 9. But Augeas is safe... class network($hostname) { file_line { 'set hostname': ensure => present, path => '/etc/sysconfig/network', line => “HOSTNAME=${hostname}”, } } # puppet apply example.pp Notice: /Stage[main]/Main/File_line[set hostname]/ensure: created # . /etc/sysconfig/network -bash: bar: command not found augeasproviders | 9 | Dominic Cleal
  • 10. But Augeas is safe... class network($hostname) { shellvar { 'HOSTNAME': ensure => present, target => '/etc/sysconfig/network', value => $hostname, } } # puppet apply example.pp Error: Could not set 'present' on ensure: /augeas/files/etc/sysconfig/network/error/path = /files/etc/sysconfig/network /augeas/files/etc/sysconfig/network/error/message = Failed to match augeasproviders | 10 | Dominic Cleal
  • 11. augeasproviders | 11 | Dominic Cleal
  • 12. Types and providers ● ● ● ● See last year's talk on replacing “exec” with a type/provider Nothing fancy here – either building on existing types, where they're been properly separated, or declaring new ones Types all take a “target” parameter for the configuration file to be edited, but providers have sensible defaults augeasproviders helps declare getters/setters in providers with attribute helpers: ● attr_aug_accessor(:foo) ● Gives us foo and foo= augeasproviders | 12 | Dominic Cleal
  • 13. What's in augeasproviders core? ● Helpers to define information about the file being managed ● default_file ● ● lens ● ● Defines a block for the Augeas lens of the file resource_path ● ● Defines a block to get the default file path for this provider Defines a block for the location in the tree of this resource Augeas library wrappers ● augopen, augopen! ● Helpers to open the Augeas library, save, and close augeasproviders | 13 | Dominic Cleal
  • 14. augeasproviders | 14 | Dominic Cleal
  • 15. What's in augeasproviders core? ● Helpers to define methods that use Augeas ● define_aug_method, define_aug_method! ● ● Takes a block, which is wrapped in augopen or augopen! methods to open Augeas Helpers using the resource_path ● attr_aug_accessor, attr_aug_reader, attr_aug_writer ● Much like Ruby's accessor definitions augeasproviders | 15 | Dominic Cleal
  • 16. augeasproviders | 16 | Dominic Cleal
  • 17. Complete functional tests ● Don't test the provider, test the resource ● Start with a set of known-state fixtures ● Then take a resource and build a catalogue out of it: shellvar { .. } ● ● catalogue .apply Then let's check the result of the resource apply But what happens if you run it twice? Verify that a resource behaves in an idempotent manner augeasproviders | 17 | Dominic Cleal
  • 18. Verifying test results ● Much code stolen from rspec-puppet-augeas ● If you haven't checked it out, and use augeas { } resources, do so. augparse_filter(target, "Sysctl.lns", "net.ipv4.ip_forward", ' { "net.ipv4.ip_forward" = "1" } ') aug_open(target, "Sysctl.lns") do |aug| aug.match("#comment[. =~ regexp('kernel.sysrq:.*')]").should == [] aug.match("#comment[. = 'SysRq setting']").should_not == [] end augeasproviders | 18 | Dominic Cleal
  • 19. What's next? ● Big split ● augeasproviders core ● Do users want packages? ● Can Puppet reliably handle libs in other modules? ● ● ● Where to put existing providers? Resource testing to rspec-puppet or r-p-augeas Always more providers augeasproviders | 19 | Dominic Cleal