31
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission. Groovy for System Administrators By Dan Woods

Groovy for System Administrators

Embed Size (px)

Citation preview

Page 1: Groovy for System Administrators

© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.

Groovy for System Administrators

By Dan Woods

Page 2: Groovy for System Administrators

Who Am I?

2

f

@danveloper /danveloper #author

[email protected]

Page 3: Groovy for System Administrators

Who Am I?

3

Page 4: Groovy for System Administrators

Groovy for System Administrators

4

System administration is a multi-faceted problem

domain, not dissimilar from software development.

- Me

Page 5: Groovy for System Administrators

Groovy for System Administrators

5

At a high level, System Administration is about…

Provisioning

Deployment

Management

Page 6: Groovy for System Administrators

Groovy for System Administrators

6

Provisioning…

• “Building” the server

• Creating the installation media

• Installing the OS on the server

Page 7: Groovy for System Administrators

Groovy for System Administrators

7

Deployment…

• Getting our app on the server

• Making sure it runs there

• Managing environment dependencies

Page 8: Groovy for System Administrators

Groovy for System Administrators

8

Management…

• Maintaining user accounts/access

• Managing resource authorization

• Designing security protocols

Page 9: Groovy for System Administrators

Groovy for System Administrators

9

What about…

• Docker?

• Chef?

• Puppet?

• Ansible?

• Packer?

• Salt?

• CFEngine?

• Synctool?

• Rex?

• Rundeck?

• STAF?

• Server CM of the week?

Page 10: Groovy for System Administrators

Groovy for System Administrators

10

A Disjointed Process

• CM setup just hopes that you’ve

done everything right to start with

• The CM agent requires different

requisite config than just OS

installation

• May leave your server in an

unknown state if the process

didn’t succeed for some reason

Pre-provisioned server

Agent-based post-install

configuration

OS installation

Server provisioning and configuration

?

Page 11: Groovy for System Administrators

Groovy for System Administrators

11

We need to rethink the way that we build and work

with server environments.

- Me

Page 12: Groovy for System Administrators

Groovy for System Administrators

12

Environment Considerations

• Disaster Recovery

• Auditing

• Forensics

Page 13: Groovy for System Administrators

Groovy for System Administrators

13

We need to be able to rapidly recover and reproduce

an environment from configuration and archives

alone.

- Me

Page 14: Groovy for System Administrators

Groovy for System Administrators

14

Immutable Infrastructure

• Every new version of software gets a new server

• Servers are ephemeral entities in the infrastructure

• Pragmatic for adopting a software-defined network

Page 15: Groovy for System Administrators

Groovy for System Administrators

15

Building Servers with Gradle

• Programmatic solution to supporting immutable infrastructure

• Servers are version controlled and archived

• "Builds" (ie. servers) can be archived for recovery and

reconstitution

• Continuous Integration, Continuous Delivery, Continuous

Deployment

Page 17: Groovy for System Administrators

Groovy for System Administrators

17

Gradle Provisioning Plugin

• Provides a DSL to Gradle to represent a server's

configuration

• Support for Continuous Integration and Continuous

Deployment

• Continuous Delivery can be achieved through your CI

system

Page 18: Groovy for System Administrators

Groovy for System Administrators

18

Provisioning and Deployment through CI

Web App Build Job

Provisioning &

Deployment Job Smoke Tests

Production Deploy

Build

Page 19: Groovy for System Administrators

Groovy for System Administrators

19

Authentication Hacking with Groovy

Page 20: Groovy for System Administrators

Groovy for System Administrators

20

Pluggable Authentication Module

• Account Details

• Authentication

• Password Changes

• Session Interaction

Page 21: Groovy for System Administrators

Groovy for System Administrators

21

Common PAM Modules

• LDAP (pam_ldap)

• Active Directory

• Radius

• … etc, etc, etc.

Page 22: Groovy for System Administrators

Groovy for System Administrators

22

Why not let the software infrastructure manage the

server’s authentication strategy?

- Me

Page 23: Groovy for System Administrators

Groovy for System Administrators

23

Why not Spring Security through a Grails application?

- Me

Page 24: Groovy for System Administrators

Groovy for System Administrators

24

PAM Module: pam_exec.so

• Allows an external system script to provide for any layer of

the PAM stack

Page 25: Groovy for System Administrators

Groovy for System Administrators

25

PAM Account & Authentication with Grails

Add to /etc/pam.d/login

Create /etc/security/onauth script and mark it executable:

auth sufficient pam_exec.so debug expose_authtok /etc/security/onauth

account sufficient pam_exec.so /etc/security/onaccount

#!/bin/sh

pass=`cat`;

result=$(curl -s -d "user=$PAM_USER&pass=$pass" http://192.168.0.106:8080/auth)

if [ "$result" != "success" ]; then

exit 1;

else

/usr/sbin/useradd $PAM_USER -m -k /etc/skel

exit 0;

fi

Page 26: Groovy for System Administrators

Groovy for System Administrators

26

Kernel Hacking with Groovy

Page 27: Groovy for System Administrators

Groovy for System Administrators

27

Kernel Space IPC with Userland Groovy

Kernel Memory

Kernel Processes

Userland Memory

Userland Processes

procfs

netlink

mmap

udp

Page 28: Groovy for System Administrators

Groovy for System Administrators

28

Groovy as a Rules Engine for `mkdir`

MKDIR

syscall

table

mkdir_code

filesystem

mkdir()

__NR_mkdir

Page 29: Groovy for System Administrators

Groovy for System Administrators

29

Groovy as a Rules Engine for `mkdir`

MKDIR

syscall

table

original

mkdir_code

filesystem

mkdir()

intercepted

mkdir_code

Page 30: Groovy for System Administrators

Groovy for System Administrators

30

Other Considerations for Kernel Hacking

• Intelligent Packet Inspection (a la IDS)

• Network Manipulation (via netlink interface)

• Packet tagging and external tracking

• User and application oriented metrics gathering

Page 31: Groovy for System Administrators

Groovy for System Administrators

31

Questions?