-
Notifications
You must be signed in to change notification settings - Fork 70
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
ifcfg files reading issue fix #487
ifcfg files reading issue fix #487
Conversation
f7c2ef8
to
96a93d5
Compare
recheck |
/retest-required |
recheck |
/retest-required |
roles/edpm_kernel/tasks/reboot.yaml
Outdated
@@ -62,8 +62,7 @@ | |||
# This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage) | |||
# Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4'] is undefined | |||
- hostvars[inventory_hostname]['ansible_facts'][item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_')]['ipv4'] is undefined | |||
loop: | |||
- "{{ ifcfg_files.files }}" | |||
loop: "{{ ifcfg_files.files | flatten(levels=1) }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is flatten needed? Can you explain in a more detailed commit message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slagle this task requires looping ifcfg files and not list of ifcfg files list, missing file parameters in looping var 'item'. so changed to loop only list of ifcfg files and tested working fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifcfg_file.files is the list of files, call it X. flatten would take any of those X list items and if that item Y is also a list, it will take the list items of Y and add them to X.
See sample output:
shell-el7.hosts.prod.upshift.rdu2.redhat.com | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"examined": 35,
"files": [
{
"atime": 1701142182.7918751,
"ctime": 1602802230.2658126,
"dev": 64768,
"gid": 0,
"gr_name": "root",
"inode": 67198113,
"isblk": false,
"ischr": false,
"isdir": false,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": true,
"issock": false,
"isuid": false,
"mode": "0644",
"mtime": 1590144273.0,
"nlink": 1,
"path": "/etc/sysconfig/network-scripts/ifcfg-lo",
"pw_name": "root",
"rgrp": true,
"roth": true,
"rusr": true,
"size": 254,
"uid": 0,
"wgrp": false,
"woth": false,
"wusr": true,
"xgrp": false,
"xoth": false,
"xusr": false
},
{
"atime": 1701142182.7958753,
"ctime": 1563746161.165,
"dev": 64768,
"gid": 0,
"gr_name": "root",
"inode": 67455073,
"isblk": false,
"ischr": false,
"isdir": false,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": true,
"issock": false,
"isuid": false,
"mode": "0644",
"mtime": 1563746161.165,
"nlink": 1,
"path": "/etc/sysconfig/network-scripts/ifcfg-eth0",
"pw_name": "root",
"rgrp": true,
"roth": true,
"rusr": true,
"size": 211,
"uid": 0,
"wgrp": false,
"woth": false,
"wusr": true,
"xgrp": false,
"xoth": false,
"xusr": false
}
],
"matched": 2,
"msg": "All paths examined",
"skipped_paths": {}
}
Can you provide more details about the actual error, with a sample of the error and describe how this fixes it, all in the commit message, that would be helpful in pushing this one forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ifcfg_files.files is the list of dictionary, so looping works. issue item is again list item and not dictionary item when we use ' - "{{ ifcfg_files.files }}"'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we use '- "{{ ifcfg_files.files }}"', getting path is not found in item error. and working fine if we use only '{{ ifcfg_files.files }}'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You were likely getting the path is not found in item
error because you were nesting the files lists in a new list passed to loop
Try just this:
loop: "{{ ifcfg_files.files }}"
instead of:
loop:
- "{{ ifcfg_files.files }}"
then the flatten is likely not even necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated and working with no flatten.
96a93d5
to
e7925d5
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Jaganathancse, rebtoor The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
cce7511
into
openstack-k8s-operators:main
No description provided.