Closed Pierroto69 closed 9 months ago
with yhe right format of playbook, the copy paste was not very good :) i attached a print screen
Can you provide some environment information? Level/version of collection, control node OS and level, level of ansible and python on control node, and level of python on target node.
Hi Rob, thanks for your support see below informations you request :
Control node : Ansible tower Ansible Automation Platform Controller 4.4.8 November 21, 2023 Galaxy collection ibm.power_ibmi:2.0.0 ansible python module location = /usr/lib/python3.8/site-packages/ansible python version = 3.8.16 (default, May 31 2023, 12:44:21) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)] Host partition variable ansible_python_interpreter : '/QOpensys/pkgs/bin/python3' Source Control URL : https://github.kyndryl.net/zouhair-oulli/ansible-for-i-devel
Target node OS400 V7R3M0 cumulative 23 103 python 3.9.16-1
On target node i upgrade python39 from 3.9.16-1 to 3.9.18-1 and also put on control node Host partition variable ansible_python_interpreter : '/QOpensys/pkgs/bin/python3.9' instead python3
But same error
OK, I took a closer look and there are a couple of issues I am seeing that I had to resolve before this worked.
The example documentation for sync_apply_ptf_group places the ptf group info in quotes, which is making the value a string instead of dict, so that doesn't work. I am assuming this was simply documented incorrectly versus working at one point in time with older levels of ansible.
The other issue I see later on is there is a bug in the role where it references repo_server instead of src_host (repo_server is a common variable used in the roles, so must have been defined in our test and the issue went totally unnoticed), so we need to define repo_server to src_host as a temporary work around until the code is fixed and patch or publish provided.
Your code should look something like the following for the role vars (with a different ptf group here):
vars:
ptf_group_info: { 'file_path': '/home/TESTER/SYNCPTFs', 'file_name': ['SF99666_1.BIN'] }
src_host: "{{ src_host }}"
repo_server: "{{ src_host }}"
Please try this with revised "ptf_group_info" variable value and the extra "repo_server" variable and I expect this will work for you now. We can keep the issue open until a fix is provided (and as a reminder for me to check other role documentation for similar mistake so that other folks don't have to stumble over incorrect examples).
Hi Rob , thanks for your help, i retry it's works fine except I have new issue in main line 20 column 3 , have you an idea ? thanks , see atched file joblog and below error message
job_log_error line 20 main .txt
TASK [Include check_file role to check if files are the same] ** task path: /runner/requirements_collections/ansible_collections/ibm/power_ibmi/roles/sync_apply_ptf_group/tasks/main.yml:20 fatal: [fotest.iis.ibmfr.bluecare.ibm.com]: FAILED! => { "msg": "The conditional check 'stat_result.stat.exists is true' failed. The error was: template error while templating string: no test named 'true'. String: {% if stat_result.stat.exists is true %} True {% else %} False {% endif %}\n\nThe error appears to be in '/runner/requirements_collections/ansible_collections/ibm/power_ibmi/roles/sync_apply_ptf_group/tasks/main.yml': line 20, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Include check_file role to check if files are the same\n ^ here\n" }
That is interesting. I didn't see that issue. I may have already had the directory defined on target though. What level of ansible is this on control node? We need to be at 2.14 or 2.15 for collection at 2.0.0.
I don't like how the role uses "is true" in conditional instead of using the name by itself for a boolean, but not sure why throwing an error for you. Using "stat_result.stat.exists is true" instead of what I'd prefer with "stat_result.stat.exists" in the problem section you are hitting:
May need to look at cleaning up this role file and then seeing it that helps (use "exists" or "not exists" in conditionals instead of things like "exists is true").
Hi Rob, yes i understand for the condition but how to cleaning up this role file and then seeing it that helps (use "exists" or "not exists" in conditionals instead of things like "exists is true") ?
se below version on Control node : Ansible tower Ansible Automation Platform Controller 4.4.8 November 21, 2023 Galaxy collection ibm.power_ibmi:2.0.0 ansible python module location = /usr/lib/python3.8/site-packages/ansible python version = 3.8.16 (default, May 31 2023, 12:44:21) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)]
OK, it would be helpful to run "ansible --version" on the control/tower node to see what ansible core level is.
I am not sure why you are hitting this error but changing the check for this task given that "exists" is always defined from the stat module regardless of result. Attaching updated role file from source at roles/sync_apply_ptf_group/tasks/main.yml that you should copy into your ibmi collection that will be placed at this path:
/
Hi Rob, thanks but I haven't possibility to change the main.yml in role sync_apply_ptf_group as the galaxy collection is installed on controler node shared and secure by our enterprise , we use "tower ansible" GUI interface , job template , scheduling and we don't have access to terminal for online command , so our only solution we see is to have a new release of galaxy ibm i collection with our update of this issue , when do you think it will be possible ? many thanks
Probably won't have an update for a couple of months. Not certain why you are hitting the last error, so code clean-up I mention may not resolve the last problem, but thought it was worth a try given it makes the code cleaner.
The only thing I can find on this error is from one online forum, but doesn't give environment / context of user: https://www.reddit.com/r/ansible/comments/z80q18/conditional_check_service_filestatexists_is_true/ Not clear why I don't see the issue but you do. The prior code authors I believe used "X is true" to implicitly handle undefined variables, so this is really doing "X is defined and X" from what I gather. I'lll clean up this role but there will be other places this crops up in the collection to look at later (see we are also using this with a check after conditional call to "check_files" role with "same_files" return var in the sync_apply_ptf_group role).
Hi Rob, very interesting your link to the same issue , thanks a lot for your help i will see with the team how to manage
Hi Rob , in fact we realize that we was running on 2.13 of ansible control node and we test the playbook on test environment 2.15 it's running well, sorry for inconvenient , many thanks for your help , we can close the issue
OK, glad that fixed it up. This was helpful to investigate anyway because it identified a documentation error for the ptf_group_info argument and I found another bug in the role that also occurred in the similar lvl1 role. I did clean up the relevant code hitting the issue on 2.13 in these two roles because it makes things more readable.
Resolved with release 2.0.1.
Hi , when i execute playbook with role "sync_apply_ptf_group" I have an error : "msg": "The task includes an option with an undefined variable. The error was: Unable to look up a name or access an attribute in template string ({{ dest }}/{{ ptf_group_info.file_path | basename }}).\nMake sure your variable name does not contain invalid characters like '-': expected str, bytes or os.PathLike object, not AnsibleUndefined\n\nThe error appears to be in '/runner/requirements_collections/ansible_collections/ibm/power_ibmi/roles/sync_apply_ptf_group/tasks/main.yml': line 10, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Compose target tmp dir str\n ^ here\n", "_ansible_no_log": false
Playbook is the following
hosts: all gather_facts: yes collections:
vars: ptf_group_info: "{ 'file_path': '/QIBM/UserData/OS/Service/ECS/PTF/2333955458', 'file_name': ['S8052V01.BIN'] }" src_host: "{{ src_host }}"
tasks:
and I put joblog in a file attached to the issue
Have you an idea about the reror ? thanks job_sync_apply_ptf_group log error .txt