Skip to content

Commit

Permalink
Handle change in extrepo Enabled/Disabled sources file
Browse files Browse the repository at this point in the history
(cherry picked from commit a34f78e)
  • Loading branch information
julien-lecomte authored and drybjed committed Mar 17, 2023
1 parent d06757d commit 1bc62e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ General
Ansible requires use of FQCNs in filters. The ``ansible.utils`` Ansible
Collection is now a dependency of the DebOps Collection.

- Extrepo facts file did not detect a disabled repository as being disabled
due to a change in the extrepo file format.

:ref:`debops.pki` role
''''''''''''''''''''''

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-

# Copyright (C) 2021 Maciej Delmanowski <drybjed@gmail.com>
# Copyright (C) 2021 DebOps <https://debops.org/>
# Copyright (C) 2021-2023 DebOps <https://debops.org/>
# SPDX-License-Identifier: GPL-3.0-or-later

# {{ ansible_managed }}
Expand Down Expand Up @@ -33,14 +33,20 @@ except Exception:

sources_path = '/etc/apt/sources.list.d'

sources_files = [f for f in os.listdir(sources_path)
sources_files = [sources_path + "/" + f for f in os.listdir(sources_path)
if os.path.isfile(os.path.join(sources_path, f))]

sources = []

for item in sources_files:
if item.startswith('extrepo_') and item.endswith('.sources'):
sources.append(item[8:-8])
with open(item, mode="r") as fd:
lines = fd.readlines()
# Missing, or 'Enabled: yes\n' means enabled
disabled = 'Enabled: no\n' in lines
if not disabled:
item = os.path.basename(item)
if item.startswith('extrepo_') and item.endswith('.sources'):
sources.append(item[8:-8])

output['sources'] = sources

Expand Down

0 comments on commit 1bc62e3

Please sign in to comment.