You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
3.6 KiB
105 lines
3.6 KiB
--- |
|
# 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. |
|
|
|
- name: Ensure /var/lib/tripleo-config directory exists |
|
become: true |
|
file: |
|
path: /var/lib/tripleo-config |
|
state: directory |
|
setype: container_file_t |
|
selevel: s0 |
|
|
|
- name: Check for previous run of NetworkConfig |
|
become: true |
|
stat: |
|
path: /var/lib/tripleo-config/os-net-config.returncode |
|
register: os_net_config_returncode_stat |
|
|
|
- name: Check result of previous run of NetworkConfig |
|
become: true |
|
slurp: |
|
path: /var/lib/tripleo-config/os-net-config.returncode |
|
when: os_net_config_returncode_stat.stat.exists |
|
register: os_net_config_returncode_slurp |
|
|
|
- name: NetworkConfig |
|
become: true |
|
block: |
|
- name: Create /etc/os-net-config directory |
|
become: true |
|
file: |
|
path: /etc/os-net-config |
|
state: directory |
|
recurse: true |
|
|
|
- name: Create os-net-config mappings from lookup data |
|
tripleo_os_net_config_mappings: |
|
net_config_data_lookup: |
|
"{{ tripleo_network_config_os_net_config_mappings }}" |
|
when: not ansible_check_mode|bool |
|
register: os_net_config_mappings_result |
|
|
|
- name: Write os-net-config mappings file /etc/os-net-config/mapping.yaml |
|
copy: |
|
content: "{{ os_net_config_mappings_result.mapping | to_nice_yaml }}" |
|
dest: /etc/os-net-config/mapping.yaml |
|
when: os_net_config_mappings_result.changed|bool |
|
|
|
- name: Manage NetworkConfig with tripleo_os_net_config module |
|
block: |
|
- name: Remove /var/lib/tripleo-config/scripts directory |
|
file: |
|
path: /var/lib/tripleo-config/scripts |
|
state: absent |
|
|
|
- name: Run NetworkConfig with tripleo_os_net_config |
|
include_tasks: os_net_config.yml |
|
|
|
- name: Write rc of NetworkConfig script |
|
copy: |
|
content: "{{ NetworkConfig_result.rc }}" |
|
dest: /var/lib/tripleo-config/os-net-config.returncode |
|
when: |
|
- NetworkConfig_result.rc is defined |
|
|
|
# os-net-config currently relies on the legacy network |
|
# so we need to ensure it's enabled on boot. This should |
|
# be removed when we switch to NetworkManager or replaced |
|
# with something that ensures NetworkManager is enabled. |
|
- name: Ensure network service is enabled |
|
systemd: |
|
name: network |
|
enabled: true |
|
when: |
|
- tripleo_network_config_manage_service |
|
- not ansible_check_mode|bool |
|
|
|
# The conditions here are when we want to apply the |
|
# NetworkConfig. They are: |
|
# - If the stack_action is CREATE |
|
# - Or UPDATE is in the network_deployment_actions |
|
# - Or the previous run of NetworkConfig failed. |
|
# - Or it has never run |
|
# This will match the prior behavior of when a Heat |
|
# SoftwareDeployment was used. |
|
# It also ensures the script does exist as a sine qua non |
|
# condition |
|
when: |
|
- (tripleo_network_config_action == "CREATE") or |
|
("UPDATE" in tripleo_network_config_network_deployment_actions) or |
|
(os_net_config_returncode_stat.stat.exists and |
|
((os_net_config_returncode_slurp.content | b64decode) != 0)) or |
|
(not os_net_config_returncode_stat.stat.exists)
|
|
|