Add docker templates for octavia services
[apex-tripleo-heat-templates.git] / extraconfig / pre_network / ansible_host_config.ansible
1 ---
2 - name: Configuration to be applied before rebooting the node
3   connection: local
4   hosts: localhost
5
6   tasks:
7     # Kernel Args Configuration
8     - block:
9         - name: Ensure the kernel args ( {{ _KERNEL_ARGS_ }} ) is present as TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS
10           lineinfile:
11             dest: /etc/default/grub
12             regexp: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
13             insertafter: '^GRUB_CMDLINE_LINUX.*'
14             line: 'TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS=" {{ _KERNEL_ARGS_ }} "'
15         - name: Add TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS to the GRUB_CMDLINE_LINUX parameter
16           lineinfile:
17             dest: /etc/default/grub
18             line: 'GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX:+$GRUB_CMDLINE_LINUX }${TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS}"'
19             insertafter: '^TRIPLEO_HEAT_TEMPLATE_KERNEL_ARGS.*'
20         - name: Generate grub config file
21           command: grub2-mkconfig -o /boot/grub2/grub.cfg
22       become: true
23       when: _KERNEL_ARGS_|default("") != ""
24
25     # Tune-d Configuration
26     - block:
27         - name: Tune-d Configuration
28           lineinfile:
29             dest: /etc/tuned/cpu-partitioning-variables.conf
30             regexp: '^isolated_cores=.*'
31             line: 'isolated_cores={{ _HOST_CPUS_LIST_ }}'
32           when: _HOST_CPUS_LIST_|default("") != ""
33
34         - name: Tune-d provile activation
35           shell: tuned-adm profile {{ _TUNED_PROFILE_NAME_ }}
36       become: true
37       when: _TUNED_PROFILE_NAME_|default("") != ""
38
39     # Provisioning Network workaround
40     # The script will be executed before os-net-config, in which case, only Provisioning network will have IP
41     # BOOTPROTO of all interface config files (except provisioning), will be set to "none" to avoid reboot failing to acquire IP on other networks
42     - block:
43       - find:
44           paths: /etc/sysconfig/network-scripts/
45           patterns: ifcfg-*
46         register: ifcfg_files
47
48       - replace:
49           dest: "{{ item.path }}"
50           regexp: '^BOOTPROTO=.*'
51           replace: 'BOOTPROTO=none'
52         when:
53           - item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') != "lo"
54           # This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
55           # Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4']['address'] is undefined
56           - hostvars[inventory_hostname]['ansible_' + item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') ]['ipv4']['address'] is undefined
57         with_items:
58           - "{{ ifcfg_files.files }}"