aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/infra_rampup_stack_nodes/tasks/update_conf_files.yml
blob: 424fb543b2f1fdedda5490cb766fde4551bb89f1 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright (c) 2018 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: Set hostname
  shell: hostname {{ ansible_hostname }}

- name: Delete hosts between markers
  blockinfile:
    path: /etc/hosts
    marker: "# {mark} generated hosts file"
    content: ""

- set_fact:
    block_str: "{{ block_str | default('') + hostvars[item].host_ip + ' ' + hostvars[item].ansible_host + '\n'}}"
  with_items: "{{ groups['ostack'] }}"

- name: Update /etc/hosts
  blockinfile:
    path: /etc/hosts
    block: |
      {{ block_str }}
    marker: "# {mark} generated hosts file"

- name: Update /etc/hosts
  lineinfile:
    path: /etc/hosts
    regexp: ".*{{ hostvars[groups['jumphost'][0]].proxy_host }}.*"
    line: "{{ hostvars[groups['jumphost'][0]].proxy_host_ip }} {{ hostvars[groups['jumphost'][0]].proxy_host }}"

- name: Turn off IPv6
  lineinfile:
    path: /etc/sysctl.conf
    regexp: '^{{ item }}.*'
    line: "{{ item }} = 1"
  with_items:
    - 'net.ipv6.conf.all.disable_ipv6'
    - 'net.ipv6.conf.default.disable_ipv6'
    - 'net.ipv6.conf.lo.disable_ipv6'

- name: Update IP configuration
  shell: sysctl -p

- name: Update resolv.conf
  shell: echo "{{ 'nameserver ' + hostvars[ansible_host].ansible_default_ipv4.gateway }}" > /etc/resolvconf/resolv.conf.d/base

- name: Update name servers
  shell: resolvconf -u

- name: Update /etc/environment
  lineinfile:
    path: /etc/environment
    regexp: "{{ item.find }}"
    line: "{{ item.add }}"
  with_items:
   - { find: 'http_proxy=', add: "{{ 'export http_proxy=' + lookup('env', 'http_proxy') }}" }
   - { find: 'https_proxy=', add: "{{ 'export https_proxy=' + lookup('env', 'https_proxy') }}" }
   - { find: 'ftp_proxy=', add: "{{ 'export ftp_proxy=' + lookup('env', 'ftp_proxy') }}" }
   - { find: 'no_proxy=', add: "{{ 'export no_proxy=' + lookup('env', 'no_proxy') + ',' + ansible_host + ',' + hostvars[ansible_host].ansible_default_ipv4.address }}" }