-
Notifications
You must be signed in to change notification settings - Fork 2
Use repository modules instead of copy
#16
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
base: develop
Are you sure you want to change the base?
Use repository modules instead of copy
#16
Conversation
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.
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.
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. |
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.
I made some suggestions, which you should feel free to argue against if you disagree with them.
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 |
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.
I think you can remove the yamllint
disable directive...
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: |
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 }} |
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 you make these changes:
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 }} |
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.
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.
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.
Yes, that's fine.
# Re-enable the line-length yamllint rule. | ||
# | ||
# yamllint enable rule:line-length |
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.
This can be removed too:
# 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: |
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.
Ideally we would use ansible.builtin.deb822_repository
where possible. See, for example, here.
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.
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.
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.
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?
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.
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.
🗣 Description
This pull request replaces the use of the
copy
module withapt_repository
for Debian-based systems andyum_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