a systems management api for linux [email protected] … · 2017. 12. 14. · libral a systems...

48
libral a systems management API for Linux David Lutterkort @lutterkort [email protected]

Upload: others

Post on 18-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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

librala systems management API for Linux

David Lutterkort@[email protected]

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
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

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

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

$ 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

$ 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

$ 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

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

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

● 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

$ 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

$ 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

# '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

# '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

---

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

---

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

# 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

# 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

# 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

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

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

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

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

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

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