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, 2019 in Ansible by Neha
1,016 views

1 answer to this question.

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, 2019 by Arc

Related Questions In Ansible

0 votes
1 answer

How to create a key pair on AWS using Ansible-Playbook?

Hi@akhtar, You can find the ec2_key module in ...READ MORE

answered Aug 12, 2020 in Ansible by MD
• 95,440 points
1,134 views
0 votes
1 answer

How to create an Elastic Load Balancer in AWS with Ansible Playbook?

Hi@akhtar, You can find one module in ansible ...READ MORE

answered Oct 12, 2020 in Ansible by MD
• 95,440 points
922 views
0 votes
1 answer

How to create ECS service on VPC network using Ansible Playbook?

Hi@akhtar, An Amazon ECS service enables you to run and ...READ MORE

answered Dec 4, 2020 in Ansible by MD
• 95,440 points
701 views
0 votes
1 answer

How do I manage Server Load balancing on A10 network? - Ansible

Hey @Tanishq, you can use the a10_server ...READ MORE

answered Feb 11, 2019 in Ansible by Myra
735 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,508 views
+2 votes
1 answer
0 votes
1 answer

Ansible with AWS Parameter store

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

answered Mar 24, 2019 in Ansible by Rhea
788 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, 2019 in Ansible by Aarohi
1,098 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP