aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/reset_resolv_conf/tasks/main.yml
blob: 4e6de695d7df5ca426b49c52017aa4fedb9b79f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copyright (c) 2017 Intel Corporation.
#
# 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: Readlink on /etc/resolv.conf to find original file so we don't break image symlink
  stat:
    path: /etc/resolv.conf
  register: resolv_conf_stat

- name: pre-create resolv.conf sourc link dest
  file:
    path: "{{ resolv_conf_stat.stat.lnk_source|dirname }}"
    state: directory
    mode: 0755

- name: Override resolv.conf link source with specific nameserver
  template:
    src: resolv.conf.j2
    dest: "{{ resolv_conf_stat.stat.lnk_source }}"
span> decimal_list = map(int, ip_str.split('.')) decimal_list[index] = val return '.'.join(map(str, decimal_list)) def parse_yaml(self, yaml_path): with io.open(yaml_path) as yaml_file: self.dea_struct = yaml.load(yaml_file) def get_env_name(self): return self.get_property('environment')['name'] def get_env_net_segment_type(self): return self.get_property('environment')['net_segment_type'] def get_fuel_config(self): return self.dea_struct['fuel'] def get_fuel_ip(self): fuel_conf = self.get_fuel_config() return fuel_conf['ADMIN_NETWORK']['ipaddress'] def get_fuel_netmask(self): fuel_conf = self.get_fuel_config() return fuel_conf['ADMIN_NETWORK']['netmask'] def get_fuel_gateway(self): ip = self.get_fuel_ip() return self.modify_ip(ip, 3, 1) def get_fuel_hostname(self): fuel_conf = self.get_fuel_config() return fuel_conf['HOSTNAME'] def get_fuel_dns(self): fuel_conf = self.get_fuel_config() return fuel_conf['DNS_UPSTREAM'] def get_node_property(self, node_id, property_name): for node in self.dea_struct['nodes']: if node['id'] == node_id and property_name in node: return node[property_name] def get_node_roles(self, node_id): return self.get_node_property(node_id, 'role') def get_node_main_role(self, node_id, fuel_node_id): if node_id == fuel_node_id: return 'fuel' roles = self.get_node_roles(node_id) return 'controller' if 'controller' in roles else 'compute' def get_node_ids(self): node_ids = [] for node in self.dea_struct['nodes']: node_ids.append(node['id']) return node_ids def get_property(self, property_name): return self.dea_struct[property_name] def collect_network_names(self): self.network_names = [] for network in self.dea_struct['network']['networks']: self.network_names.append(network['name']) def get_network_names(self): return self.network_names def get_dns_list(self): settings = self.get_property('settings') dns_list = settings['editable']['external_dns']['dns_list']['value'] return [d.strip() for d in dns_list.split(',')] def get_ntp_list(self): settings = self.get_property('settings') ntp_list = settings['editable']['external_ntp']['ntp_list']['value'] return [n.strip() for n in ntp_list.split(',')] def get_blade_node_map(self): return self.dea_struct['blade_node_map']