Skip to content

Conversation

mcdonnnj
Copy link
Member

🗣 Description

This pull request replaces the use of the copy module with apt_repository for Debian-based systems and yum_repository for RedHat-based systems.

💭 Motivation and context

Using these modules avoid having to manually configure file paths and permissions appropriately and results in a better maintenance position for this role.

🧪 Testing

Automated tests pass.

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • Changes are limited to a single goal - eschew scope creep!
  • All relevant type-of-change labels have been added.
  • I have read the CONTRIBUTING document.
  • These code changes follow cisagov code standards.
  • All new and existing tests pass.

Instead of using the `copy` module to create the SourceList file we
instead use the `apt_repository` module.
Instead of using the `copy` module to create the repository file we
instead use the `yum_repository` module.
@mcdonnnj mcdonnnj added the improvement This issue or pull request will add or improve functionality, maintainability, or ease of use label Apr 29, 2025
@mcdonnnj mcdonnnj requested review from a team and Copilot April 29, 2025 19:29
@mcdonnnj mcdonnnj self-assigned this Apr 29, 2025
@mcdonnnj mcdonnnj requested review from dav3r, felddy and jsf9k as code owners April 29, 2025 19:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request replaces the use of the ansible.builtin.copy module with repository-specific modules to manage package repositories more cleanly on Debian-based and RedHat-based systems.

  • For RedHat systems, the copy module was replaced with ansible.builtin.yum_repository, and repository configuration options were updated accordingly.
  • For Debian systems, the copy module was replaced with ansible.builtin.apt_repository with appropriate repository parameters.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tasks/setup_RedHat.yml Replaced the use of the copy module with yum_repository and adjusted options.
tasks/setup_Debian.yml Replaced the use of the copy module with apt_repository and updated parameters.

Copy link
Member

@jsf9k jsf9k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some suggestions, which you should feel free to argue against if you disagree with them.

Comment on lines +20 to 24
ansible.builtin.yum_repository:
# yamllint complains about the length of a couple of the lines below,
# but there is no way to shorten them.
#
# yamllint disable rule:line-length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove the yamllint disable directive...

Suggested change
ansible.builtin.yum_repository:
# yamllint complains about the length of a couple of the lines below,
# but there is no way to shorten them.
#
# yamllint disable rule:line-length
ansible.builtin.yum_repository:

Comment on lines +25 to +26
baseurl: https://dist.scaleft.com/repos/rpm/stable/{{ ansible_distribution_tweaked | lower }}/{{ ansible_distribution_major_version }}/$basearch
description: Okta PAM Stable - {{ ansible_distribution_tweaked }} {{ ansible_distribution_major_version }}
Copy link
Member

@jsf9k jsf9k Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...if you make these changes:

Suggested change
baseurl: https://dist.scaleft.com/repos/rpm/stable/{{ ansible_distribution_tweaked | lower }}/{{ ansible_distribution_major_version }}/$basearch
description: Okta PAM Stable - {{ ansible_distribution_tweaked }} {{ ansible_distribution_major_version }}
baseurl: >-
https://dist.scaleft.com/repos/rpm/stable/{{
ansible_distribution_tweaked | lower }}/{{
ansible_distribution_major_version }}/$basearch
description: >-
Okta PAM Stable - {{ ansible_distribution_tweaked }}
{{ ansible_distribution_major_version }}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on changing the description to:

Okta PAM Stable - {{ ansible_distribution_tweaked }}
{{ ansible_distribution_major_version }}

Since that still maintains the desired format without having to chop into the substitution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's fine.

Comment on lines 27 to 29
# Re-enable the line-length yamllint rule.
#
# yamllint enable rule:line-length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed too:

Suggested change
# Re-enable the line-length yamllint rule.
#
# yamllint enable rule:line-length

- name: Add the Okta ASA repo
ansible.builtin.copy:
content: >-
ansible.builtin.apt_repository:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we would use ansible.builtin.deb822_repository where possible. See, for example, here.

Copy link
Member Author

@mcdonnnj mcdonnnj Apr 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning to add that functionality in a follow-up PR though I was going to follow the logic in cisagov/ansible-role-backports.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this happening in a follow-on PR.

The nice thing about the example I provided is that it only checks for the presence of Buster. That means the logic will still work as written as new Debian versions are released. Or is there another reason to prefer the logic in the backports role?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason to prefer it, I would just prefer we be consistent. I knew backports role did a similar split-config with some getting DEB822 and some getting classic which is why I was using it as a reference. I was more just mentioning that my original intent was to use that logic and not arguing in favor of that logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement This issue or pull request will add or improve functionality, maintainability, or ease of use

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants