TripleO Ansible project repository. Contains playbooks for use with TripleO OpenStack deployments.
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.

106 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
# 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
path: /var/lib/tripleo-config
state: directory
setype: container_file_t
selevel: s0
- name: Check for previous run of NetworkConfig
become: true
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
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
- name: Create /etc/os-net-config directory
become: true
path: /etc/os-net-config
state: directory
recurse: true
- name: Create os-net-config mappings from lookup data
"{{ 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
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
- name: Remove /var/lib/tripleo-config/scripts directory
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
content: "{{ NetworkConfig_result.rc }}"
dest: /var/lib/tripleo-config/os-net-config.returncode
- 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
name: network
enabled: true
state: started
- 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
- (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 | int) != 0)) or
(not os_net_config_returncode_stat.stat.exists)