openshift-ansible
openshift-ansible copied to clipboard
[openshift_logging : conditional_set_fact] - "TypeError: string indices must be integers"
Description
When attempting to run the openshift-logging/config.yml playbook I am seeing the ansible playbooks fail when running the conditional_set_fact.py action callback.
Version
- Your ansible version per
ansible --version
ansible 2.8.1
config file = /home/ncc/documents/programming/infrastructure/ansible.cfg
configured module search path = ['/home/ncc/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/ncc/.local/lib/python3.7/site-packages/ansible
executable location = /home/ncc/.local/bin/ansible
python version = 3.7.3 (default, May 11 2019, 00:38:04) [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
I have also verified this issue occurs against ansible 2.6.
- The output of
git describe
openshift-ansible-3.11.119-1
Steps To Reproduce
- Use the following configuration in a yaml structured hosts file
openshift_logging_install_logging: true
openshift_logging_es_nodeselector:
"node-role.kubernetes.io/compute": "true"
- Run the logging installation playbook
/usr/share/ansible/openshift-ansible/playbooks/openshift-logging/config.yml
Expected Results
OpenShift logging stack to get installed
Observed Results
The conditional_set_fact.py action callback is failing with the following error:
TASK [openshift_logging : conditional_set_fact] **************************************************************************************************************************************
task path: /usr/share/ansible/openshift-ansible/roles/openshift_logging/tasks/set_defaults_from_current.yml:187
The full traceback is:
Traceback (most recent call last):
File "/home/ncc/.local/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 144, in run
res = self._execute()
File "/home/ncc/.local/lib/python3.7/site-packages/ansible/executor/task_executor.py", line 648, in _execute
result = self._handler.run(task_vars=variables)
File "/usr/share/ansible/openshift-ansible/roles/lib_openshift/action_plugins/conditional_set_fact.py", line 57, in run
local_facts[param] = facts[other_var]
TypeError: string indices must be integers
fatal: [ec2-3-93-100-129.compute-1.amazonaws.com]: FAILED! => {}
MSG:
Unexpected failure during module execution.
Additional Information
The issue seems to be caused by the facts
variable being interpreted as a string instead of a dictionary on line 57. I am not sure why this is occurring.
The values of the relevant variables during failure are:
local_facts: {}
param: 'openshift_logging_es_nodeselector'
facts: {... dictionary/string containing a large number of host facts ...}
other_var: 'openshift_logging_es_nodeselector'
This issue also seems to be caused by using a yaml based ansible inventory.
I have the same issue but I'm not using yaml mode:
openshift-ansible-3.11.127-1
host file:
openshift_logging_install_logging=true
openshift_logging_es_memory_limit=512M
openshift_logging_kibana_hostname=logging.cluster.***
openshift_logging_master_public_url=https://openshift.cluster.***:8443
openshift_logging_es_nodeselector={"node-role.kubernetes.io/infra":"true"}
ansible:
ansible 2.8.1
error:
TASK [openshift_logging : conditional_set_fact] ****************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: string indices must be integers
fatal: [cluster-master1-prd.***]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}
Downgrading to ansible 2.7.12 solved the problem for me.
Also upgrading to ansible 2.8.2
or 2.8.4
worked for me.
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle stale
TASK [openshift_logging : conditional_set_fact] **************************************************************************************************************************************************************************************************************
task path: /Users/jkr/Documents/ansible/ansible/openshift-ansible/roles/openshift_logging/tasks/set_defaults_from_current.yml:187
The full traceback is:
Traceback (most recent call last):
File "/usr/local/Cellar/ansible/2.9.9/libexec/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 146, in run
res = self._execute()
File "/usr/local/Cellar/ansible/2.9.9/libexec/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 645, in _execute
result = self._handler.run(task_vars=variables)
File "/Users/jkr/Documents/ansible/ansible/openshift-ansible/roles/lib_openshift/action_plugins/conditional_set_fact.py", line 57, in run
local_facts[param] = facts[other_var]
TypeError: string indices must be integers
fatal: [openshift-master1]: FAILED! => {}
MSG:
Unexpected failure during module execution.
Have the same error on ansible 2.9.9
/remove-lifecycle stale
I change the code to this:
for other_var in other_vars.split('|'):
if other_var in facts:
print(param); print(other_var); print(type(facts));
local_facts[param] = facts[other_var]
break
which results into this:
...
TASK [openshift_logging : set_fact] **************************************************************************************************************************************************************************************************************************
ok: [openshift-master1]
__openshift_logging_fluentd_memory_limit
fluentd-elasticsearch.resources.limits.memory
<class 'dict'>
__openshift_logging_fluentd_cpu_request
fluentd-elasticsearch.resources.requests.cpu
from ansible.plugins.action import ActionBase
<class 'dict'>
TASK [openshift_logging : conditional_set_fact] **************************************************************************************************************************************************************************************************************
changed: [openshift-master1]
openshift_logging_es_number_of_replicas
openshift_logging_es_number_of_replicas
<class 'str'>
TASK [openshift_logging : conditional_set_fact] **************************************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: string indices must be integers
fatal: [openshift-master1]: FAILED! => {}
MSG:
Unexpected failure during module execution.
For unknown reasons. facts
is a str
.
It's a ansible issue: https://github.com/ansible/ansible/issues/69914
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten
.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen
.
If this issue is safe to close now please do so with /close
.
/lifecycle rotten /remove-lifecycle stale
unstale
/remove-lifecycle rotten
/remove-lifecycle rotten /lifecycle frozen
/close
@barbacbd: Closing this issue.
In response to this:
/close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.