Skip to content
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

Network devices prelim task failure (devel branch) #73

Closed
fnschroeder opened this issue Mar 6, 2023 · 6 comments
Closed

Network devices prelim task failure (devel branch) #73

fnschroeder opened this issue Mar 6, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@fnschroeder
Copy link

Describe the Issue
When attempting to run the role from the devel branch, I am getting this bit executed:

  • name: "PRELIM | Find wireless network devices"
    ansible.builtin.shell: find /sys/class/net/*/wireless | awk -F'/' awk '{print $5}'
    failed_when: wireless_interfaces.rc not in [ 0, 2 ]
    changed_when: false
    register: wireless_interfaces
    when:
    - ubtu20cis_rule_3_1_2
    tags:
    - rule_3.1.2
    - section3

Then it should have registered a value in wireless_interfaces for it to be used with the next task:

  • name: "PRELIM | Install Network-Manager"
    ansible.builtin.package:
    name: network-manager
    state: present
    when:
    - wireless_interfaces.stdout | length > 0
    - ubtu20cis_install_network_manager
    - ubtu20cis_rule_3_1_2
    - not ubtu20cis_system_is_container
    tags:
    - rule_3.1.2
    - section3

But it throws me an error, see details below.

Expected Behavior
The prelim task to not fail when there are not network adapters or perhaps just run this not as prelim but as a regular role task.

Actual Behavior
fatal: [default]: FAILED! => {"msg": "The conditional check 'wireless_interfaces.stdout | length > 0' failed. The error was: error while evaluating conditional (wireless_interfaces.stdout | length > 0): 'dict object' has no attribute 'stdout'
The error appears to be in '/root/.ansible/roles/ubuntu-20-lockdown/tasks/prelim.yml': line 56, column 3, but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:

  • name: "PRELIM | Install Network-Manager"\n ^ here\n"}

Control(s) Affected
Rule 3_1_2

Possible Solution
main branch already doesn't have that added to prelim, perhaps doing it that way would be great.

** My role vars **
- role: ubuntu-20-lockdown
vars:
ubtu20cis_warning_banner: "{{ banner_text }}"
ansible_python_interpreter: /usr/bin/python3
ubtu20cis_grub_pw: "grub.pbkdf2.sha512.10000.{{ ansible_ops_cred }}"
ubtu20cis_set_root_password: false

    #Disable LVL 2 CIS tasks:
    ubtu20cis_rule_1_1_10: false
    ubtu20cis_rule_1_1_11: false
    ubtu20cis_rule_1_1_15: false
    ubtu20cis_rule_1_1_16: false
    ubtu20cis_rule_1_1_1_6: false
    ubtu20cis_rule_1_1_17: false
    ubtu20cis_rule_1_6_1_4: false
    ubtu20cis_rule_1_8_1: false
    ubtu20cis_rule_3_1_1: false
    ubtu20cis_rule_3_4_1: false
    ubtu20cis_rule_3_4_2: false
    ubtu20cis_rule_3_4_3: false
    ubtu20cis_rule_3_4_4: false 
    ubtu20cis_rule_4_1_1_4: false
    ubtu20cis_rule_5_3_20: false
    ubtu20cis_rule_5_3_6: false
    ubtu20cis_rule_6_1_1: false

** Additional Notes**
I would love to use the main branch but that one has the known bug which was fixed on devel:
2023-03-06T15:55:38Z: ubuntu20-ami-build.amazon-ebs.ubuntu_20_ami: TASK [ubuntu-20-lockdown : AUTOMATED | 1.3.2 | PATCH | Ensure filesystem integrity is regularly checked] ***
2023-03-06T15:55:39Z: ubuntu20-ami-build.amazon-ebs.ubuntu_20_ami: fatal: [default]: FAILED! => {"changed": false, "msg": "Will not manage /etc/crontab via cron_file, see documentation."}

@fnschroeder fnschroeder added the bug Something isn't working label Mar 6, 2023
@fnschroeder
Copy link
Author

The latest Feb changes seem to have introduced this: f706c12

Breaks my automation today but fully understand we all have other work to do as well, just trying to be as helpful as possible folks.

Best Regards,
Filipe

uk-bolly added a commit that referenced this issue Mar 7, 2023
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
@uk-bolly
Copy link
Member

uk-bolly commented Mar 7, 2023

hi @fnschroeder

Thank you for the feedback and the added detail. I have written a new branch issue_73 that should resolve the problem. The system we test on has no wireless adapter, so i didnt experience this issue. I am hoping that this branch captures this case?
If you have time to test that would be brilliant and i will raise the appropriate PR.

Many thanks again

uk-bolly

@uk-bolly uk-bolly self-assigned this Mar 7, 2023
@fnschroeder
Copy link
Author

Hi @uk-bolly , that worked like a charm, thanks a LOT!!

@fnschroeder
Copy link
Author

When this one is merged into the devel branch, I will switch my code but for now just pointing to your branch covers it.

FYI: I did have to add ubtu20cis_set_root_password: false on the vars cause I am using it on building AWS AMIs so we don't care for changing the password as it will be different already every time.

Thanks again for all your work!

@MrSteve81
Copy link
Contributor

MrSteve81 commented Apr 20, 2023

I have created the PR that should put this into devel. Sorry about the delay in this!

MrSteve81 added a commit that referenced this issue Apr 21, 2023
…Included FIX PR #81

Signed-off-by: Stephen Williams <stephenw@mindpointgroup.com>
@MrSteve81
Copy link
Contributor

This has been added to devel branch from PR [#83] Please feel free to test it out and get back to us.

MrSteve81 added a commit that referenced this issue Apr 27, 2023
Yamllint Check, Ansible-lint Chek, Module Updates, Bug #73&80 Fixed, Included FIX PR #81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants