e5af187c3297f9110026d6343cfd96a4c9eb6526
[ta/caas-cpupooler.git] / ansible / roles / cpupooler / tasks / create_cpu_pools.yaml
1 ---
2 # Copyright 2019 Nokia
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16   - name: collect facts from all hosts
17     setup:
18       gather_subset: min
19     delegate_to: "{{ item }}"
20     delegate_facts: true
21     with_items: "{{ groups['all'] }}"
22
23   - name: make cpu pooler configs
24     set_fact:
25       cpu_poolconfigs: "{{ lookup('template', 'ncir_cpu_pooler_config.yaml.j2') | from_yaml }}"
26
27   - name: template cpu pooler fact file
28     copy:
29       content: "{{ cpu_poolconfigs | to_nice_json }}"
30       dest: "/etc/ansible/facts.d/ncir_cpu_pooler_config.fact"
31     become: true
32     become_user: root
33     register: cpu_pooler_template
34
35   - name: sync to avoid IO issues
36     command: "sync"
37
38   - name: reload facts
39     setup:
40       gather_subset: min
41     when: cpu_pooler_template | changed