Install barometer collectd container on all hosts
[yardstick.git] / ansible / roles / infra_rampup_stack_nodes / tasks / update_conf_files.yml
1 # Copyright (c) 2018 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 - name: Set hostname
16   shell: hostname {{ ansible_hostname }}
17
18 - name: Delete hosts between markers
19   blockinfile:
20     path: /etc/hosts
21     marker: "# {mark} generated hosts file"
22     content: ""
23
24 - set_fact:
25     block_str: "{{ block_str | default('') + hostvars[item].host_ip + ' ' + hostvars[item].ansible_host + '\n'}}"
26   with_items: "{{ groups['ostack'] }}"
27
28 - name: Update /etc/hosts
29   blockinfile:
30     path: /etc/hosts
31     block: |
32       {{ block_str }}
33     marker: "# {mark} generated hosts file"
34
35 - name: Update /etc/hosts
36   lineinfile:
37     path: /etc/hosts
38     regexp: ".*{{ hostvars[groups['jumphost'][0]].proxy_host }}.*"
39     line: "{{ hostvars[groups['jumphost'][0]].proxy_host_ip }} {{ hostvars[groups['jumphost'][0]].proxy_host }}"
40
41 - name: Turn off IPv6
42   lineinfile:
43     path: /etc/sysctl.conf
44     regexp: '^{{ item }}.*'
45     line: "{{ item }} = 1"
46   with_items:
47     - 'net.ipv6.conf.all.disable_ipv6'
48     - 'net.ipv6.conf.default.disable_ipv6'
49     - 'net.ipv6.conf.lo.disable_ipv6'
50
51 - name: Update IP configuration
52   shell: sysctl -p
53
54 - name: Update resolv.conf
55   shell: echo "{{ 'nameserver ' + hostvars[ansible_host].ansible_default_ipv4.gateway }}" > /etc/resolvconf/resolv.conf.d/base
56
57 - name: Update name servers
58   shell: resolvconf -u
59
60 - name: Update /etc/environment
61   lineinfile:
62     path: /etc/environment
63     regexp: "{{ item.find }}"
64     line: "{{ item.add }}"
65   with_items:
66    - { find: 'http_proxy=', add: "{{ 'export http_proxy=' + lookup('env', 'http_proxy') }}" }
67    - { find: 'https_proxy=', add: "{{ 'export https_proxy=' + lookup('env', 'https_proxy') }}" }
68    - { find: 'ftp_proxy=', add: "{{ 'export ftp_proxy=' + lookup('env', 'ftp_proxy') }}" }
69    - { find: 'no_proxy=', add: "{{ 'export no_proxy=' + lookup('env', 'no_proxy') + ',' + ansible_host + ',' + hostvars[ansible_host].ansible_default_ipv4.address }}" }