SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante 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
 

Semelhante 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

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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 ...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

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