Skip to content

Instantly share code, notes, and snippets.

@farahfa
Created June 29, 2017 17:44
Show Gist options
  • Save farahfa/ed46167b1a26684e6dd2235af8d862b8 to your computer and use it in GitHub Desktop.
Save farahfa/ed46167b1a26684e6dd2235af8d862b8 to your computer and use it in GitHub Desktop.
- name: Create new Elastic Search load balancer if it doesn't exists
ec2_elb_lb:
name: "{{ elb_name }}"
state: present
region: "{{aws_region}}"
scheme: internal
subnets:
- "{{ elb_subnet_1 }}"
- "{{ elb_subnet_2 }}"
- "{{ elb_subnet_3 }}"
security_group_ids: "{{vpc_sg}}"
listeners:
- protocol: tcp
- load_balancer_port: 9600
- instance_port: 9600
stickiness:
type: loadbalancer
enabled: yes
expiration: 300
access_logs:
interval: 5 # minutes (defaults to 60)
s3_location: "{{ lb_log_location }}" # This value is required if access_logs is set
s3_prefix: "logstash"
cross_az_load_balancing: "yes"
# when: ' "{{lb_name}}" != "{{ elb_name }}" '
when: elb_name_output is undefined
@farahfa
Copy link
Author

farahfa commented Jun 29, 2017

The error msg that I get is this:

TASK [aws.instance : Create new Elastic Search  load balancer if it doesn't exists] ***
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: 'load_balancer_port'
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_WObIqE/ansible_module_ec2_elb_lb.py\", line 1359, in <module>\n    main()\n  File \"/tmp/ansible_WObIqE/ansible_module_ec2_elb_lb.py\", line 1346, in main\n    elb_man.ensure_ok()\n  File \"/tmp/ansible_WObIqE/ansible_module_ec2_elb_lb.py\", line 418, in _do_op\n    return op(*args, **kwargs)\n  File \"/tmp/ansible_WObIqE/ansible_module_ec2_elb_lb.py\", line 488, in ensure_ok\n    self._create_elb()\n  File \"/tmp/ansible_WObIqE/ansible_module_ec2_elb_lb.py\", line 709, in _create_elb\n    listeners = [self._listener_as_tuple(l) for l in self.listeners]\n  File \"/tmp/ansible_WObIqE/ansible_module_ec2_elb_lb.py\", line 814, in _listener_as_tuple\n    int(listener['load_balancer_port']),\nKeyError: 'load_balancer_port'\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 0}
	to retry, use: --limit @/var/lib/jenkins/workspace/Us1-prod.eng-pst.ansible-logstash-deployment/logstash.retry

@s-hertel
Copy link

Hi @farahfa. Does this problem persist if you specify listeners like this?

listeners:
  - protocol: tcp
    load_balancer_port: 9600
    instance_port: 9600

Right now your playbook reads as though it is designating three listeners rather than one listener with those three attributes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment