Skip to content

Instantly share code, notes, and snippets.

@anryko
Last active February 21, 2018 18:56
Show Gist options
  • Select an option

  • Save anryko/c854ec431a1b25667da4f1c24a1a23e4 to your computer and use it in GitHub Desktop.

Select an option

Save anryko/c854ec431a1b25667da4f1c24a1a23e4 to your computer and use it in GitHub Desktop.

Revisions

  1. anryko revised this gist Feb 20, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions listeners.yml
    Original file line number Diff line number Diff line change
    @@ -9,14 +9,14 @@
    - 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
    - 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'
    - CertificateArn: aaa
    - CertificateArn: bbb

    listener_http_default:
    Port: 80
  2. anryko revised this gist Feb 20, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion listeners_loop.yml
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,8 @@

    - set_fact:
    first_certificate:
    - Certificates: "{{ old_certificates[0] }}"
    Certificates:
    - "{{ old_certificates[0] }}"

    - set_fact:
    new_listeners: "{{ new_listeners + [ listener_https_default | combine(listener) | combine(first_certificate) ] }}"
  3. anryko revised this gist Feb 20, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion listeners_loop.yml
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@

    - set_fact:
    first_certificate:
    Certificates: "{{ old_certificates[0] }}"
    - Certificates: "{{ old_certificates[0] }}"

    - set_fact:
    new_listeners: "{{ new_listeners + [ listener_https_default | combine(listener) | combine(first_certificate) ] }}"
  4. anryko revised this gist Feb 20, 2018. 2 changed files with 5 additions and 5 deletions.
    6 changes: 3 additions & 3 deletions listeners.yml
    Original file line number Diff line number Diff line change
    @@ -7,13 +7,13 @@
    vars:
    listeners:
    - Protocol: HTTP
    Port: 80
    # 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
    # Port: 443
    # SslPolicy: ELBSecurityPolicy-2016-08
    Certificates:
    - CertificateArn: 'aaa'
    - CertificateArn: 'bbb'
    4 changes: 2 additions & 2 deletions listeners_loop.yml
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    - set_fact:
    new_listeners: "{{ new_listeners + [ listener | combine(listener_http_default) ] }}"
    new_listeners: "{{ new_listeners + [ listener_http_default | combine(listener) ] }}"
    when: listener.Protocol == 'HTTP'

    - block:
    @@ -11,5 +11,5 @@
    Certificates: "{{ old_certificates[0] }}"

    - set_fact:
    new_listeners: "{{ new_listeners + [ listener | combine(listener_https_default) | combine(first_certificate) ] }}"
    new_listeners: "{{ new_listeners + [ listener_https_default | combine(listener) | combine(first_certificate) ] }}"
    when: listener.Protocol == 'HTTPS'
  5. anryko created this gist Feb 20, 2018.
    38 changes: 38 additions & 0 deletions listeners.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    ---
    - 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
    15 changes: 15 additions & 0 deletions listeners_loop.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    - set_fact:
    new_listeners: "{{ new_listeners + [ listener | combine(listener_http_default) ] }}"
    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 | combine(listener_https_default) | combine(first_certificate) ] }}"
    when: listener.Protocol == 'HTTPS'