27703d358733b3cb8345391516fed9c9c1137ca7
[ta/infra-ansible.git] / roles / sriov_nodes / tasks / sriov.yaml
1 ---
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 - name: Set sriov config dir variable
18   set_fact:
19     sriov_conf_dir: "/etc/sriov"
20
21 - name:  ensure sriov config dir exists
22   file:
23     path: "{{ sriov_conf_dir }}"
24     recurse: "yes"
25     state: "directory"
26     mode: "0755"
27
28 - name: Create /etc/sriov/sriov.conf file
29   template:
30     src: "sriov.conf.j2"
31     dest: "{{ sriov_conf_dir }}/sriov.conf"
32     owner: "root"
33     mode: "0644"
34
35 - name: Configure VF count
36   script: configure_vf_count.sh
37   register: configure_vf_count_result
38   failed_when: not (configure_vf_count_result.rc == 0 or configure_vf_count_result.rc == 2)
39   changed_when: configure_vf_count_result.rc == 2
40
41 - debug: var=configure_vf_count_result.stdout_lines
42   when: configure_vf_count_result.rc != 0
43
44 - debug: var=configure_vf_count_result.stderr_lines
45   when: configure_vf_count_result.rc != 0
46
47 - name: Restart sriov service
48   systemd:
49     service: sriov
50     state: restarted
51   when:
52     - hostname == installation_controller
53     - ('caas_master' in hosts[hostname]['service_profiles']) or ('caas_worker' in hosts[hostname]['service_profiles'])