Fix in sqlalchemy collectd plugin

While evaluating the conditional statement
(when: (('Controller' in group_names) and ('plugin=collectd' not in item.stdout) and sqlalchemy_collectd_plugin)),
if sqlalchemy_collectd_plugin is set to false, the register db_connections does not store any output as the
step (Get mysql string) is skipped. This causes the error (dict object has no attribute stdout).
This patch fixes the issue by placing the condition check ('plugin=collectd' not in item.stdout) at the end of
the when statement, and due to lazy evaluation of conditional statements in Ansible, the condition check is skipped
if sqlalchemy_collectd_plugin is set to false.

Change-Id: I20302e43318c969fb15acd8e78d30cc7c5c208af
This commit is contained in:
Sanjay Chari 2021-12-09 11:04:54 +05:30
parent dc8393e3c8
commit cd9c30c1a1

View File

@ -75,7 +75,7 @@
section: database
option: connection
value: "{{ item.stdout }}&plugin=collectd&collectd_program_name={{ item.item.key }}"
when: (('Controller' in group_names) and ('plugin=collectd' not in item.stdout) and sqlalchemy_collectd_plugin)
when: (('Controller' in group_names) and sqlalchemy_collectd_plugin and ('plugin=collectd' not in item.stdout))
with_items: "{{ db_connections.results }}"
become: true