Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#327 from rebtoor/download-…
Browse files Browse the repository at this point in the history
…cache-network-config

Enable download-cache for `edpm_network_config` role
  • Loading branch information
openshift-merge-robot authored Sep 14, 2023
2 parents cb28720 + b1c05d9 commit f4adc32
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 6 deletions.
5 changes: 5 additions & 0 deletions roles/edpm_download_cache/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@
ansible.builtin.include_role:
name: osp.edpm.edpm_bootstrap
tasks_from: download_cache.yml

- name: Download packages for edpm_network_config role
ansible.builtin.include_role:
name: osp.edpm.edpm_network_config
tasks_from: download_cache.yml
10 changes: 10 additions & 0 deletions roles/edpm_network_config/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
# supported scenario. Refer to nmstate.io for configuration snippets.
edpm_network_config_tool: os-net-config

# Packages needed by nmstate (via system-role)
edpm_network_config_systemrole_nmstate_dependencies:
- NetworkManager-ovs

# seconds between retries for download tasks
edpm_network_config_download_delay: 5

# number of retries for download tasks
edpm_network_config_download_retries: 5

edpm_network_config_update: false
edpm_network_config_async_poll: 3
edpm_network_config_async_timeout: 300
Expand Down
13 changes: 13 additions & 0 deletions roles/edpm_network_config/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ argument_specs:
main:
short_description: The main entry point for the edpm_network_config role.
options:
edpm_network_config_systemrole_nmstate_dependencies:
type: list
default:
- NetworkManager-ovs
description: Packages needed by nmstate (via system-role)
edpm_network_config_download_delay:
type: int
default: 5
description: The seconds between retries for failed download tasks
edpm_network_config_download_retries:
type: int
default: 5
description: The number of retries for failed download tasks
edpm_network_config_tool:
type: str
description: Which network config tool should be used
Expand Down
23 changes: 23 additions & 0 deletions roles/edpm_network_config/tasks/download_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

- name: Download packages needed by linux-system-role - nmstate
when: edpm_network_config_tool == 'nmstate'
ansible.builtin.dnf:
name: "{{ edpm_network_config_systemrole_nmstate_dependencies }}"
download_only: true
become: true
register: edpm_network_config_systemrole_nmstate_dependencies_download
until: edpm_network_config_systemrole_nmstate_dependencies_download.rc == 0
retries: "{{ edpm_network_config_download_retries }}"
delay: "{{ edpm_network_config_download_delay }}"

- name: Download os-net-config package
when: edpm_network_config_tool == 'os-net-config'
ansible.builtin.dnf:
name: "os-net-config"
download_only: true
become: true
register: edpm_network_config_onc_download
until: edpm_network_config_onc_download.rc == 0
retries: "{{ edpm_network_config_download_retries }}"
delay: "{{ edpm_network_config_download_delay }}"
9 changes: 6 additions & 3 deletions roles/edpm_network_config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# under the License.

- name: Configure network with network role from system roles [nmstate]
when: edpm_network_config_tool == 'nmstate'
block:
- name: Retrieve role name [nmstate]
ansible.builtin.set_fact:
Expand All @@ -28,9 +29,12 @@
delegate_to: localhost
- name: Install OVS NetworkManager plugin [nmstate]
ansible.builtin.dnf:
name: NetworkManager-ovs
state: latest
name: "{{ edpm_network_config_systemrole_nmstate_dependencies }}"
state: present
register: nm_ovs_status
until: nm_ovs_status.rc == 0
retries: "{{ edpm_network_config_download_retries }}"
delay: "{{ edpm_network_config_download_delay }}"
- name: Restart NetworkManager after plugin installation [nmstate]
ansible.builtin.systemd:
name: NetworkManager
Expand All @@ -39,7 +43,6 @@
- name: Load system-roles.network tasks [nmstate]
ansible.builtin.include_role:
name: "{{ systemrolename }}"
when: edpm_network_config_tool == 'nmstate'

- name: Load edpm_network_config tasks [os-net-config]
ansible.builtin.include_tasks:
Expand Down
8 changes: 5 additions & 3 deletions roles/edpm_network_config/tasks/network_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@
ansible.builtin.include_role:
name: osp.edpm.edpm_bootstrap
tasks_from: "packages.yml"
vars:
edpm_bootstrap_dnf_use_cacheonly: false

- name: Install os-net-config package
become: true
ansible.builtin.dnf:
name: os-net-config
state: latest
state: present
register: edpm_network_config_onc_download
until: edpm_network_config_onc_download.rc == 0
retries: "{{ edpm_network_config_download_retries }}"
delay: "{{ edpm_network_config_download_delay }}"

- name: Ensure /var/lib/edpm-config directory exists
become: true
Expand Down

0 comments on commit f4adc32

Please sign in to comment.