From 751e2b200cdca94908a36bcaab3d718d739a5e5a Mon Sep 17 00:00:00 2001 From: Jeffrey Cutter Date: Thu, 27 Jun 2024 22:17:28 +0800 Subject: [PATCH 1/4] Add support for providing the convert2rhel repos in Satellite. --- .../allow_convert2rhel_repo_in_satellite.yml | 6 ++++++ roles/common/README.md | 2 ++ roles/common/defaults/main.yml | 2 ++ roles/common/tasks/main.yml | 11 +++++++---- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/allow_convert2rhel_repo_in_satellite.yml diff --git a/changelogs/fragments/allow_convert2rhel_repo_in_satellite.yml b/changelogs/fragments/allow_convert2rhel_repo_in_satellite.yml new file mode 100644 index 0000000..d825b30 --- /dev/null +++ b/changelogs/fragments/allow_convert2rhel_repo_in_satellite.yml @@ -0,0 +1,6 @@ +--- +minor_changes: + - Add support for hosting convert2rhel repo in Satellite. + - Add option to specify enablerepo parameter to yum when installing convert2rhel package. + +... diff --git a/roles/common/README.md b/roles/common/README.md index b86c68c..0e64414 100644 --- a/roles/common/README.md +++ b/roles/common/README.md @@ -16,6 +16,8 @@ Following variables are recommended to **NOT** be changed. | common_convert2rhel_repokey_url | String | https://www.redhat.com/security/data/fd431d51.txt | Can be used to override where to get the GPG Key for the convert2rhel repository. | | common_convert2rhel_7_repofile_url | String | https://cdn-public.redhat.com/content/public/addon/dist/convert2rhel/server/7/7Server/x86_64/files/repofile.repo | Can be used to override where to get the RHEL 7 convert2rhel repo file. | | common_convert2rhel_8_repofile_url | String | https://cdn-public.redhat.com/content/public/addon/dist/convert2rhel8/8/x86_64/files/repofile.repo | Can be used to override where to get the RHEL 8 convert2rhel repo file. | +| common_convert2rhel_repo_satellite | boolean | false | Set to true if the convert2rhel repo is served from Satellite. | +| common_yum_enable_repos | list of strings | unset | Optionally pass a list of repositories to enable to yum install convert2rhel. | Dependencies ------------ diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml index d64dac1..e3245d6 100644 --- a/roles/common/defaults/main.yml +++ b/roles/common/defaults/main.yml @@ -15,6 +15,8 @@ common_centos8_repos: common_supported_distribution: ['CentOS', 'OracleLinux', 'AlmaLinux', 'Rocky'] common_supported_major_version: ['7', '8'] +common_convert2rhel_repo_satellite: false + common_convert2rhel_repokey_url: https://www.redhat.com/security/data/fd431d51.txt common_convert2rhel_7_repofile_url: https://cdn-public.redhat.com/content/public/addon/dist/convert2rhel/server/7/7Server/x86_64/files/repofile.repo common_convert2rhel_8_repofile_url: https://cdn-public.redhat.com/content/public/addon/dist/convert2rhel8/8/x86_64/files/repofile.repo diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 1beeaa4..a212e9b 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -25,7 +25,8 @@ loop: "{{ common_centos8_repos }}" when: ansible_distribution == 'CentOS' and ansible_distribution_major_version | int == 8 -- name: Setup & Install Convert2RHEL +- name: Setup Convert2RHEL repository + when: not common_convert2rhel_repo_satellite block: - name: Download Red Hat GPG key ansible.builtin.get_url: @@ -42,9 +43,10 @@ dest: "/etc/yum.repos.d/convert2rhel.repo" mode: '0644' - - name: Install Convert2RHEL - ansible.builtin.yum: - name: convert2rhel +- name: Install Convert2RHEL + ansible.builtin.yum: + name: convert2rhel + enablerepo: "{{ common_yum_enable_repos | default(omit) }}" - name: Create temporary configuration file ansible.builtin.tempfile: @@ -57,4 +59,5 @@ src: configfile.j2 dest: "{{ convert2rhel_configfile.path }}" mode: '0600' + when: not common_convert2rhel_repo_satellite ... From 109f85ce6981489bdb9592694a7937bc855a3643 Mon Sep 17 00:00:00 2001 From: Jeffrey Cutter Date: Thu, 27 Jun 2024 22:18:07 +0800 Subject: [PATCH 2/4] Update meta/runtime.yml for ansible-lint. --- meta/runtime.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/runtime.yml b/meta/runtime.yml index 32d55c3..d26157b 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,3 +1,3 @@ --- -requires_ansible: ">=2.14.0" +requires_ansible: ">=2.15.0" ... From c85525b6f70a499c2f6afea8708b5725732702e7 Mon Sep 17 00:00:00 2001 From: Jeffrey Cutter Date: Thu, 27 Jun 2024 22:18:48 +0800 Subject: [PATCH 3/4] Update .yamllint for ansible-lint. --- .yamllint | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.yamllint b/.yamllint index 30b4ed5..07c3220 100644 --- a/.yamllint +++ b/.yamllint @@ -7,10 +7,14 @@ ignore: | rules: # 80 chars should be enough, but don't fail if a line is longer line-length: disable + braces: + min-spaces-inside: 0 + max-spaces-inside: 1 comments: require-starting-space: true ignore-shebangs: true min-spaces-from-content: 1 + comments-indentation: false colons: max-spaces-before: 0 max-spaces-after: -1 @@ -24,6 +28,9 @@ rules: spaces: 2 indent-sequences: true check-multi-line-strings: false + octal-values: + forbid-implicit-octal: true + forbid-explicit-octal: true truthy: level: error # Allow only YAML 1.2 booleans https://redhat-cop.github.io/automation-good-practices/#_yaml_and_jinja2_syntax From 905b23d9c39a38f0a868effa1211cd1e35d38d4c Mon Sep 17 00:00:00 2001 From: Jeffrey Cutter Date: Thu, 27 Jun 2024 22:26:22 +0800 Subject: [PATCH 4/4] Switch from ansible.builtin.yum to ansible.builtin.package for ansible-lint. --- roles/common/tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index a212e9b..bad2dc9 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -44,7 +44,7 @@ mode: '0644' - name: Install Convert2RHEL - ansible.builtin.yum: + ansible.builtin.package: name: convert2rhel enablerepo: "{{ common_yum_enable_repos | default(omit) }}"