a systems management API for Linux [email protected] … · 2017. 12. 14. · libral a systems...
Transcript of a systems management API for Linux [email protected] … · 2017. 12. 14. · libral a systems...
![Page 2: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/2.jpg)
![Page 3: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/3.jpg)
3
http://augeas.net/
![Page 4: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/4.jpg)
The trouble with management
![Page 5: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/5.jpg)
$ usermod -s /sbin/nologin app
![Page 6: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/6.jpg)
$ usermod -s /sbin/nologin appusermod: user 'app' does not exist
![Page 7: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/7.jpg)
$ usermod -s /sbin/nologin appusermod: user 'app' does not exist
$ grep -q app /etc/passwd && \ usermod -s /sbin/nologin app || \ useradd -u 72 -g 72 -s /sbin/nologin \ -M -r -d / app
![Page 8: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/8.jpg)
Need to do this for every sort of resource(user, group, package, service, firewall rule, …)
8
![Page 9: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/9.jpg)
What if all you need is some insight ?
9
![Page 10: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/10.jpg)
● regular audits
● verify that what you built is what you meant
● inspect running containers
● ask adhoc questions of your infrastructure
10
Insight is its own use case
![Page 11: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/11.jpg)
$ grep app /etc/passwd | \ cut -d ':' -f 7/sbin/nologin
![Page 12: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/12.jpg)
$ grep app /etc/passwd | \ cut -d ':' -f 7/bin/bash/sbin/nologin/sbin/nologin
![Page 13: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/13.jpg)
Adhoc scripting full of pitfalls
13
![Page 14: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/14.jpg)
Is "learn this big config management system"
the best we can do ?
14
![Page 15: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/15.jpg)
Anatomy of a
configuration management system
![Page 16: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/16.jpg)
16
Workflow
Global controller
Local controller
Resource abstraction
![Page 17: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/17.jpg)
17
Workflow
Global controller
Local controller
libral
![Page 18: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/18.jpg)
18
Workflow
Global controller
Local controller
libral
???
Analysis
Global storage
Local collector
![Page 19: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/19.jpg)
What makes a
good management API ?
![Page 20: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/20.jpg)
Desired state
(idempotency)
20
![Page 21: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/21.jpg)
Bidirectional
(change & insight)
21
![Page 22: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/22.jpg)
Light-weight abstractions
22
![Page 23: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/23.jpg)
Simple to extend
23
![Page 24: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/24.jpg)
libral
group
package
service
user
host
Providers
ralsh
CRuby
remote API
API Users
![Page 25: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/25.jpg)
But what about … ?
![Page 26: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/26.jpg)
What about CIM ?
26
![Page 27: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/27.jpg)
What about OpenLMI ?
27
![Page 28: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/28.jpg)
What about $cm_system ?
28
![Page 29: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/29.jpg)
Demo
![Page 30: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/30.jpg)
Writing providers
![Page 31: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/31.jpg)
1. Pick scripting language and calling convention
2. Write standalone script
a. Start with listing resources
b. Get update working
3. Try out/integrate with ralsh
31
![Page 32: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/32.jpg)
32
![Page 33: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/33.jpg)
Choosing a language
● Use what you are familiar with
● Keep it simple
○ bash
○ whatever can be expected to be there
○ mRuby
33
![Page 34: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/34.jpg)
High-level API
provider.get(names) → list[resource]
provider.set(is, should) → list[change]
34
![Page 35: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/35.jpg)
# 'Simple' calling convention
$ systemd.prov ral_action=describe ↳ some yaml
$ systemd.prov ral_action=list ↳ all resources
$ systemd.prov ral_action=find name=<name> ↳ one resource
![Page 36: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/36.jpg)
# 'Simple' calling convention
$ systemd.prov ral_action=update \ attr1=value1 \ attr2=value2 ↳ changes performed
![Page 37: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/37.jpg)
---
provider: type: service invoke: simple actions: [list,find,update] suitable: ${suitable} attributes:
name: type: string
ensure: type: enum[running, stopped]
enable: type: enum[true, false, mask]
![Page 38: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/38.jpg)
---
provider: type: service invoke: simple actions: [list,find,update] suitable: ${suitable} attributes:
name: type: string
ensure: type: enum[running, stopped]
enable: type: enum[true, false, mask]
![Page 39: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/39.jpg)
# systemd provider: 'list' all known serviceslist() {
echo '# simple'join -j 1 -o 1.1,1.2,2.3 \
<(systemctl list-unit-files ...) \ <(systemctl list-units --type service ...) \ | while read svc enable ensure
do echo "name: $svc" echo "ensure: $ensure" echo "enable: $enable"
done}
![Page 40: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/40.jpg)
# systemd provider: 'list' all known serviceslist() {
echo '# simple'join -j 1 -o 1.1,1.2,2.3 \
<(systemctl list-unit-files ...) \ <(systemctl list-units --type service ...) \ | while read svc enable ensure
do echo "name: $svc" echo "ensure: $ensure" echo "enable: $enable"
done}
![Page 41: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/41.jpg)
# systemd provider: 'list' all known serviceslist() {
echo '# simple'join -j 1 -o 1.1,1.2,2.3 \
<(systemctl list-unit-files ...) \ <(systemctl list-units --type service ...) \ | while read svc enable ensure
do echo "name: $svc" echo "ensure: $ensure" echo "enable: $enable"
done}
.
![Page 42: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/42.jpg)
What now ?
![Page 43: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/43.jpg)
Firm up interfaces/calling conventions
43
![Page 44: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/44.jpg)
More providers
44
![Page 45: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/45.jpg)
Distribution
45
![Page 46: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/46.jpg)
Desired-state bidirectional APIjoin the fun
![Page 47: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/47.jpg)
47
https://github.com/puppetlabs/libral
![Page 48: a systems management API for Linux lutter@puppet.com … · 2017. 12. 14. · libral a systems management API for Linux David Lutterkort @lutterkort lutter@puppet.com. 3 ... good](https://reader036.fdocuments.net/reader036/viewer/2022071003/5fc03d4021a37567045aad40/html5/thumbnails/48.jpg)