-
Notifications
You must be signed in to change notification settings - Fork 7
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
Error generating reports with client_sw role #21
Comments
Hi Cullen, |
Attached is the output with the -v option. Thanks, |
Hi Cullen, |
Output with the -vvv option Thanks, |
Hi Cullen,
You are going to get something like this:
Please share the commands' output. Thank you! |
|
We need at least version 2.10. Is it possible for you to install a newer jinja2 version? |
I believe this version of jinja2 was installed when Red Hat Ansible Engine 2.9 was installed. I am checking with Red Hat support as I don't see a newer version of Ansible Engine in their repositories. |
I don't know if this approach works but I installed rh-python38.x86_64 and rh-python38-python-jinja2.noarch. Then I added "source scl_source enable rh-python38” to the .bashrc file for user1. After logging in as the user, this is what I get: [user1@server1 ~]$ python --version
I ran the playbook again as user1 but still see the same error: failed: [server1] (item={u'dest': u'client_sw_report.csv', u'src': u'client_sw_report.csv.j2'}) => { |
Maybe not since ansible still shows the python version as 2.7.5 [user1@server1 ~]$ ansible --version |
While I was trying to reproduce the error I tried to change the python version ansible uses on the controller node because my ansible uses python 3 and I would have liked it to use python 2.7.5 instead. Then I found this in ansible doc: |
Hi,
I downloaded the zip file and unzipped it on my RHEL 7 server. I am pretty much running the example playbook provided for the client_sw role against one host and I get errors when the generate_reports task runs for both the csv and html reports. Can you just use the client_sw_report.csv.j2 and client_sw_report.html.j2 templates as is from the zip file or do these require modifications?
I commented out the csv report and ran the playbook. Below is the error I see for the html report. Any ideas as to what causes this error?
TASK [roles/client_sw : generate reports] ***********************************************************************************************************************************
failed: [server1] (item={u'dest': u'client_sw_report.csv', u'src': u'client_sw_report.csv.j2'}) => {"ansible_loop_var": "item", "changed": false, "item": {"dest": "client_sw_report.csv", "src": "client_sw_report.csv.j2"}, "msg": "AnsibleError: template error while templating string: expected token '=', got '.'. String: {# Print CSV header #}\nhostname,group,ip_address,os_distro,os_version,hw_arch,time,changed,unreachable,failed,details\n{# Loop through all hosts #}\n{% for host in ansible_play_hosts_all | sort %}\n{# System time #}\n{% if hostvars[host]['ansible_facts']['date_time'] is not defined %}\n{% set sys_time = '' %}\n{% else %}\n{% set sys_time = hostvars[host]['ansible_facts']['date_time']['date'] + ' ' + hostvars[host]['ansible_facts']['date_time']['time'] %}\n{% endif %}\n{# Package details #}\n{% set ns = namespace( details = [], changed = false ) %}\n{% for pkg_name in client_sw_pkg_state %}\n{% set pkg_file = hostvars[host]['ansible_facts']['sas_client_sw_pkgs']['packages'][pkg_name]['file'] | default('none', true) %}\n{% set pkg_vers = hostvars[host]['ansible_facts']['sas_client_sw_pkgs']['packages'][pkg_name]['vers'] | default('none', true) %}\n{% set pkg_req = hostvars[host]['ansible_facts']['sas_client_sw_' + pkg_name + 'req'] | default('none', true) %}\n{% set pkg_act = hostvars[host]['ansible_facts']['sas_client_sw' + pkg_name + 'act'] | default('none', true) %}\n{% set pkg_vers_beg = hostvars[host]['ansible_facts']['sas_client_sw' + pkg_name + 'vers_beg'] | default('none', true) %}\n{% set pkg_vers_end = hostvars[host]['ansible_facts']['sas_client_sw' + pkg_name + '_vers_end'] | default('none', true) %}\n{% set pkg_detail = {'key': pkg_name, 'value': {'installer_file': pkg_file, 'installer_version': pkg_vers, 'state_request': pkg_req, 'state_change': pkg_act, 'version_begin': pkg_vers_beg, 'version_end': pkg_vers_end}} %}\n{% if pkg_file != 'none' or pkg_act != 'none' %}\n{% set ns.details = ns.details + [pkg_detail] %}\n{% endif %}\n{% if pkg_act not in ['none', 'failed'] %}\n{% set ns.changed = true %}\n{% endif %}\n{% endfor %}\n{% set package_details = ns.details | items2dict %}\n{# Status #}\n{% set changed = ns.changed %}\n{% set unreachable = hostvars[host]['ansible_facts']['sas_client']['unreachable'] | default(False) %}\n{% set failed = hostvars[host]['ansible_facts']['sas_client']['failed'] | default(True) %}\n{% set msg = hostvars[host]['ansible_facts']['sas_client']['msg'] | default('Unexpected error occurred') %}\n{# Details #}\n{% set details = {\n 'hostname': host,\n 'msg': msg,\n 'unreachable': unreachable,\n 'failed': failed,\n 'changed': changed,\n 'packages': package_details\n }\n%}\n{# Format details #}\n{% if details %}\n{% if client_sw_reports_details_format | lower == 'json' %}\n{% set details = details | to_nice_json(indent=2) | replace("\"", "\"\"") %}\n{% else %}\n{% set details = details | to_nice_yaml(indent=2, width=160) | replace("\"", "\"\"") %}\n{% endif %}\n{% else %}\n{% set details = '' %}\n{% endif %}\n{# Print CSV line #}\n{{ '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,"%s"' | format(\nhost,\nhostvars[host]['group_names'] | join(', '),\nhostvars[host]['ansible_facts']['default_ipv4']['address'] | default(),\nhostvars[host]['ansible_facts']['distribution'] | default(),\nhostvars[host]['ansible_facts']['distribution_version'] | default(),\nhostvars[host]['ansible_facts']['architecture'] | default(),\nsys_time,\nchanged,\nunreachable,\nfailed,\ndetails\n)}}\n{% endfor %}"}
Thanks,
Cullen
The text was updated successfully, but these errors were encountered: