Create Network Load Balancer on AWS using Ansible

0 votes
Can I create a Network Load Balancer on AWS using Ansible? If yes how? Thank you
Mar 24 in Ansible by Neha
17 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hey @Neha, you can create NLB using boto itself. Follow these steps:

  • Create NLB using Boto
import boto3

client = boto3.client('elbv2')
client.create_load_balancer(Name='my-load-balancer', Type='network')

Provision the LB

CloudFormation Template - my-nlb-stack.yml

Resources:
  NetworkLoadBalancer:
    Type: "AWS::ElasticLoadBalancingV2::LoadBalancer"
    Properties:
      Name: my-network-lb
      Type: network
      Subnets:
        - subnet-aabbccdd
        - subnet-ddeeff11
        - subnet-22334455
Outputs:
  MyNLB:
    Description: The ARN of the newly provisioned NLB
    Value: !Ref NetworkLoadBalancer
playbook.yml
---
- hosts: all
  tasks:
    - name: launch ansible network lb stack with cloudformation
      cloudformation:
        stack_name: MyNetworkLBStack
        state: present
        region: eu-west-1
        template: my-lb-stack.yml
      register: nlbstack
    - name: check the facts of the load balancer
      elb_application_lb_facts:
        load_balancer_arns:
          - "{{ nlbstack.stack_outputs.MyNLB }}"
answered Mar 24 by Arc

Related Questions In Ansible

0 votes
1 answer
0 votes
1 answer

Ansible Playbook to create a Load Balancer

Hey @Himanshu, you can try something like ...READ MORE

answered Mar 25 in Ansible by Jack
23 views
0 votes
1 answer

How can I create a new user using ansible ploybook?

You're switching from the root user. Root ...READ MORE

answered Mar 29, 2018 in Ansible by DareDev
• 6,560 points
69 views
0 votes
3 answers
+13 votes
2 answers
0 votes
1 answer
0 votes
1 answer

Ansible with AWS Parameter store

Hey @Dipti, have a look at the ...READ MORE

answered Mar 24 in Ansible by Rhea
33 views
0 votes
1 answer

Playbook to get my current IP - Ansible and AWS

Hey Komal, that's pretty simple. Try this: - ...READ MORE

answered Mar 24 in Ansible by Aarohi
22 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.