Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elb_network_lb always shown as changed #604

Closed
mszumilak opened this issue Jun 21, 2021 · 6 comments · Fixed by ansible-collections/amazon.aws#940
Closed

elb_network_lb always shown as changed #604

mszumilak opened this issue Jun 21, 2021 · 6 comments · Fixed by ansible-collections/amazon.aws#940
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) python3

Comments

@mszumilak
Copy link

SUMMARY

elb_network_lb shows state of LB as changed with no changes made.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

elb_nework_lb

ANSIBLE VERSION
ansible [core 2.11.1] 
  config file = /home/x/ansible.cfg
  configured module search path = ['/home/x/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/x/venvs/ansible/lib/python3.8/site-packages/ansible
  ansible collection location = /home/x/.ansible/collections
  executable location = /home/x/venvs/ansible/bin/ansible
  python version = 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0]
  jinja version = 3.0.1
  libyaml = True

CONFIGURATION
n/a
OS / ENVIRONMENT

n/a

STEPS TO REPRODUCE

Create NLB and re-run the same task/playbook

- name: Create internal NLB
  elb_network_lb:
    name: "my-internal-nlb"
    deletion_protection: True
    subnets: "{{ private_elb_subnets }}"
    scheme: internal
    listeners:
      - Protocol: TCP
        Port: 5555
        DefaultActions:
          - Type: forward
            TargetGroupName: "{{ target_group_1_name }}"
      - Protocol: TCP
        Port: 5556
        DefaultActions:
          - Type: forward
            TargetGroupName: "{{ target_group_2_name }}"
    state: present
    region: "{{ aws_region }}"
EXPECTED RESULTS

I'd exect this module to show no changes if there are no changes.

ACTUAL RESULTS

Every time I run the playbook the NLB task is shown as changed

TASK [aws/eks : Create internal NLB] ******************************************
changed: [localhost]
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 labels Jun 21, 2021
@markuman
Copy link
Member

The error is happening in amazon.aws collection plugins/module_utils/elbv2.py L618 and following lines

  0.0s compare_listeners: 
      new_listener={'DefaultActions': [{'TargetGroupArn': 'arn:aws:elasticloadbalancing:eu-central-1:111:targetgroup/test1/d277d07b1a53b119', 'Type': 'forward'}], 'Port': 5555, 'Protocol': 'TCP'}
 0.0s _compare_listener: 
      current_listener['DefaultActions']=[{'ForwardConfig': {'TargetGroups': [{'TargetGroupArn': 'arn:aws:elasticloadbalancing:eu-central-1:111:targetgroup/test1/d277d07b1a53b119'}]}, 'TargetGroupArn': 'arn:aws:elasticloadbalancing:eu-central-1:111:targetgroup/test1/d277d07b1a53b119', 'Type': 'forward'}]

this fixes the issue

diff --git a/plugins/module_utils/elbv2.py b/plugins/module_utils/elbv2.py
index 8ad0bbf..563a542 100644
--- a/plugins/module_utils/elbv2.py
+++ b/plugins/module_utils/elbv2.py
@@ -616,6 +616,7 @@ class ELBListeners(object):
         # If the lengths of the actions are the same, we'll have to verify that the
         # contents of those actions are the same
         if len(current_listener['DefaultActions']) == len(new_listener['DefaultActions']):
+            current_listener['DefaultActions'][0].pop('ForwardConfig')
             current_actions_sorted = _sort_actions(current_listener['DefaultActions'])
             new_actions_sorted = _sort_actions(new_listener['DefaultActions'])
 

results in

TASK [Create internal NLB] **********************************************************************************************************************************************************************************************************
ok: [localhost]

but maybe breaks other things? a PR/Issue in amazon.aws is necessary.

alinabuzachis added a commit to alinabuzachis/community.aws that referenced this issue May 25, 2022
Tag EC2 volume on creation

SUMMARY

Tag EC2 volume on creation using TagSpecifications.
Fixes: ansible-collections#596

ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_vol

Reviewed-by: Jill R <None>
Reviewed-by: None <None>
@hectoralicea
Copy link

I have the opposite issue. When I re-run my create elb with static IPs I get the following error:

TASK [ansible-role-aws-ingress-controller : install-nlb-to-ingress.yaml | create an internal ELB with a specified IP address] ********************************************
fatal: [localhost]: FAILED! => changed=false 
  msg: Modifying subnets and elastic IPs is not supported for Network Load Balancer

it should state "ok:" since nothing is being changed.

@tremble
Copy link
Contributor

tremble commented Jul 21, 2022

@hectoralicea the error you're seeing looks like it's unrelated, please open a separate issue.

@tremble
Copy link
Contributor

tremble commented Jul 21, 2022

@mszumilak hopefully the issue you're hitting will be fixed by ansible-collections/amazon.aws#940

softwarefactory-project-zuul bot pushed a commit to ansible-collections/amazon.aws that referenced this issue Jul 22, 2022
More work on ELBv2 module_utils

SUMMARY

Refactors LB creation and makes sure that  ip_address_type is set on creation (bug found when working on fixing NLB tests)
Fixes bug with DefaultAction comparisons
Extends tests for _prune_ForwardConfig
Extends tests for _prune_secrets
Fixes KeyError bug uncovered when extending tests for _prune_secrets

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/module_utils/elbv2.py
ADDITIONAL INFORMATION
Fixes: ansible-collections/community.aws#604
See also: ansible-collections/community.aws#1365

Reviewed-by: Alina Buzachis <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug has_pr module module plugins plugin (any type) python3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants