Skip to content

Commit 332f74f

Browse files
committed
Move package management related config to system_packages
boostrap_os initial purpose is to provision Python on managed nodes which don't have it pre-installed. Some OS specifics tasks here are in fact related to package management (installing extra packages sources like epel, package manager proxy settings). Move all of those to system_packages, allowing to eliminate some call to the setup module.
1 parent 8af9f37 commit 332f74f

File tree

15 files changed

+123
-196
lines changed

15 files changed

+123
-196
lines changed

roles/bootstrap_os/handlers/main.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

roles/bootstrap_os/tasks/almalinux.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

roles/bootstrap_os/tasks/main.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
loop_control:
3131
loop_var: included_tasks_file
3232

33+
- name: Gather facts
34+
setup:
35+
gather_subset:
36+
- '!all'
37+
- '!min'
38+
- distribution
39+
- os_family
40+
- pkg_mgr
41+
- system
42+
3343
- name: Install system packages
3444
import_role:
3545
name: system_packages
@@ -42,11 +52,6 @@
4252
state: directory
4353
mode: "0700"
4454

45-
- name: Gather facts
46-
setup:
47-
gather_subset: '!all'
48-
filter: ansible_*
49-
5055
- name: Assign inventory name to unconfigured hostnames (non-CoreOS, non-Flatcar, Suse and ClearLinux, non-Fedora)
5156
hostname:
5257
name: "{{ inventory_hostname }}"

roles/bootstrap_os/tasks/openEuler.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

roles/bootstrap_os/tasks/opensuse-leap.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

roles/bootstrap_os/tasks/opensuse-tumbleweed.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

roles/bootstrap_os/tasks/rhel.yml

Lines changed: 0 additions & 95 deletions
This file was deleted.

roles/bootstrap_os/tasks/rocky.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

roles/system_packages/tasks/main.yml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
---
2-
- name: Gather OS information
3-
setup:
4-
gather_subset:
5-
- distribution
6-
- pkg_mgr
2+
- name: Add proxy to yum.conf or dnf.conf if http_proxy is defined
3+
community.general.ini_file:
4+
path: "/etc/dnf/dnf.conf"
5+
section: main
6+
option: proxy
7+
value: "{{ http_proxy | default(omit) }}"
8+
state: "{{ http_proxy | default(False) | ternary('present', 'absent') }}"
9+
no_extra_spaces: true
10+
mode: "0644"
11+
become: true
12+
when:
13+
- not skip_http_proxy_on_os_packages
14+
- ansible_pkg_mgr == 'dnf'
15+
16+
- name: Distribution family specific package config
17+
include_tasks: "{{ item }}"
18+
with_first_found:
19+
- files:
20+
- "os_family/{{ ansible_os_family }}.yml"
21+
skip: true
22+
23+
- name: Distribution specific package config
24+
include_tasks: "{{ item }}"
25+
with_first_found:
26+
- files:
27+
- "os/{{ ansible_distribution }}.yml"
28+
skip: true
729

830
- name: Update package management cache (zypper) - SUSE
931
command: zypper -n --gpg-auto-import-keys ref
@@ -15,25 +37,6 @@
1537
- ansible_pkg_mgr == 'zypper'
1638
tags: bootstrap_os
1739

18-
- name: Remove legacy docker repo file
19-
file:
20-
path: "{{ yum_repo_dir }}/docker.repo"
21-
state: absent
22-
when:
23-
- ansible_os_family == "RedHat"
24-
- not is_fedora_coreos
25-
26-
- name: Install epel-release on RHEL derivatives
27-
package:
28-
name: epel-release
29-
state: present
30-
when:
31-
- ansible_os_family == "RedHat"
32-
- not is_fedora_coreos
33-
- epel_enabled | bool
34-
tags:
35-
- bootstrap_os
36-
3740
# Remove this after ansible-core >= 2.19.0
3841
# See https://github.com/kubernetes-sigs/kubespray/pull/12138#issuecomment-3019304574
3942
- name: Install python3-libdnf5 on Fedora >= 41

0 commit comments

Comments
 (0)