puppet camp la 2015: server management with puppet on aws for a fast-growing startup (beginner)

23
Server Management with Puppet on AWS Marco Almeida - Site Reliability Engineer

Upload: puppet-labs

Post on 14-Jul-2015

419 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Server Management with Puppet on AWS

Marco Almeida - Site Reliability Engineer

Page 2: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

About usThumbtack helps you accomplish the personal projects that are central to your life.

Whether you need to paint your home, learn a new language, or plan your daughter's birthday party, Thumbtack is the easiest and most dependable way to hire the right professional for your projects.

Page 3: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Our infrastructure

Page 4: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Our infrastructure

● 43 physical servers● 97 EC2 instances

○ roughly half for staging/research purposes● Everything managed with Puppet

Page 5: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Scaling the infrastructure

● Goals: ○ completely automate server provisioning○ proper development environment for the

whole team○ good way of distributing sensitive

information● Two components:

○ Custom AMI + a shell script○ Puppet

Page 6: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Scaling the infrastructure

● Debian 7 (Wheezy) or 8 (Jessie)● Simple, i.e., minimal base system

○ include the contrib and non-free areas○ don't install suggested packages by default

The custom AMI

Page 7: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Scaling the infrastructure

● Set the hostname● Update DNS (forward and reverse)● Run the Puppet agent● Notify Slack● Uninstall itself● Reboot● Log everything

The shell script

Page 8: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementBootstrapping servers

1. Generate new SSL key and request a new certificate

2. Run policy-based autosign script3. Compile catalog4. Download catalog5. Apply the catalog

1. Basic checks: certname was provided, no certificate with the same name has already been signed, etc.

2. Verify that an instance with the exact same name exists

3. ...

1

puppet.internal

bender.internal

2, 34

5

Page 9: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

In the old days...

● Git repo● Single puppet master● No staging environment

Page 10: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

In the old days...

● Write code● Commit● Push● Update master● Dry run on some node

Syntax error at 'FOO'; expected '}' at BAR

Page 11: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

In the old days...

● Write code● Commit● Push● Update master● Dry run on some node

Could not find class FOO

Page 12: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

In the old days...

● Write code● Commit● Push● Update master● Dry run on some node

Duplicate declaration: Package[FOO] is already declared

Page 13: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

In the old days...

● Write code● Commit● Push● Update master● Dry run on some node

Could not apply complete catalog: Found 1 dependency cycle

Page 14: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

puppet.internal

bender.internalGit

fry.internal

.

.

.

dev-1.internal

dev-2.internal

dev-3.internal

Puppet masters

Page 15: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

● A few extra configuration options○ ca = false○ dns_alt_names = dev-1, dev-1.internal,

puppet, puppet.internal● Test changes locally or from a staging box

○ puppetd --test --server dev-1.internal

Page 16: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementDevelopment environment

● Write code● Test changes● Commit● Code review● Push● Update master● Let the agent do its thing

Page 17: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementSensitive data

● Problem○ Licence keys○ Passwords○ Anything that shouldn’t be on Github

● The solution we want○ Easy to use with Puppet code, e.g.,

templates○ Shouldn’t require another password○ Simple and easy to understand

Page 18: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementSensitive data

● Easy to use○ Variables

● Don’t require another password○ IAM role

● Simple and easy to understand○ S3 or DynamoDB

Page 19: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementSensitive data

● Store the data on an S3 Bucket (or DynamoDB)● Create an IAM role with read-only permissions● Assign the role to all puppet master instances● Use an ENC

○ On every run Puppet gets all the sensitive data relevant to that node

○ Data is made available through top-scope variables

Page 20: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementSensitive data

class { 'datadog': stage => monitoring, api_key => $::datadog_api_key,}

production: host: puppetdashboard.foo.rds.amazonaws.com database: puppetdashboard password: <%= @puppetdashboard_db_password %>

Page 21: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementSpeed things up

● Re-deploy the provisioning script● Create an AMI

Page 22: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Configuration ManagementConclusion

● Each developer has his/hers own puppet master

● Changes can be easily tested locally or on staging instances○ just point the agent to your puppet master

● Development can happen in parallel● No need to babysit agent runs● All standard tools, didn’t reinvent the wheel

Page 23: Puppet Camp LA 2015: Server Management with Puppet on AWS for a fast-growing startup (Beginner)

Questions?