tripleo-ansible/tripleo_ansible/roles/tripleo_network_config/tasks/os_net_config.yml

67 lines
2.5 KiB
YAML

---
# Copyright 2020 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# Apply network configuration with os-net-config.
#
- name: Apply os-net-config configuration
become: true
block:
- name: Set nic_config_file fact
set_fact:
nic_config_file: "{{ (tripleo_network_config_with_ansible|bool) \
| ternary('/etc/os-net-config/config.yaml', \
'/etc/os-net-config/config.json') }}"
- name: Render overidden network config
no_log: "{{ tripleo_network_config_hide_sensitive_logs | bool }}"
copy:
content: "{{tripleo_network_config_override | to_yaml}}"
dest: "{{ nic_config_file }}"
mode: 0600
backup: true
when:
- tripleo_network_config_override.keys()|length > 0
- name: Render network_config
no_log: "{{ tripleo_network_config_hide_sensitive_logs | bool }}"
template:
src: "{{ tripleo_network_config_script_path }}"
dest: "{{ nic_config_file }}"
mode: 0600
backup: true
when:
- not tripleo_network_config_with_ansible|bool
- tripleo_network_config_override.keys()|length == 0
- name: Render network_config from template
no_log: "{{ tripleo_network_config_hide_sensitive_logs | bool }}"
template:
src: "{{ tripleo_network_config_template }}"
dest: "{{ nic_config_file }}"
mode: 0600
backup: true
when:
- tripleo_network_config_with_ansible|bool
- tripleo_network_config_override.keys()|length == 0
- name: Run tripleo_os_net_config_module with network_config
tripleo_os_net_config:
config_file: "{{ nic_config_file }}"
debug: "{{ tripleo_network_config_debug|bool }}"
detailed_exit_codes: true
safe_defaults: "{{ tripleo_network_config_safe_defaults | bool }}"
async: "{{ tripleo_network_config_async_timeout }}"
poll: "{{ tripleo_network_config_async_poll }}"
register: NetworkConfig_result
when: not ansible_check_mode