|
| 1 | +--- |
| 2 | +# Copyright 2020 Red Hat, Inc. |
| 3 | +# All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. You may obtain |
| 7 | +# a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | +# License for the specific language governing permissions and limitations |
| 15 | +# under the License. |
| 16 | +# |
| 17 | +# Apply network configuration with os-net-config. |
| 18 | +# |
| 19 | + |
| 20 | +- name: Purge os-net-config configuration |
| 21 | + become: true |
| 22 | + block: |
| 23 | + - name: Set nic_config_file fact |
| 24 | + ansible.builtin.set_fact: |
| 25 | + nic_config_file: "/etc/os-net-config/config.yaml" |
| 26 | + - name: Render network_config from template |
| 27 | + no_log: "{{ edpm_network_config_hide_sensitive_logs | bool }}" |
| 28 | + ansible.builtin.copy: |
| 29 | + content: "{{ edpm_network_config_template }}" |
| 30 | + dest: "{{ nic_config_file }}" |
| 31 | + mode: '0644' |
| 32 | + backup: true |
| 33 | + - name: Retrieve and output nic_config_file contents for debug before applying |
| 34 | + when: edpm_network_config_debug|bool |
| 35 | + block: |
| 36 | + - name: Retrieve content of nic_config_file before applying |
| 37 | + ansible.builtin.slurp: |
| 38 | + path: "{{ nic_config_file }}" |
| 39 | + register: os_net_config_config |
| 40 | + - name: Debug print nic_config_file contents |
| 41 | + ansible.builtin.debug: |
| 42 | + msg: "{{ os_net_config_config['content'] | b64decode | trim }}" |
| 43 | + - name: Run edpm_os_net_config_module to purge network_config |
| 44 | + edpm_os_net_config: |
| 45 | + cleanup: "{{ edpm_network_config_nonconfigured_cleanup }}" |
| 46 | + config_file: "{{ nic_config_file }}" |
| 47 | + purge-provider: "{{ edpm_network_config_purge_provider }}" |
| 48 | + debug: "{{ edpm_network_config_debug | bool }}" |
| 49 | + detailed_exit_codes: true |
| 50 | + safe_defaults: "{{ edpm_network_config_safe_defaults | bool }}" |
| 51 | + async: "{{ edpm_network_config_async_timeout }}" |
| 52 | + poll: "{{ edpm_network_config_async_poll }}" |
| 53 | + register: network_config_result |
| 54 | + when: not ansible_check_mode |
0 commit comments