Last active
February 21, 2018 18:56
-
-
Save anryko/c854ec431a1b25667da4f1c24a1a23e4 to your computer and use it in GitHub Desktop.
Ansible AWS ALB Listeners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: test | |
hosts: localhost | |
connection: local | |
gather_facts: False | |
vars: | |
listeners: | |
- Protocol: HTTP | |
# Port: 80 | |
DefaultActions: | |
- Type: forward # Required. Only 'forward' is accepted at this time | |
TargetGroupName: se1-stg-webapp-all-alb-http # Required. The name of the target group | |
- Protocol: HTTPS | |
# Port: 443 | |
# SslPolicy: ELBSecurityPolicy-2016-08 | |
Certificates: | |
- CertificateArn: aaa | |
- CertificateArn: bbb | |
listener_http_default: | |
Port: 80 | |
listener_https_default: | |
Port: 443 | |
SslPolicy: ELBSecurityPolicy-2016-08 | |
Certificates: [] | |
new_listeners: [] | |
pre_tasks: | |
- include_tasks: listeners_loop.yml | |
loop_control: | |
loop_var: listener | |
with_items: "{{ listeners }}" | |
- debug: | |
var: new_listeners |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- set_fact: | |
new_listeners: "{{ new_listeners + [ listener_http_default | combine(listener) ] }}" | |
when: listener.Protocol == 'HTTP' | |
- block: | |
- set_fact: | |
old_certificates: "{{ listener.Certificates }}" | |
- set_fact: | |
first_certificate: | |
Certificates: | |
- "{{ old_certificates[0] }}" | |
- set_fact: | |
new_listeners: "{{ new_listeners + [ listener_https_default | combine(listener) | combine(first_certificate) ] }}" | |
when: listener.Protocol == 'HTTPS' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment