senior software engineer ryan scott brown - serverless code · going serverless with ansible ryan...

23
Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer

Upload: others

Post on 22-May-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Going Serverless with AnsibleRyan Scott Brown - @ryan_sbSenior Software Engineer

Page 2: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

AboutBlogs @ Serverless CodeCommunity @ The Serverless ZoneWorks @ Ansible by Red Hat

Tweets @ryan_sb

2

Page 3: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

• Ansible Philosophy• Ansible for Cloud Resources• Playing Well w/ Other Tools• Mixing Infrastructures• State of the (Serverless) Union

Agenda

3

Page 4: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Simple Wins

• Extend automation beyond the operations team• Works on two levels of abstraction

– Configuration management and provisioning– Orchestration and control-plane

• Bring existing tools and infrastructure

Ansible Philosophy

4

Page 5: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Agentless

• Windows and Linux• Third-party APIs• Networking Hardware• Security mitigation

Ansible Philosophy

5

Page 6: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

• AWS• Azure• Google Cloud• OpenStack

Ansible for Cloud Resources

6

Page 7: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Dynamic Inventory

• Resources are becoming more ephemeral• Cloud provider API is now the source of truth

Ansible for Cloud Resources

7

Page 8: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Orchestrating Other Tools

- puppet: environment: production facts: serve_with: ssl application_version: v1.49.2

Ansible & Puppet

8

Page 9: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Implementation Patterns

9

Page 10: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Pattern 1Ansible and Serverless Framework

10

Page 11: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Best of Both Worlds

• Helps to have devs with Serverless Framework experience• Can pass control for shared resources up to Ansible

Ansible & Serverless

11

Page 12: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Sample Play

- cloudformation: stack_name: prod-vpc state: present template: base_vpc.yml- cloudformation_facts: stack_name: external_stack

Ansible & Serverless

12

Page 13: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Inside base_vpc.yaml

Outputs: VpcId: Value: !Ref AppVPC Export: {Name: !Sub “${Stage}-VPCID”} SubnetA: Value: !Ref SubnetA Export: {Name: !Sub “${Stage}-VPCSubnetA”} SubnetB: Value: !Ref SubnetB Export:{Name: !Sub “${Stage}-VPCSubnetB”}

Ansible & Serverless

13

Page 14: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

- cloudformation: stack_name: prod-vpc state: present template_args: Stage: prod region: us-east-1 template: base_vpc.yml- serverless_deploy: stage: prod functions: - createUser - deleteUser region: us-east-1

Ansible & Serverless

14

Page 15: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Migration Tips

• Attention to detail - who owns resources needed by both?• Make sure data is close enough to new & old systems• Don’t couple serverless & legacy too tightly• Remember Ansible can populate Serverless variable files

Ansible & Serverless

15

Page 16: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Pattern 2Ansible All-In

16

Page 17: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Fastest Start

• Ansible skills 100% transferrable• Add to existing playbooks• Great for “Lambda Light” workloads

Ansible Only

17

Page 18: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Build a Function

- lambda: name: sendReportMail zip_file: "{{ deployment_package }}" runtime: python2.7 timeout: 20 handler: handler.handler memory_size: 1024 role: "{{ iam_exec_role }}" register: lambda

Ansible Only

18

Page 19: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Cron Scheduling

- cloudwatchevent_rule: description: "Send out incident summary daily" name: incident_summary_schedule schedule_expression: 'rate(1 day)' targets: - id: SendSummary arn: "{{ lambda.configuration.function_arn }}" input: '{}’

Ansible Only

19

Page 20: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Least Mature

• Limited event source availability– Kinesis/DynamoDB streams– CloudWatch Events

• No direct API Gateway (in v2.2)

Ansible Only

20

Page 21: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

State of the UnionSo, how’s Jeff?

21

Page 22: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

• Look for more integrations in 2.3• Serverless Framework module • Old & new apps can share tooling

State of the Union

22

Page 23: Senior Software Engineer Ryan Scott Brown - Serverless Code · Going Serverless with Ansible Ryan Scott Brown - @ryan_sb Senior Software Engineer. About Blogs @ Serverless Code Community

Thank You!Questions to @ryan_sb or find me at the social tonight

23