What the heck is this?!?

This may be the most incomprehensible Ansible error message I ave seen yet :slight_smile:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: KeyError: ‘HealthCheckPath’
fatal: [localhost]: FAILED! => {“changed”: false, “module_stderr”: “Traceback (most recent call last):\n File "/tmp/ansible_sNNqfv/ansible_module_elb_target_group.py", line 705, in \n main()\n File "/tmp/ansible_sNNqfv/ansible_module_elb_target_group.py", line 699, in main\n create_or_update_target_group(connection, module)\n File "/tmp/ansible_sNNqfv/ansible_module_elb_target_group.py", line 444, in create_or_update_target_group\n if 'HealthCheckPath’in params and tg[‘HealthCheckPath’] != params[‘HealthCheckPath’]:\nKeyError: ‘HealthCheckPath’\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”, “rc”: 1}

The main bit seems to be: this test:

if 'HealthCheckPath’in params and tg[‘HealthCheckPath’] != params[‘HealthCheckPath’]

I have no idea how to fix this.

I have a parameter that looks like this:

tg_health_check:

path: “/ADFS/probe”
port: 80
timeout: 5
protocol: HTTP
interval: 30
threshold_count: 3

Which I pass into a role that looks like this:

  • elb_target_group:
    state: present
    region: “{{ tg_region }}”
    vpc_id: “{{ tg_vpc_id }}”
    name: “{{ tg_name }}”
    port: “{{ tg_port }}”
    protocol: “{{ tg_protocol }}”
    targets: “{{ tg_targets }}”
    target_type: “{{ tg_target_type }}”
    health_check_protocol: “{{ tg_health_check.protocol }}”
    health_check_port: “{{ tg_health_check.port }}”
    health_check_path: “{{ tg_health_check.path }}”
    health_check_timeout: “{{ tg_health_check.timeout }}”
    health_check_interval: “{{ tg_health_check.interval }}”
    healthy_threshold_count: “{{ tg_health_check.threshold_count }}”
    tags: “{{ all_tags }}”
    register: tg

I figured it out - it was because I was trying to change the protocol on a target group, and that isn’t allowed.

It’s a very poor error message though.

Regards, K.

Hi,

I figured it out - it was because I was trying to change the protocol
on a target group, and that isn't allowed.

It's a very poor error message though.

well, that's because it is a bug in the module :slight_smile: Please create an
issue on github for the elb_target_group module and explain what you
were doing, so the maintainers can add some code which catches this
error and prints something nicer for the users :slight_smile:

Cheers,
Felix