Skip to content

Issue with "ufw reset" function in Ubuntu 22.04Β #275

Description

@middleagedman

πŸ—£οΈ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

πŸ‘» Brief Description

I am creating a recipe that will flush all the rules before implementing the ones I want. I'm doing this to dynamically clear out IPs that are no longer around. I get an error every time from chef-client:

   ---- Begin output of ["ufw", "reset"] ----
     STDOUT: Resetting all rules to installed defaults. Proceed with operation (y|n)?
     STDERR: ERROR: '/etc/ufw/user.rules.20230403_002136' already exists. Aborting
     ---- End output of ["ufw", "reset"] ----
     Ran ["ufw", "reset"] returned 1

However, inspecting with "ufw status" shows the firewall disabled and the rules flushed.

πŸ₯ž Cookbook version

firewall (6.2.10)

πŸ‘©β€πŸ³ Chef-Infra Version

Chef Infra Client, version 18.1.0

🎩 Platform details

Testing on kitchen-dokken on Arch Linux with docker container stock ubuntu 22.04

Steps To Reproduce

Steps to reproduce the behavior:

Create simple firewall recipe:

# enable platform default firewall
firewall 'default' do
  action :install
end

firewall 'default' do
  action :flush
end

firewall_rule 'ssh' do
  source 'xx.xx.xx.xx/32'
  port 22
  protocol :tcp
  command :allow
end

However, I get the error indicated above. But when I run "ufw status" it is disabled and the rules are flushed. So it aborts after the initial flush prompt and doesn't create the port 22 rule

πŸš“ Expected behavior

ufw flush works correctly, then ufw is re-enabled and IP addresses added.

βž• Additional context

I can't seem to reproduce this manually. If I run a "ufw reset" by hand, it flushes the rules and disables UFW properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions